#include <L1MuGMTLUT.h>
Classes | |
class | PortDecoder |
Public Types | |
typedef std::pair< std::string, unsigned > | port |
Public Member Functions | |
L1MuGMTLUT () | |
Init and Destruct. | |
L1MuGMTLUT (const char *name, const std::vector< std::string > &instances, const std::vector< port > &in_widths, const std::vector< port > &out_widths, unsigned vme_addr_width=0, bool distrRAM=false) | |
constructor with init | |
L1MuGMTLUT (const char *name, const std::string &instances, const std::string &inputs, const std::string &outputs, unsigned vme_addr_width=0, bool distrRAM=false) | |
void | Load (const char *path) |
I/O functions. | |
std::vector< unsigned > | Lookup (int idx, unsigned address) const |
additional lookup function (unsigned -> std::vector) | |
std::vector< unsigned > | Lookup (int idx, const std::vector< unsigned > &address) const |
additional lookup function (std::vector -> vector) | |
virtual unsigned | LookupFunctionPacked (int idx, unsigned address) const |
unsigned | LookupPacked (int idx, unsigned) const |
unsigned | LookupPacked (int idx, const std::vector< unsigned > &address) const |
additional lookup function (std::vector -> unisgned) | |
void | MakeSubClass (const char *fname="", const char *template_file_h="../interface/L1MuGMTLUT_SubClass.h_template", const char *template_file_cc="../interface/L1MuGMTLUT_SubClass.cc_template") |
Add Generate SubClass method. | |
std::string | Name () |
int | numberOfInstances () |
get the number of Instances | |
void | Save (const char *path) |
save to LUT file | |
virtual | ~L1MuGMTLUT () |
destructor | |
Protected Member Functions | |
void | Init (const char *name, const std::vector< std::string > &instances, const std::vector< port > &in_widths, const std::vector< port > &out_widths, unsigned vme_addr_width=0, bool distrRAM=false) |
Initialize the LUT. | |
void | Set (int idx, unsigned address, unsigned value) |
set with single address and value | |
std::vector< unsigned > | u2vec (unsigned value, const std::vector< port > &widths) const |
generate composite address or value from compact unsigned | |
unsigned | vec2u (const std::vector< unsigned > &vec, const std::vector< port > &widths) const |
generate address or value from composite address or value | |
Protected Attributes | |
std::vector< std::vector < unsigned > > | m_Contents |
bool | m_distrRAM |
unsigned | m_GeneralLUTVersion |
bool | m_initialized |
std::vector< port > | m_Inputs |
std::vector< std::string > | m_InstNames |
std::string | m_name |
int | m_NLUTS |
std::vector< port > | m_Outputs |
bool | m_saveFlag |
unsigned | m_TotalInWidth |
unsigned | m_TotalOutWidth |
bool | m_UseLookupFunction |
unsigned | m_vme_addr_width |
Friends | |
class | L1MuGMTLUTConverter |
Description: A general-purpose Look-Up-Table Class
Base class for all LUTs in the Global Muon Trigger Simulation
INPUTS OUTPUTS
-------- | | | |-- Y(1) eta(6) --| | 1 8..13 | | phi(8) --| | 0..7 | |-- X(1) | | 0 --------
std::vector<unsigned> inp; inp [0] = phi inp [1] = eta
std::vector<unsigned> out = MyLUT.Lookup (lutidx, inp); X = out[0]; Y = out[1];
Definition at line 77 of file L1MuGMTLUT.h.
typedef std::pair<std::string, unsigned> L1MuGMTLUT::port |
Definition at line 80 of file L1MuGMTLUT.h.
L1MuGMTLUT::L1MuGMTLUT | ( | ) | [inline] |
Init and Destruct.
default constructor w/o init
Definition at line 85 of file L1MuGMTLUT.h.
: m_initialized(0), m_NLUTS(0), m_UseLookupFunction(true), m_saveFlag(false) {};
L1MuGMTLUT::L1MuGMTLUT | ( | const char * | name, |
const std::vector< std::string > & | instances, | ||
const std::vector< port > & | in_widths, | ||
const std::vector< port > & | out_widths, | ||
unsigned | vme_addr_width = 0 , |
||
bool | distrRAM = false |
||
) | [inline] |
constructor with init
Definition at line 88 of file L1MuGMTLUT.h.
References Init().
: m_initialized(0), m_NLUTS(0), m_UseLookupFunction(true), m_saveFlag(false) { Init (name, instances, in_widths, out_widths, vme_addr_width, distrRAM); };
L1MuGMTLUT::L1MuGMTLUT | ( | const char * | name, |
const std::string & | instances, | ||
const std::string & | inputs, | ||
const std::string & | outputs, | ||
unsigned | vme_addr_width = 0 , |
||
bool | distrRAM = false |
||
) | [inline] |
Definition at line 96 of file L1MuGMTLUT.h.
References Init().
: m_initialized(0), m_NLUTS(0), m_UseLookupFunction(true), m_saveFlag(false) { Init (name, L1MuGMTLUTHelpers::Tokenizer(" ",instances), PortDecoder(inputs), PortDecoder(outputs), vme_addr_width, distrRAM); };
L1MuGMTLUT::~L1MuGMTLUT | ( | ) | [virtual] |
destructor
Definition at line 37 of file L1MuGMTLUT.cc.
{ if (! m_UseLookupFunction ) { // de-allocate vectors // no destuction needed for vector< vector <unsigned> > // for (int i=0;i < m_NLUTS; i++) // m_Contents[i].clear(); // m_Contents.clear(); } }
void L1MuGMTLUT::Init | ( | const char * | name, |
const std::vector< std::string > & | instances, | ||
const std::vector< port > & | in_widths, | ||
const std::vector< port > & | out_widths, | ||
unsigned | vme_addr_width = 0 , |
||
bool | distrRAM = false |
||
) | [protected] |
Initialize the LUT.
Referenced by L1MuGMTLUT().
void L1MuGMTLUT::Load | ( | const char * | path | ) |
I/O functions.
load from LUT file
Definition at line 196 of file L1MuGMTLUT.cc.
References spr::find(), i, recoMuon::in, geometryCSVtoXML::line, linker::replace(), results_mgr::tok, and relativeConstraints::value.
{ string lf_name(""); vector <string> lf_InstNames; vector <port> lf_Inputs; vector <port> lf_Outputs; unsigned lf_vme_addr_width=0; bool lf_distrRAM=false; vector<string> lf_comments; ifstream in (path); const int sz=1000; char buf[sz]; // read header while ( in.getline(buf, sz) ) { string line(buf); string::size_type i=0; if ( (i=line.find("//")) != string::npos) { lf_comments.push_back( line.substr(i) ); // save comments line.erase(i); // and strip } L1MuGMTLUTHelpers::Tokenizer tok("=", line); if (tok.size() == 2) { L1MuGMTLUTHelpers::replace(tok[0], " ","", false); // skip spaces L1MuGMTLUTHelpers::replace(tok[0], "\t","", false); // skip tabs L1MuGMTLUTHelpers::replace(tok[1], "\t", " ", false); // convert tabs to spaces L1MuGMTLUTHelpers::replace(tok[1], " ", " ", true); // skip multiple spaces tok[1].erase(0, tok[1].find_first_not_of(" ")); // skip leading spaces tok[1].erase(tok[1].find_last_not_of(" ")+1); // skip trailing spaces if (tok[0] == "NAME") lf_name = tok[1]; else if (tok[0] == "INSTANCES") { lf_InstNames = L1MuGMTLUTHelpers::Tokenizer(" ",tok[1]); } else if (tok[0] == "LUT_INPUTS") lf_Inputs = PortDecoder(tok[1]); else if (tok[0] == "LUT_OUTPUTS") lf_Outputs = PortDecoder(tok[1]); else if (tok[0] == "VME_ADDR_WIDTH") lf_vme_addr_width = atoi(tok[1].c_str()); else if (tok[0] == "DISTRIBUTED_RAM") lf_distrRAM = ( atoi(tok[1].c_str()) == 1 ); } if (tok[0].find("CONTENTS") != string::npos) break; } if (!m_initialized) { // then initialize Init(lf_name.c_str(), lf_InstNames, lf_Inputs, lf_Outputs, lf_vme_addr_width, lf_distrRAM); } else { // verify compatibility if (m_name != lf_name || m_InstNames != lf_InstNames || m_Inputs != lf_Inputs || m_Outputs != lf_Outputs || m_vme_addr_width != lf_vme_addr_width || m_distrRAM != lf_distrRAM) { edm::LogWarning("LUTParmasMismatch") << "L1MuGMTLUT::Load: error: parameters in file do not match configuration of LUT. Load failed."; return; } } if (m_UseLookupFunction) { // allocate vectors m_Contents.resize( m_NLUTS ); for (int i=0;i < m_NLUTS; i++) m_Contents[i].resize( 1 << m_TotalInWidth ); // switch to table mode m_UseLookupFunction = false; } // continue to read contents (first line should be in buf) int maxrows = 1 << m_TotalInWidth; int row = 0; int current_index = -1; do { string line(buf); string::size_type i=0; if ( (i=line.find("//")) != string::npos) line.erase(i); // strip comments L1MuGMTLUTHelpers::Tokenizer tok("=", line); if (tok.size() == 2 && tok[0].find("CONTENTS") != string::npos) { L1MuGMTLUTHelpers::Tokenizer tok1("_",tok[0]); if (tok1.size() !=2) { edm::LogWarning("LUTParsingProblem") << "L1MuGMTLUT::Load: error parsing contents tag " << tok[0] << "."; break; } istringstream is(tok1[1].c_str()); int newindex; is >> newindex; if (newindex != current_index+1) edm::LogWarning("LUTParsingProblem") << "L1MuGMTLUT::Load: warning: LUTS in LUT file are not in order."; if (newindex > m_NLUTS-1) { edm::LogWarning("LUTParsingProblem") << "L1MuGMTLUT::Load: warning: LUT file contains LUT with too high index (" << tok[0] << "). max = " << m_NLUTS << " skipping."; newindex = -1; } current_index = newindex; if (row != 0) { if ( row < maxrows ) edm::LogWarning("LUTParsingProblem") << "L1MuGMTLUT::Load: warning: LUT file only contains part of LUT contents."; row = 0; } istringstream is1(tok[1].c_str()); unsigned value; if (is1 >> value) { if (current_index!=-1) Set (current_index, row++, value); } } else { istringstream is1(line.c_str()); unsigned value; if (is1 >> value) { if (row < maxrows) { if (current_index!=-1) Set (current_index, row++, value); } else edm::LogWarning("LUTParsingProblem") << "L1MuGMTLUT::Load: warning: LUT file only contains LUT with too many entries. skipping."; } } } while ( in.getline(buf, sz) ); }
std::vector<unsigned> L1MuGMTLUT::Lookup | ( | int | idx, |
const std::vector< unsigned > & | address | ||
) | const [inline] |
additional lookup function (std::vector -> vector)
Definition at line 117 of file L1MuGMTLUT.h.
References m_Inputs, and vec2u().
Referenced by L1MuGMTMIAUPhiPro1LUT::SpecificLookup_cphi_fine(), L1MuGMTMIAUPhiPro1LUT::SpecificLookup_cphi_ofs(), L1MuGMTLFCOUDeltaEtaLUT::SpecificLookup_delta_eta(), L1MuGMTLFDeltaEtaLUT::SpecificLookup_delta_eta(), L1MuGMTLFDisableHotLUT::SpecificLookup_disable_hot(), L1MuGMTLFPhiProLUT::SpecificLookup_dphi(), L1MuGMTLFEtaConvLUT::SpecificLookup_eta_gmt(), L1MuGMTLFPhiProEtaConvLUT::SpecificLookup_eta_out(), L1MuGMTMIAUEtaConvLUT::SpecificLookup_eta_out(), L1MuGMTLFOvlEtaConvLUT::SpecificLookup_eta_ovl(), L1MuGMTMIAUEtaProLUT::SpecificLookup_eta_sel(), L1MuGMTLFMergeRankEtaQLUT::SpecificLookup_flag(), L1MuGMTLFMergeRankCombineLUT::SpecificLookup_merge_rank(), L1MuGMTLFMatchQualLUT::SpecificLookup_mq(), L1MuGMTMIAUPhiPro2LUT::SpecificLookup_phi_sel(), L1MuGMTLFPtMixLUT::SpecificLookup_pt_mixed(), L1MuGMTLFMergeRankEtaPhiLUT::SpecificLookup_rank_etaphi(), L1MuGMTLFSortRankEtaPhiLUT::SpecificLookup_rank_etaphi(), L1MuGMTLFMergeRankEtaQLUT::SpecificLookup_rank_etaq(), L1MuGMTLFSortRankEtaQLUT::SpecificLookup_rank_etaq(), L1MuGMTLFSortRankPtQLUT::SpecificLookup_rank_ptq(), L1MuGMTLFMergeRankPtQLUT::SpecificLookup_rank_ptq(), L1MuGMTLFSortRankCombineLUT::SpecificLookup_sort_rank(), and L1MuGMTLFSortRankEtaQLUT::SpecificLookup_vlq().
std::vector<unsigned> L1MuGMTLUT::Lookup | ( | int | idx, |
unsigned | address | ||
) | const [inline] |
additional lookup function (unsigned -> std::vector)
Definition at line 121 of file L1MuGMTLUT.h.
References LookupPacked(), m_Outputs, and u2vec().
{ return u2vec ( LookupPacked(idx, address), m_Outputs ); };
virtual unsigned L1MuGMTLUT::LookupFunctionPacked | ( | int | idx, |
unsigned | address | ||
) | const [inline, virtual] |
lookup defined as analytic function to be impemented in derived class
Reimplemented in L1MuGMTLFCOUDeltaEtaLUT, L1MuGMTLFDeltaEtaLUT, L1MuGMTLFDisableHotLUT, L1MuGMTLFEtaConvLUT, L1MuGMTLFMatchQualLUT, L1MuGMTLFMergeRankCombineLUT, L1MuGMTLFMergeRankEtaPhiLUT, L1MuGMTLFMergeRankEtaQLUT, L1MuGMTLFMergeRankPtQLUT, L1MuGMTLFOvlEtaConvLUT, L1MuGMTLFPhiProEtaConvLUT, L1MuGMTLFPhiProLUT, L1MuGMTLFPtMixLUT, L1MuGMTLFSortRankCombineLUT, L1MuGMTLFSortRankEtaPhiLUT, L1MuGMTLFSortRankEtaQLUT, L1MuGMTLFSortRankPtQLUT, L1MuGMTMIAUEtaConvLUT, L1MuGMTMIAUEtaProLUT, L1MuGMTMIAUPhiPro1LUT, and L1MuGMTMIAUPhiPro2LUT.
Definition at line 136 of file L1MuGMTLUT.h.
Referenced by LookupPacked().
{ return 0; };
unsigned L1MuGMTLUT::LookupPacked | ( | int | idx, |
const std::vector< unsigned > & | address | ||
) | const [inline] |
additional lookup function (std::vector -> unisgned)
Definition at line 113 of file L1MuGMTLUT.h.
References LookupPacked(), m_Inputs, and vec2u().
{ return LookupPacked (idx, vec2u ( address, m_Inputs ) ); };
unsigned L1MuGMTLUT::LookupPacked | ( | int | idx, |
unsigned | address | ||
) | const [inline] |
main lookup function (unsigned -> unsigned) all lookup functions go through this one
Definition at line 262 of file L1MuGMTLUT.h.
References LookupFunctionPacked(), m_Contents, m_initialized, m_name, m_NLUTS, m_TotalInWidth, m_TotalOutWidth, m_UseLookupFunction, and relativeConstraints::value.
Referenced by Lookup(), LookupPacked(), L1MuGMTLFEtaConvLUT::SpecificLookup(), L1MuGMTLFPhiProEtaConvLUT::SpecificLookup(), L1MuGMTLFMergeRankEtaQLUT::SpecificLookup(), L1MuGMTLFMergeRankCombineLUT::SpecificLookup(), L1MuGMTLFCOUDeltaEtaLUT::SpecificLookup(), L1MuGMTLFSortRankPtQLUT::SpecificLookup(), L1MuGMTMIAUPhiPro2LUT::SpecificLookup(), L1MuGMTMIAUPhiPro1LUT::SpecificLookup(), L1MuGMTLFDisableHotLUT::SpecificLookup(), L1MuGMTLFOvlEtaConvLUT::SpecificLookup(), L1MuGMTMIAUEtaConvLUT::SpecificLookup(), L1MuGMTLFDeltaEtaLUT::SpecificLookup(), L1MuGMTLFMergeRankEtaPhiLUT::SpecificLookup(), L1MuGMTLFPtMixLUT::SpecificLookup(), L1MuGMTMIAUEtaProLUT::SpecificLookup(), L1MuGMTLFMergeRankPtQLUT::SpecificLookup(), L1MuGMTLFPhiProLUT::SpecificLookup(), L1MuGMTLFMatchQualLUT::SpecificLookup(), L1MuGMTLFSortRankCombineLUT::SpecificLookup(), L1MuGMTLFSortRankEtaPhiLUT::SpecificLookup(), and L1MuGMTLFSortRankEtaQLUT::SpecificLookup().
{ if (! m_initialized) { edm::LogWarning("LUTMismatch") << "Error in L1MuGMTLUT::LookupPacked: LUT not initialized. "; return 0; } if ( idx >= m_NLUTS ) { edm::LogWarning("LUTMismatch") << "Error in L1MuGMTLUT::LookupPacked: LUT index exceeds range (0 to " << ( m_NLUTS -1 ) << ")." ; return 0; } if ( address >= (unsigned) (1 << m_TotalInWidth) ) { edm::LogWarning("LUTMismatch") << "Error in L1MuGMTLUT::LookupPacked: LUT input exceeds range (0 to " << ( (1 << m_TotalInWidth) -1 ) << ")." ; return 0; } unsigned value = 0; if (m_UseLookupFunction) { value = LookupFunctionPacked (idx, address); } else { value = m_Contents[idx][address]; } // check range of output if ( value >= (unsigned) (1 << m_TotalOutWidth) ) { edm::LogWarning("LUTMismatch") << "Error in L1MuGMTLUT::LookupPacked(): LUT output value " << value << " exceeds range (0 to " << ( (1 << m_TotalOutWidth) -1 ) << ")." ; edm::LogWarning("LUTMismatch") << " LUT name: " << m_name; if (m_UseLookupFunction) edm::LogWarning("LUTMismatch") << " Lookup Function has to be corrected!!!"; else edm::LogWarning("LUTMismatch") << " LUT File has to be corrected!!!"; return (1 << m_TotalOutWidth) - 1; } return value; }
void L1MuGMTLUT::MakeSubClass | ( | const char * | fname = "" , |
const char * | template_file_h = "../interface/L1MuGMTLUT_SubClass.h_template" , |
||
const char * | template_file_cc = "../interface/L1MuGMTLUT_SubClass.cc_template" |
||
) |
Add Generate SubClass method.
Definition at line 328 of file L1MuGMTLUT.cc.
References i, recoMuon::in, j, geometryCSVtoXML::line, linker::replace(), tmp, and L1MuGMTLUTHelpers::upperCase().
{ // prepare parts string ins_name (m_name); string ins_name_upper = L1MuGMTLUTHelpers::upperCase (ins_name); string ins_instance_string; string ins_instances_enum; for (unsigned i=0; i<m_InstNames.size(); i++) { if (i!=0) ins_instance_string += ' '; ins_instance_string += m_InstNames[i]; if (i!=0) ins_instances_enum += ", "; ins_instances_enum += m_InstNames[i]; } char ins_vme[100]; sprintf (ins_vme, "%d", m_vme_addr_width); char ins_distr_RAM[10]; sprintf (ins_distr_RAM, "%s", m_distrRAM?"true":"false"); string ins_input_decl_list, ins_input_list, ins_input_addr_list; for (unsigned i=0; i<m_Inputs.size(); i++) { ins_input_decl_list += string(", unsigned ") + m_Inputs[i].first; ins_input_list += string(", ") + m_Inputs[i].first; char tmp[100]; sprintf (tmp, " ,addr[%d]", i); ins_input_addr_list += string(tmp); } // string ins_lookup_functions; ostringstream os; for (unsigned i=0; i<m_Outputs.size(); i++) { os << " /// specific lookup function for " << m_Outputs[i].first << endl; os << " unsigned SpecificLookup_" << m_Outputs[i].first << " (int idx" << ins_input_decl_list << ") const {" << endl; os << " vector<unsigned> addr(" << m_Inputs.size() << ");" << endl; for (unsigned j=0; j< m_Inputs.size(); j++) { os << " addr[" << j << "] = " << m_Inputs[j].first << ";" << endl; } os << " return Lookup(idx, addr) [" << i << "];" << endl; os << " };" << endl << endl; } os << " /// specific lookup function for entire output field" << endl; os << " unsigned SpecificLookup (int idx" << ins_input_decl_list << ") const {" << endl; os << " vector<unsigned> addr(" << m_Inputs.size() << ");" << endl; for (unsigned j=0; j< m_Inputs.size(); j++) { os << " addr[" << j << "] = " << m_Inputs[j].first << ";" << endl; } os << " return LookupPacked(idx, addr);" << endl; os << " };" << endl << endl; os << ends; string ins_lookup_functions = os.str(); // substitute in .h file string outfn (fname); if (outfn.size() == 0) outfn = string("../interface/L1MuGMT") + m_name + string("LUT.h"); ifstream of_check(outfn.c_str()); if (! of_check.good() ) { ofstream of(outfn.c_str()); ifstream in(template_file_h); const int sz=1000; char buf[sz]; while ( in.getline(buf, sz) ) { string line(buf); L1MuGMTLUTHelpers::replace(line, "###insert_name_upper###", ins_name_upper, false); L1MuGMTLUTHelpers::replace(line, "###insert_name###", ins_name, false); L1MuGMTLUTHelpers::replace(line, "###insert_instance_string###", ins_instance_string, false); L1MuGMTLUTHelpers::replace(line, "###insert_instances_enum###", ins_instances_enum, false); L1MuGMTLUTHelpers::replace(line, "###insert_inputs_string###", string(PortDecoder(m_Inputs).str()), false); L1MuGMTLUTHelpers::replace(line, "###insert_outputs_string###", string(PortDecoder(m_Outputs).str()), false); L1MuGMTLUTHelpers::replace(line, "###insert_vme_input_width###", string(ins_vme), false); L1MuGMTLUTHelpers::replace(line, "###insert_distrRAM###", string(ins_distr_RAM), false); L1MuGMTLUTHelpers::replace(line, "###insert_input_decl_list###", ins_input_decl_list, false); L1MuGMTLUTHelpers::replace(line, "###insert_input_list###", ins_input_list, false); L1MuGMTLUTHelpers::replace(line, "###insert_input_addr_list###", ins_input_addr_list, false); L1MuGMTLUTHelpers::replace(line, "###insert_lookup_functions###", ins_lookup_functions, false); of << line << endl; } } // substitute in .cc file string outfn_cc (fname); if (outfn_cc.size() == 0) outfn_cc = string("../interface/L1MuGMT") + m_name + string("LUT.cc"); ifstream of_cc_check( outfn_cc.c_str() ); if (! of_cc_check.good() ) { ofstream of_cc(outfn_cc.c_str()); ifstream in_cc(template_file_cc); const int sz=1000; char buf[sz]; while ( in_cc.getline(buf, sz) ) { string line(buf); L1MuGMTLUTHelpers::replace(line, "###insert_name_upper###", ins_name_upper, false); L1MuGMTLUTHelpers::replace(line, "###insert_name###", ins_name, false); L1MuGMTLUTHelpers::replace(line, "###insert_instance_string###", ins_instance_string, false); L1MuGMTLUTHelpers::replace(line, "###insert_instances_enum###", ins_instances_enum, false); L1MuGMTLUTHelpers::replace(line, "###insert_inputs_string###", string(PortDecoder(m_Inputs).str()), false); L1MuGMTLUTHelpers::replace(line, "###insert_outputs_string###", string(PortDecoder(m_Outputs).str()), false); L1MuGMTLUTHelpers::replace(line, "###insert_vme_input_width###", string(ins_vme), false); L1MuGMTLUTHelpers::replace(line, "###insert_distrRAM###", string(ins_distr_RAM), false); L1MuGMTLUTHelpers::replace(line, "###insert_input_decl_list###", ins_input_decl_list, false); L1MuGMTLUTHelpers::replace(line, "###insert_input_list###", ins_input_list, false); L1MuGMTLUTHelpers::replace(line, "###insert_input_addr_list###", ins_input_addr_list, false); L1MuGMTLUTHelpers::replace(line, "###insert_lookup_functions###", ins_lookup_functions, false); of_cc << line << endl; } } }
std::string L1MuGMTLUT::Name | ( | ) | [inline] |
int L1MuGMTLUT::numberOfInstances | ( | ) | [inline] |
get the number of Instances
Definition at line 147 of file L1MuGMTLUT.h.
References m_NLUTS.
{ return m_NLUTS; };
void L1MuGMTLUT::Save | ( | const char * | path | ) |
save to LUT file
Definition at line 79 of file L1MuGMTLUT.cc.
References i, and L1MuGMTLUT::PortDecoder::str().
{ if (! m_initialized) { edm::LogWarning("LUTNotInitialized") << "L1MuGMTLUT::Save: LUT not initialized. "; return; } m_saveFlag = true; ofstream of(path); of << "// This is a CMS L1 Global Muon Trigger .lut file. " << endl; of << "// " << endl; of << "// It defines a set of look-up-tables(LUTs) of the same type (same inputs and outputs) but" << endl; of << "// with different default contents. For example a certain type of LUT can have different" << endl; of << "// default values for DT for RPC and for CSC muons. " << endl; of << "// " << endl; of << "// NAME gives the name of the LUT. It should match the base name (name without '.lut')" << endl; of << "// of the LUT file." << endl; of << "// When deriving a C++ sub-class the name is used case sensitive." << endl; of << "// In generated VHDL code the name is used in lower case." << endl; of << "// " << endl; of << "// INSTANCES is the list of instances of the LUT with different default values." << endl; of << "// the lists consists of identifiers for each of the instances separated by spaces." << endl; of << "// the identifiers can be made up of characters that are valid in VHDL lables. " << endl; of << "// In the VHDL code they are used to label the different instances." << endl; of << "// " << endl; of << "// In C++ and VHDL the instance of a LUT is selected by an integer index where 0 " << endl; of << "// corresponds to the leftmost identifier. Integer indices are also used in the CONTENTS_XX" << endl; of << "// statements in this file." << endl; of << "// " << endl; of << "// LUT_INPUTS is the (space-separated) list of inputs of the LUT. Each input is specified in the form" << endl; of << "// <input_name>(<number_of_bits>) where <input_name> is the name of the input and" << endl; of << "// <number_of_bits> is the number of bits of the input. <input_name> has to be a valid" << endl; of << "// identifier both in C++ and in VHDL. In C++ it is represented as an unsigned int." << endl; of << "// " << endl; of << "// All LUT inputs together make up the address of the corresponding memory." << endl; of << "// The first input in the list corresponds to the most-significant bits of the address." << endl; of << "// " << endl; of << "// LUT_OUTPUTS is the (space-separated) list of outputs of the LUT. Each output is specified in the form" << endl; of << "// <output_name>(<number_of_bits>) where <output_name> is the name of the output and" << endl; of << "// <number_of_bits> is the number of bits of the output. <output_name> has to be a valid" << endl; of << "// identifier both in C++ and in VHDL. In C++ it is represented as an unsigned int." << endl; of << "// " << endl; of << "// All LUT outputs together make up the data of the corresponding memory." << endl; of << "// The first output in the list corresponds to the most-significant data bits." << endl; of << "// " << endl; of << "// VME_ADDR_WIDTH is the address width of the LUT memory when accessed via VME. When the LUT " << endl; of << "// is implemented as dual-port block RAM, the VME address with can be different " << endl; of << "// from the address width given by the sum of the input widths. It can be larger or" << endl; of << "// smaller by a factor of 2^n. When the LUT is implemented as dual-port distributed RAM," << endl; of << "// the VME address width has to match the input width. " << endl; of << "// " << endl; of << "// DISTRIBUTED_RAM is 1 if the LUT is to be implemented in distributed RAM and 0 for Block RAM " << endl; of << "// Note that for distributed RAM the address width on the GMT side (sum of input widths)" << endl; of << "// has to match the vme_addr_width" << endl; of << "// " << endl; of << "// CONTENTS_XX specifies the default contents of instance with index XX (see INSTANCES)." << endl; of << "// contents are specified as decimal numbers, one number per line." << endl; of << "// " << endl; of << "// Hannes Sakulin / HEPHY Vienna, 2003" << endl; of << "// "<< endl; of << "NAME = " << m_name << endl; of << "INSTANCES =" ; for (unsigned i=0; i<m_InstNames.size(); i++) of << " " << m_InstNames[i]; of << endl; of << "LUT_INPUTS = " << PortDecoder(m_Inputs).str() << endl; of << "LUT_OUTPUTS = " << PortDecoder(m_Outputs).str() << endl; of << "VME_ADDR_WIDTH = " << m_vme_addr_width << endl; of << "DISTRIBUTED_RAM = " << (m_distrRAM?"1":"0") << endl; for (int i=0; i<m_NLUTS; i++) { of << "// " << m_InstNames[i] << endl; of << "CONTENTS_" << i << " = "; for (unsigned addr = 0; addr < (unsigned) (1<<m_TotalInWidth); addr ++) { of << LookupPacked (i, addr) << endl; } of << endl; } m_saveFlag = false; }
void L1MuGMTLUT::Set | ( | int | idx, |
unsigned | address, | ||
unsigned | value | ||
) | [protected] |
set with single address and value
Definition at line 173 of file L1MuGMTLUT.cc.
References relativeConstraints::value.
{ if (! m_initialized) { edm::LogWarning("LUTNotInitialized") << "L1MuGMTLUT::Set: LUT not initialized. "; return; } if ( idx >= m_NLUTS ) { edm::LogWarning("LUTRangeViolation") << "L1MuGMTLUT::Set: LUT index exceeds range (0 to " << ( m_NLUTS -1 ) << ")."; return; } if ( address >= (unsigned)(1 << m_TotalInWidth) ) { edm::LogWarning("LUTRangeViolation") << "Error in L1MuGMTLUT::Set: LUT input exceeds range (0 to " << ( (1 << m_TotalInWidth) -1 ) << ")."; return; } if ( value >= (unsigned)(1 << m_TotalOutWidth) ) { edm::LogWarning("LUTRangeViolation") << "Error in L1MuGMTLUT::Set: LUT output exceeds range (0 to " << ( (1 << m_TotalOutWidth) -1 ) << ")." ; return; } m_Contents[idx][address] = value; }
std::vector< unsigned > L1MuGMTLUT::u2vec | ( | unsigned | value, |
const std::vector< port > & | widths | ||
) | const [inline, protected] |
generate composite address or value from compact unsigned
Definition at line 241 of file L1MuGMTLUT.h.
References i, and convertSQLitetoXML_cfg::output.
Referenced by Lookup(), L1MuGMTMIAUPhiPro1LUT::LookupFunctionPacked(), L1MuGMTLFSortRankCombineLUT::LookupFunctionPacked(), L1MuGMTLFPhiProLUT::LookupFunctionPacked(), L1MuGMTLFMergeRankEtaPhiLUT::LookupFunctionPacked(), L1MuGMTLFMergeRankPtQLUT::LookupFunctionPacked(), L1MuGMTLFMergeRankCombineLUT::LookupFunctionPacked(), L1MuGMTLFMatchQualLUT::LookupFunctionPacked(), L1MuGMTLFPtMixLUT::LookupFunctionPacked(), L1MuGMTLFSortRankEtaQLUT::LookupFunctionPacked(), L1MuGMTLFSortRankEtaPhiLUT::LookupFunctionPacked(), L1MuGMTLFPhiProEtaConvLUT::LookupFunctionPacked(), L1MuGMTLFCOUDeltaEtaLUT::LookupFunctionPacked(), L1MuGMTLFMergeRankEtaQLUT::LookupFunctionPacked(), L1MuGMTMIAUEtaConvLUT::LookupFunctionPacked(), L1MuGMTLFEtaConvLUT::LookupFunctionPacked(), L1MuGMTLFDeltaEtaLUT::LookupFunctionPacked(), L1MuGMTMIAUEtaProLUT::LookupFunctionPacked(), L1MuGMTLFOvlEtaConvLUT::LookupFunctionPacked(), L1MuGMTLFDisableHotLUT::LookupFunctionPacked(), L1MuGMTLFSortRankPtQLUT::LookupFunctionPacked(), and L1MuGMTMIAUPhiPro2LUT::LookupFunctionPacked().
unsigned L1MuGMTLUT::vec2u | ( | const std::vector< unsigned > & | vec, |
const std::vector< port > & | widths | ||
) | const [inline, protected] |
generate address or value from composite address or value
Definition at line 216 of file L1MuGMTLUT.h.
References i, and relativeConstraints::value.
Referenced by Lookup(), and LookupPacked().
{ if (vec.size() != widths.size()) { edm::LogWarning("LUTMismatch") << "Error in L1MuGMTLUT::vec2u: number of LUT inputs/outputs does not match definition"; return (0); } unsigned value = 0; unsigned start_ofs=0; for (int i=vec.size()-1; i>=0; i--) { if ( vec[i] >= (unsigned) (1 << widths[i].second) ) { edm::LogWarning("LUTMismatch") << "Error in L1MuGMTLUT::vec2u: LUT input/output number " << i << " exceeds range (0 to " << ( (1 << widths[i].second) -1 ) << ")." ; } else value |= vec[i] << start_ofs; start_ofs += widths[i].second; } return (value); }
friend class L1MuGMTLUTConverter [friend] |
Definition at line 142 of file L1MuGMTLUT.h.
std::vector<std::vector <unsigned> > L1MuGMTLUT::m_Contents [protected] |
Definition at line 202 of file L1MuGMTLUT.h.
Referenced by LookupPacked().
bool L1MuGMTLUT::m_distrRAM [protected] |
Definition at line 208 of file L1MuGMTLUT.h.
unsigned L1MuGMTLUT::m_GeneralLUTVersion [protected] |
Definition at line 211 of file L1MuGMTLUT.h.
Referenced by L1MuGMTLFMergeRankEtaQLUT::TheLookupFunction().
bool L1MuGMTLUT::m_initialized [protected] |
Definition at line 198 of file L1MuGMTLUT.h.
Referenced by LookupPacked().
std::vector<port> L1MuGMTLUT::m_Inputs [protected] |
Definition at line 203 of file L1MuGMTLUT.h.
Referenced by Lookup(), L1MuGMTMIAUPhiPro1LUT::LookupFunctionPacked(), L1MuGMTLFSortRankCombineLUT::LookupFunctionPacked(), L1MuGMTLFMergeRankEtaPhiLUT::LookupFunctionPacked(), L1MuGMTLFPhiProLUT::LookupFunctionPacked(), L1MuGMTLFMatchQualLUT::LookupFunctionPacked(), L1MuGMTLFMergeRankCombineLUT::LookupFunctionPacked(), L1MuGMTLFMergeRankPtQLUT::LookupFunctionPacked(), L1MuGMTLFPtMixLUT::LookupFunctionPacked(), L1MuGMTLFCOUDeltaEtaLUT::LookupFunctionPacked(), L1MuGMTLFPhiProEtaConvLUT::LookupFunctionPacked(), L1MuGMTLFSortRankEtaPhiLUT::LookupFunctionPacked(), L1MuGMTLFSortRankEtaQLUT::LookupFunctionPacked(), L1MuGMTLFMergeRankEtaQLUT::LookupFunctionPacked(), L1MuGMTLFDeltaEtaLUT::LookupFunctionPacked(), L1MuGMTLFEtaConvLUT::LookupFunctionPacked(), L1MuGMTMIAUEtaConvLUT::LookupFunctionPacked(), L1MuGMTLFDisableHotLUT::LookupFunctionPacked(), L1MuGMTLFOvlEtaConvLUT::LookupFunctionPacked(), L1MuGMTMIAUEtaProLUT::LookupFunctionPacked(), L1MuGMTLFSortRankPtQLUT::LookupFunctionPacked(), L1MuGMTMIAUPhiPro2LUT::LookupFunctionPacked(), and LookupPacked().
std::vector<std::string> L1MuGMTLUT::m_InstNames [protected] |
Definition at line 201 of file L1MuGMTLUT.h.
std::string L1MuGMTLUT::m_name [protected] |
Definition at line 209 of file L1MuGMTLUT.h.
Referenced by LookupPacked(), and Name().
int L1MuGMTLUT::m_NLUTS [protected] |
Definition at line 199 of file L1MuGMTLUT.h.
Referenced by LookupPacked(), and numberOfInstances().
std::vector<port> L1MuGMTLUT::m_Outputs [protected] |
Definition at line 204 of file L1MuGMTLUT.h.
Referenced by Lookup().
bool L1MuGMTLUT::m_saveFlag [protected] |
Definition at line 210 of file L1MuGMTLUT.h.
Referenced by L1MuGMTLFPhiProEtaConvLUT::TheLookupFunction(), L1MuGMTMIAUEtaConvLUT::TheLookupFunction(), and L1MuGMTMIAUEtaProLUT::TheLookupFunction().
unsigned L1MuGMTLUT::m_TotalInWidth [protected] |
Definition at line 205 of file L1MuGMTLUT.h.
Referenced by LookupPacked().
unsigned L1MuGMTLUT::m_TotalOutWidth [protected] |
Definition at line 206 of file L1MuGMTLUT.h.
Referenced by LookupPacked().
bool L1MuGMTLUT::m_UseLookupFunction [protected] |
Definition at line 200 of file L1MuGMTLUT.h.
Referenced by LookupPacked().
unsigned L1MuGMTLUT::m_vme_addr_width [protected] |
Definition at line 207 of file L1MuGMTLUT.h.