|
|
Go to the documentation of this file.
43 #ifndef L1TriggerGlobalMuonTrigger_L1MuGMTLUT_h
44 #define L1TriggerGlobalMuonTrigger_L1MuGMTLUT_h
60 class L1MuGMTLUTConverter;
75 typedef std::pair<std::string, unsigned>
port;
84 const std::vector<std::string>&
instances,
85 const std::vector<port>& in_widths,
86 const std::vector<port>& out_widths,
87 unsigned vme_addr_width = 0,
88 bool distrRAM =
false)
97 unsigned vme_addr_width = 0,
98 bool distrRAM =
false)
121 inline std::vector<unsigned>
Lookup(
int idx,
const std::vector<unsigned>& address)
const {
126 inline std::vector<unsigned>
Lookup(
int idx,
unsigned address)
const {
144 const char* template_file_h =
"../interface/L1MuGMTLUT_SubClass.h_template",
145 const char* template_file_cc =
"../interface/L1MuGMTLUT_SubClass.cc_template");
157 const std::vector<std::string>&
instances,
158 const std::vector<port>& in_widths,
159 const std::vector<port>& out_widths,
160 unsigned vme_addr_width = 0,
161 bool distrRAM =
false);
164 inline unsigned vec2u(
const std::vector<unsigned>& vec,
const std::vector<port>& widths)
const;
167 inline std::vector<unsigned>
u2vec(
unsigned value,
const std::vector<port>& widths)
const;
170 void Set(
int idx,
unsigned address,
unsigned value);
173 typedef std::vector<port>
base;
181 for (
unsigned int i = 0;
i < tok.size();
i++) {
182 size_type obrace = tok[
i].find(
'('), cbrace = tok[
i].find(
')');
183 if (obrace != std::string::npos && cbrace != std::string::npos)
185 port(tok[
i].substr(0, obrace), (
unsigned)atoi(tok[
i].substr(obrace + 1, cbrace - obrace - 1).c_str())));
187 edm::LogWarning(
"LUTMismatch") <<
"L1MuGMTLUT::PortDecoder: error decoding port " << tok[
i];
192 for (
unsigned int i = 0;
i <
size();
i++) {
227 unsigned L1MuGMTLUT::vec2u(
const std::vector<unsigned>& vec,
const std::vector<port>& widths)
const {
228 if (vec.size() != widths.size()) {
230 <<
"Error in L1MuGMTLUT::vec2u: number of LUT inputs/outputs does not match definition";
235 unsigned start_ofs = 0;
237 for (
int i = vec.size() - 1;
i >= 0;
i--) {
238 if (vec[
i] >= (
unsigned)(1 << widths[
i].second)) {
239 edm::LogWarning(
"LUTMismatch") <<
"Error in L1MuGMTLUT::vec2u: LUT input/output number " <<
i
240 <<
" exceeds range (0 to " << ((1 << widths[
i].second) - 1) <<
").";
242 value |= vec[
i] << start_ofs;
243 start_ofs += widths[
i].second;
252 std::vector<unsigned>
output(widths.size(), 0);
254 unsigned start_ofs = 0;
256 for (
int i = widths.size() - 1;
i >= 0;
i--) {
257 int mask = ((1 << widths[
i].second) - 1) << start_ofs;
259 start_ofs += widths[
i].second;
274 edm::LogWarning(
"LUTMismatch") <<
"Error in L1MuGMTLUT::LookupPacked: LUT not initialized. ";
278 edm::LogWarning(
"LUTMismatch") <<
"Error in L1MuGMTLUT::LookupPacked: LUT index exceeds range (0 to "
283 edm::LogWarning(
"LUTMismatch") <<
"Error in L1MuGMTLUT::LookupPacked: LUT input exceeds range (0 to "
297 edm::LogWarning(
"LUTMismatch") <<
"Error in L1MuGMTLUT::LookupPacked(): LUT output value " <<
value
301 edm::LogWarning(
"LUTMismatch") <<
" Lookup Function has to be corrected!!!";
PortDecoder(const std::string &input)
int numberOfInstances()
get the number of Instances
static const std::string input
std::vector< std::string > m_InstNames
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
std::vector< port > m_Inputs
unsigned m_GeneralLUTVersion
U second(std::pair< T, U > const &p)
void Load(const char *path)
I/O functions.
Log< level::Warning, false > LogWarning
PortDecoder(const std::vector< port > &pt)
virtual unsigned LookupFunctionPacked(int idx, unsigned address) const
unsigned m_vme_addr_width
unsigned LookupPacked(int idx, const std::vector< unsigned > &address) const
additional lookup function (std::vector -> unisgned)
virtual ~L1MuGMTLUT()
destructor
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 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.
unsigned LookupPacked(int idx, unsigned) const
void Set(int idx, unsigned address, unsigned value)
set with single address and value
L1MuGMTLUT(const char *name, const std::string &instances, const std::string &inputs, const std::string &outputs, unsigned vme_addr_width=0, bool distrRAM=false)
std::vector< std::vector< unsigned > > m_Contents
unsigned vec2u(const std::vector< unsigned > &vec, const std::vector< port > &widths) const
generate address or value from composite address or value
std::pair< std::string, unsigned > port
std::vector< port > m_Outputs
std::vector< unsigned > u2vec(unsigned value, const std::vector< port > &widths) const
generate composite address or value from compact unsigned
std::vector< unsigned > Lookup(int idx, unsigned address) const
additional lookup function (unsigned -> std::vector)
L1MuGMTLUT()
Init and Destruct.
std::vector< unsigned > Lookup(int idx, const std::vector< unsigned > &address) const
additional lookup function (std::vector -> vector)
void Save(const char *path)
save to LUT file
friend class L1MuGMTLUTConverter