2 #include "../interface/MicroGMTLUT.h"
10 std::stringstream
out;
13 out <<
"}" << std::endl;
19 std::ifstream fstream;
21 if (!fstream.good()) {
23 throw cms::Exception(
"FileOpenError") <<
"Failed to open LUT file: " << inFileName;
29 while (!fstream.eof()) {
33 if (lineID.find(
"CONTENT_VECTOR") != std::string::npos)
break;
38 throw cms::Exception(
"FileOpenError") <<
"Failed to find LUT contents";
41 for (
int cntr = 0; cntr < (1 << m_totalInWidth); ++cntr) {
42 fstream >> m_contents[cntr];
53 return m_contents.at(input);
55 throw cms::Exception(
"Unitialized") <<
"If you're not loading a LUT from file you need to implement lookupPacked.";
62 for (
int in = 0;
in < (1 << m_totalInWidth); ++
in) {
63 int out = lookupPacked(
in);
72 unsigned maxIn = (1 <<
maxWidth) - 1;
73 return (in < maxIn ? in : maxIn);
79 stream <<
"\"CONTENT\" : [ ";
81 int maxVal = (1<<m_totalInWidth);
82 for (
int in = 0;
in < maxVal; ++
in) {
83 stream << lookupPacked(
in);
84 if (
in != maxVal - 1) {
88 stream <<
"] " << std::endl;
94 stream <<
"{" << std::endl;
95 stream <<
"\"NAME\" : \"Name of the LUT\","<< std::endl;
96 stream <<
"\"INSTNACES\" : \"List (space separated) of instances of this LUT (differing contents but same in/output)\"," << std::endl;
97 stream <<
"\"INPUTS\" : \"List (space separated) of inputs in format <input_name>(<input_width>)\"," << std::endl;
98 stream <<
"\"OUTPUTS\" : \"List (space separated) of outputs in format <output_name>(<output_width>)\"," << std::endl;
99 stream <<
"\"IPBUS_ADD\" : \"Address for access via IPBus\"," << std::endl;
100 stream <<
"\"CONTENT_X\" : \"List (space separated) of outputs from packed int for zero-indexed instance X\"," << std::endl;
void contentsToStream(std::stringstream &stream)
virtual int lookupPacked(int input) const
int checkedInput(unsigned in, unsigned maxWidth) const
static std::string const input
void headerToStream(std::stringstream &stream) const
void load(const std::string &inFileName)
void save(std::ofstream &output)