CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes
trklet::VarBase Class Reference

#include <imath.h>

Inheritance diagram for trklet::VarBase:
trklet::VarAdd trklet::VarAdjustK trklet::VarAdjustKR trklet::VarCut trklet::VarDef trklet::VarDSPPostadd trklet::VarFlag trklet::VarInv trklet::VarMult trklet::VarNeg trklet::VarNounits trklet::VarParam trklet::VarShift trklet::VarShiftround trklet::VarSubtract trklet::VarTimesC

Classes

struct  HLS
 
struct  Verilog
 

Public Member Functions

void add_cut (VarCut *cut, const bool call_set_cut_var=true)
 
void add_delay (int i)
 
void add_latency (unsigned int l)
 
void analyze ()
 
void calcDebug (int debug_level, long int ival_prev, bool &all_ok)
 
bool calculate (int debug_level=0)
 
VarBasecut_var ()
 
std::string dump ()
 
void dump_msg ()
 
double fval () const
 
bool has_delay (int i)
 
void inputs (std::vector< VarBase *> *vd)
 
long int ival () const
 
double K () const
 
std::map< std::string, int > Kmap () const
 
std::string kstring () const
 
int latency () const
 
virtual void local_calculate ()
 
bool local_passes () const
 
void makeready ()
 
double maxval () const
 
double minval () const
 
std::string name () const
 
int nbits () const
 
std::string op () const
 
VarBasep1 () const
 
VarBasep2 () const
 
VarBasep3 () const
 
void passes (std::map< const VarBase *, std::vector< bool > > &passes, const std::map< const VarBase *, std::vector< bool > > *const previous_passes=nullptr) const
 
int pipe_counter ()
 
std::string pipe_delays (const int step)
 
void pipe_increment ()
 
virtual void print (std::ofstream &fs, Verilog, int l1=0, int l2=0, int l3=0)
 
virtual void print (std::ofstream &fs, HLS, int l1=0, int l2=0, int l3=0)
 
void print_all (std::ofstream &fs, Verilog)
 
void print_all (std::ofstream &fs, HLS)
 
void print_cuts (std::map< const VarBase *, std::set< std::string > > &cut_strings, const int step, Verilog, const std::map< const VarBase *, std::set< std::string > > *const previous_cut_strings=nullptr) const
 
void print_cuts (std::map< const VarBase *, std::set< std::string > > &cut_strings, const int step, HLS, const std::map< const VarBase *, std::set< std::string > > *const previous_cut_strings=nullptr) const
 
void print_step (int step, std::ofstream &fs, Verilog)
 
void print_step (int step, std::ofstream &fs, HLS)
 
void print_truncation (std::string &t, const std::string &o1, const int ps, Verilog) const
 
void print_truncation (std::string &t, const std::string &o1, const int ps, HLS) const
 
double range () const
 
void reset ()
 
int shift () const
 
int step () const
 
 VarBase (imathGlobals *globals, std::string name, VarBase *p1, VarBase *p2, VarBase *p3, int l)
 
virtual ~VarBase ()
 

Static Public Member Functions

static void design_print (const std::vector< VarBase *> &v, std::ofstream &fs, Verilog)
 
static void design_print (const std::vector< VarBase *> &v, std::ofstream &fs, HLS)
 
static void hls_print (const std::vector< VarBase *> &v, std::ofstream &fs)
 
static std::string itos (int i)
 
static std::string pipe_delay (VarBase *v, int nbits, int delay)
 
static std::string pipe_delay_wire (VarBase *v, std::string name_delayed, int nbits, int delay)
 
static void verilog_print (const std::vector< VarBase *> &v, std::ofstream &fs)
 

Static Public Attributes

static struct trklet::VarBase::HLS hls
 
static struct trklet::VarBase::Verilog verilog
 

Protected Attributes

VarBasecut_var_
 
std::vector< VarBase * > cuts_
 
double fval_
 
imathGlobalsglobals_
 
long int ival_
 
double K_
 
std::map< std::string, int > Kmap_
 
int latency_
 
double maxval_
 
double minval_
 
std::string name_
 
int nbits_
 
std::string op_
 
VarBasep1_
 
VarBasep2_
 
VarBasep3_
 
int pipe_counter_
 
std::vector< int > pipe_delays_
 
bool readytoanalyze_
 
bool readytoprint_
 
int step_
 
bool usedasinput_
 
double val_
 

Detailed Description

Definition at line 160 of file imath.h.

Constructor & Destructor Documentation

◆ VarBase()

trklet::VarBase::VarBase ( imathGlobals globals,
std::string  name,
VarBase p1,
VarBase p2,
VarBase p3,
int  l 
)
inline

Definition at line 162 of file imath.h.

References cut_var_, cuts_, globals_, Kmap_, MainPageGenerator::l, latency(), latency_, SiStripPI::max, maxval_, minval_, name(), name_, p1(), p1_, p2(), p2_, p3(), p3_, pipe_counter_, pipe_delays_, readytoanalyze_, readytoprint_, step(), step_, and usedasinput_.

162  {
163  globals_ = globals;
164  p1_ = p1;
165  p2_ = p2;
166  p3_ = p3;
167  name_ = name;
168  latency_ = l;
169  int step1 = (p1) ? p1->step() + p1->latency() : 0;
170  int step2 = (p2) ? p2->step() + p2->latency() : 0;
171  step_ = std::max(step1, step2);
172 
173  cuts_.clear();
174  cut_var_ = nullptr;
175 
176  pipe_counter_ = 0;
177  pipe_delays_.clear();
178 
181  readytoprint_ = true;
182  readytoanalyze_ = true;
183  usedasinput_ = false;
184  Kmap_.clear();
185  Kmap_["2"] = 0; // initially, zero shift
186 #ifdef IMATH_ROOT
187  h_ = 0;
188  h_nbins_ = 1024;
189  h_precision_ = 0.02;
190 #endif
191  }
std::string name() const
Definition: imath.h:208
int latency_
Definition: imath.h:302
VarBase * p1_
Definition: imath.h:298
VarBase * cut_var_
Definition: imath.h:310
imathGlobals * globals_
Definition: imath.h:296
VarBase * p2_
Definition: imath.h:299
std::vector< int > pipe_delays_
Definition: imath.h:317
VarBase * p3_
Definition: imath.h:300
VarBase * p1() const
Definition: imath.h:210
int step() const
Definition: imath.h:251
int latency() const
Definition: imath.h:252
VarBase * p3() const
Definition: imath.h:212
double minval_
Definition: imath.h:323
bool readytoprint_
Definition: imath.h:320
int pipe_counter_
Definition: imath.h:316
std::vector< VarBase * > cuts_
Definition: imath.h:309
std::string name_
Definition: imath.h:297
std::map< std::string, int > Kmap_
Definition: imath.h:314
VarBase * p2() const
Definition: imath.h:211
double maxval_
Definition: imath.h:324
bool readytoanalyze_
Definition: imath.h:319
bool usedasinput_
Definition: imath.h:321

◆ ~VarBase()

virtual trklet::VarBase::~VarBase ( )
inlinevirtual

Definition at line 192 of file imath.h.

References globals_.

192  {
193 #ifdef IMATH_ROOT
194  if (globals_->h_file_) {
195  globals_->h_file_->ls();
196  globals_->h_file_->Close();
197  globals_->h_file_ = 0;
198  }
199 #endif
200  }
imathGlobals * globals_
Definition: imath.h:296

Member Function Documentation

◆ add_cut()

void VarBase::add_cut ( VarCut cut,
const bool  call_set_cut_var = true 
)

Definition at line 359 of file imath.cc.

References DMR_cfg::cut, and cuts_.

Referenced by trklet::IMATH_TrackletCalculator::IMATH_TrackletCalculator(), and trklet::VarCut::set_cut_var().

359  {
360  cuts_.push_back(cut);
361  if (call_set_cut_var)
362  cut->set_cut_var(this, false);
363 }
std::vector< VarBase * > cuts_
Definition: imath.h:309

◆ add_delay()

void trklet::VarBase::add_delay ( int  i)
inline

Definition at line 273 of file imath.h.

References mps_fire::i, and pipe_delays_.

273 { pipe_delays_.push_back(i); }
std::vector< int > pipe_delays_
Definition: imath.h:317

◆ add_latency()

void trklet::VarBase::add_latency ( unsigned int  l)
inline

Definition at line 253 of file imath.h.

References MainPageGenerator::l, and latency_.

253 { latency_ += l; } //only call before using the variable in calculation!
int latency_
Definition: imath.h:302

◆ analyze()

void VarBase::analyze ( )

Definition at line 29 of file imath.cc.

References analyze(), HltBtagPostValidation_cff::c, globals_, maxval_, minval_, name_, p1_, p2_, range(), and readytoanalyze_.

Referenced by analyze().

29  {
30  if (!readytoanalyze_)
31  return;
32 
33  double u = maxval_;
34  if (u < -minval_)
35  u = -minval_;
36 
37  int iu = log2(range() / u);
38  if (iu > 1) {
39  char slog[1024];
40  sprintf(slog,
41  "analyzing %s: range %g is much larger then %g. suggest cutting by a factor of 2^%i",
42  name_.c_str(),
43  range(),
44  u,
45  iu);
46  edm::LogVerbatim("Tracklet") << slog;
47  }
48 #ifdef IMATH_ROOT
49  char slog[100];
50  if (h_) {
51  double eff = h_->Integral() / h_->GetEntries();
52  if (eff < 0.99) {
53  sprintf(slog, "analyzing %s: range is too small, contains %f", name_.c_str(), eff);
54  edm::LogVerbatim("Tracklet") << slog;
55  h_->Print();
56  }
57  globals_->h_file_->cd();
58  TCanvas *c = new TCanvas();
59  c->cd();
60  h_->Draw("colz");
61  h_->Write();
62  } else {
63  if (globals_->use_root) {
64  sprintf(slog, "analyzing %s: no histogram!\n", name_.c_str());
65  edm::LogVerbatim("Tracklet") << slog;
66  }
67  }
68 #endif
69 
70  if (p1_)
71  p1_->analyze();
72  if (p2_)
73  p2_->analyze();
74 
75  readytoanalyze_ = false;
76 }
Log< level::Info, true > LogVerbatim
void analyze()
Definition: imath.cc:29
double range() const
Definition: imath.h:246
VarBase * p1_
Definition: imath.h:298
imathGlobals * globals_
Definition: imath.h:296
VarBase * p2_
Definition: imath.h:299
double minval_
Definition: imath.h:323
std::string name_
Definition: imath.h:297
double maxval_
Definition: imath.h:324
bool readytoanalyze_
Definition: imath.h:319

◆ calcDebug()

void VarBase::calcDebug ( int  debug_level,
long int  ival_prev,
bool &  all_ok 
)

Definition at line 50 of file imath_calculate.cc.

References funct::abs(), l1t::bitShift(), HLT_2023v12_cff::debug_level, dump(), fval_, createfilelist::int, ival_, K_, maxval_, minval_, nbits_, op_, p1_, tolerance, and val_.

Referenced by calculate().

50  {
51  if (fval_ > maxval_)
52  maxval_ = fval_;
53  if (fval_ < minval_)
54  minval_ = fval_;
55 
56  bool todump = false;
57  int nmax = sizeof(long int) * 8;
58  int ns = nmax - nbits_;
59  long int itest = ival_;
60  itest = l1t::bitShift(itest, ns);
61  itest = itest >> ns;
62  if (itest != ival_) {
63  if (debug_level == 3 || (ival_ != ival_prev && all_ok)) {
64  edm::LogVerbatim("Tracklet") << "imath: truncated value mismatch!! " << ival_ << " != " << itest;
65  todump = true;
66  }
67  all_ok = false;
68  }
69 
70  float ftest = val_;
71  float tolerance = 0.1 * std::abs(fval_);
72  if (tolerance < 2 * K_)
73  tolerance = 2 * K_;
74  if (std::abs(ftest - fval_) > tolerance) {
75  if (debug_level == 3 || (ival_ != ival_prev && (all_ok && (op_ != "inv" || debug_level >= 2)))) {
76  edm::LogVerbatim("Tracklet") << "imath: **GROSS** value mismatch!! " << fval_ << " != " << ftest;
77  if (op_ == "inv")
78  edm::LogVerbatim("Tracklet") << p1_->dump() << "\n-----------------------------------";
79  todump = true;
80  }
81  all_ok = false;
82  }
83  if (todump)
84  edm::LogVerbatim("Tracklet") << dump();
85 }
Log< level::Info, true > LogVerbatim
double val_
Definition: imath.h:307
const double tolerance
VarBase * p1_
Definition: imath.h:298
std::string op_
Definition: imath.h:301
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
long int ival_
Definition: imath.h:306
double minval_
Definition: imath.h:323
double maxval_
Definition: imath.h:324
double K_
Definition: imath.h:313
std::string dump()
Definition: imath.cc:78
double fval_
Definition: imath.h:305
int bitShift(int num, int bits)
Definition: BitShift.h:6

◆ calculate()

bool VarBase::calculate ( int  debug_level = 0)

Definition at line 6 of file imath_calculate.cc.

References calcDebug(), calculate(), HLT_2023v12_cff::debug_level, fval_, globals_, ival_, K_, local_calculate(), name_, op_, p1_, p2_, p3_, range(), AlCaHLTBitMon_QueryRunRegistry::string, and val_.

Referenced by trklet::TrackletCalculatorBase::barrelSeeding(), calculate(), trklet::TrackletCalculatorBase::diskSeeding(), and trklet::TrackletCalculatorBase::overlapSeeding().

6  {
7  bool ok1 = true;
8  bool ok2 = true;
9  bool ok3 = true;
10 
11  if (p1_)
12  ok1 = p1_->calculate(debug_level);
13  if (p2_)
14  ok2 = p2_->calculate(debug_level);
15  if (p3_)
16  ok3 = p3_->calculate(debug_level);
17 
18  bool all_ok = debug_level && ok1 && ok2 && ok3;
19  long int ival_prev = ival_;
20 
22 
23  val_ = ival_ * K_;
24 
25 #ifdef IMATH_ROOT
26  if (globals_->use_root) {
27  if (h_ == 0) {
28  globals_->h_file_->cd();
29  std::string hname = "h_" + name_;
30  h_ = (TH2F *)globals_->h_file_->Get(hname.c_str());
31  if (h_ == 0) {
32  h_precision_ = 0.5 * h_nbins_ * K_;
33  std::string st = name_ + ";fval;fval-ival*K";
34  h_ = new TH2F(hname.c_str(), name_.c_str(), h_nbins_, -range(), range(), h_nbins_, -h_precision_, h_precision_);
35  if (debug_level == 3)
36  edm::LogVerbatim("Tracklet") << " booking histogram " << hname;
37  }
38  }
39  if (ival_ != ival_prev || op_ == "def" || op_ == "const")
40  h_->Fill(fval_, K_ * ival_ - fval_);
41  }
42 #endif
43 
44  if (debug_level)
45  calcDebug(debug_level, ival_prev, all_ok);
46 
47  return all_ok;
48 }
Log< level::Info, true > LogVerbatim
void calcDebug(int debug_level, long int ival_prev, bool &all_ok)
double val_
Definition: imath.h:307
double range() const
Definition: imath.h:246
VarBase * p1_
Definition: imath.h:298
imathGlobals * globals_
Definition: imath.h:296
VarBase * p2_
Definition: imath.h:299
VarBase * p3_
Definition: imath.h:300
std::string op_
Definition: imath.h:301
virtual void local_calculate()
Definition: imath.h:255
long int ival_
Definition: imath.h:306
std::string name_
Definition: imath.h:297
double K_
Definition: imath.h:313
double fval_
Definition: imath.h:305
bool calculate(int debug_level=0)

◆ cut_var()

VarBase * VarBase::cut_var ( )

Definition at line 388 of file imath.cc.

References cut_var_, and op_.

Referenced by trklet::VarFlag::passes(), trklet::VarFlag::print(), trklet::VarCut::set_cut_var(), and trklet::VarCut::VarCut().

388  {
389  if (op_ == "cut")
390  return cut_var_;
391  else
392  return this;
393 }
VarBase * cut_var_
Definition: imath.h:310
std::string op_
Definition: imath.h:301

◆ design_print() [1/2]

void VarBase::design_print ( const std::vector< VarBase *> &  v,
std::ofstream &  fs,
Verilog   
)
static

Definition at line 466 of file imath_Verilog.cc.

References phase2TrackerDigitizer_cfi::delay, compareTotals::fs, mps_fire::i, inputs(), dqmiodumpmetadata::n, name(), nbits(), pipe_delay_wire(), print_all(), step(), AlCaHLTBitMon_QueryRunRegistry::string, findQualityFiles::v, and verilog.

Referenced by hls_print(), and verilog_print().

466  {
467  //step at which all the outputs should be valid
468  int maxstep = 0;
469 
470  //header of the module
471 
472  //inputs
473  std::vector<VarBase*> vd;
474  vd.clear();
475  int imax = v.size();
476  for (int i = 0; i < imax; ++i) {
477  (v[i])->inputs(&vd);
478  int step = v[i]->step() + v[i]->latency();
479  if (step > maxstep)
480  maxstep = step;
481  }
482 
483  //print header
484  fs << "module \n";
485  fs << "(\n";
486  fs << " input clk,\n";
487  fs << " input reset,\n\n";
488 
489  imax = vd.size();
490  for (int i = 0; i < imax; ++i)
491  fs << " input [" << (vd[i])->nbits() - 1 << ":0] " << (vd[i])->name() << "_wire,\n";
492  fs << "\n";
493 
494  imax = v.size() - 1;
495  for (int i = 0; i < imax; ++i)
496  if (v[i]->nbits() > 1)
497  fs << " output [" << (v[i])->nbits() - 1 << ":0] " << (v[i])->name() << "_wire,\n";
498  else
499  fs << " output " << (v[i])->name() << "_wire,\n";
500  if (imax >= 0) {
501  if (v[imax]->nbits() > 1)
502  fs << " output [" << (v[imax])->nbits() - 1 << ":0] " << (v[imax])->name() << "_wire\n";
503  else
504  fs << " output " << (v[imax])->name() << "_wire\n";
505  }
506  fs << ");\n\n";
507 
508  //body of the module
509  imax = v.size();
510  for (int i = 0; i < imax; ++i) {
511  fs << "\n//\n";
512  fs << "// calculating " << (v[i])->name() << "\n";
513  fs << "//\n";
514  (v[i])->print_all(fs, verilog);
515  }
516  fs << "\n";
517 
518  //trailer
519  fs << "\n";
520  fs << "\n//\n";
521  fs << "// wiring the outputs \n";
522  fs << "// latency = " << maxstep << "\n";
523  fs << "//\n";
524  for (int i = 0; i < imax; ++i) {
525  std::string n = v[i]->name() + "_wire";
526  int delay = maxstep - v[i]->step() - v[i]->latency();
527  if (delay == 0)
528  fs << "assign " << n << " = " << (v[i])->name() << ";\n";
529  else
530  fs << pipe_delay_wire(v[i], n, v[i]->nbits(), delay);
531  }
532 
533  fs << "endmodule\n";
534 }
std::string name() const
Definition: imath.h:208
void inputs(std::vector< VarBase *> *vd)
Definition: imath.cc:205
void print_all(std::ofstream &fs, Verilog)
int nbits() const
Definition: imath.h:244
static struct trklet::VarBase::Verilog verilog
int step() const
Definition: imath.h:251
std::vector< DeviationSensor2D * > vd
static std::string pipe_delay_wire(VarBase *v, std::string name_delayed, int nbits, int delay)
Definition: imath.cc:196
step
Definition: StallMonitor.cc:98

◆ design_print() [2/2]

void VarBase::design_print ( const std::vector< VarBase *> &  v,
std::ofstream &  fs,
HLS   
)
static

Definition at line 355 of file imath_HLS.cc.

References compareTotals::fs, hls, mps_fire::i, dqmiodumpmetadata::n, name(), nbits(), print_all(), AlCaHLTBitMon_QueryRunRegistry::string, and findQualityFiles::v.

355  {
356  //header of the module
357 
358  //inputs
359  std::vector<VarBase*> vd;
360  vd.clear();
361  int imax = v.size();
362  for (int i = 0; i < imax; ++i)
363  (v[i])->inputs(&vd);
364 
365  //print header
366  fs << "#include \"ap_int.h\"\n\n";
367  fs << "void XXX (\n";
368 
369  imax = vd.size();
370  for (int i = 0; i < imax; ++i)
371  fs << " const ap_int<" << (vd[i])->nbits() << "> " << (vd[i])->name() << "_wire,\n";
372  fs << "\n";
373 
374  imax = v.size() - 1;
375  for (int i = 0; i < imax; ++i)
376  fs << " ap_int<" << (v[i])->nbits() << "> * const " << (v[i])->name() << "_wire,\n";
377  if (imax >= 0)
378  fs << " ap_int<" << (v[imax])->nbits() << "> * const " << (v[imax])->name() << "_wire\n";
379  fs << ")\n{\n";
380  fs << "#pragma HLS pipeline II=1\n";
381  fs << "#pragma HLS latency max=25\n";
382 
383  //body of the module
384  imax = v.size();
385  for (int i = 0; i < imax; ++i) {
386  fs << "\n//\n";
387  fs << "// calculating " << (v[i])->name() << "\n";
388  fs << "//\n";
389  (v[i])->print_all(fs, hls);
390  }
391  fs << "\n";
392 
393  //trailer
394  fs << "\n";
395  fs << "\n//\n";
396  fs << "// wiring the outputs \n";
397  fs << "//\n";
398  for (int i = 0; i < imax; ++i) {
399  std::string n = v[i]->name() + "_wire";
400  fs << "*" << n << " = " << (v[i])->name() << ";\n";
401  }
402 
403  fs << "}\n";
404 }
std::string name() const
Definition: imath.h:208
void print_all(std::ofstream &fs, Verilog)
int nbits() const
Definition: imath.h:244
std::vector< DeviationSensor2D * > vd
static struct trklet::VarBase::HLS hls

◆ dump()

std::string VarBase::dump ( void  )

Definition at line 78 of file imath.cc.

References fval_, ival_, K_, kstring(), name_, nbits_, op_, range(), alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, and submitPVValidationJobs::t.

Referenced by calcDebug().

78  {
79  char s[1024];
80  std::string u = kstring();
81  sprintf(
82  s,
83  "Name = %s \t Op = %s \t nbits = %i \n ival = %li \t fval = %g \t K = %g Range = %f\n units = %s\n",
84  name_.c_str(),
85  op_.c_str(),
86  nbits_,
87  ival_,
88  fval_,
89  K_,
90  range(),
91  u.c_str());
92  std::string t(s);
93  return t;
94 }
double range() const
Definition: imath.h:246
std::string kstring() const
Definition: imath.cc:18
std::string op_
Definition: imath.h:301
long int ival_
Definition: imath.h:306
std::string name_
Definition: imath.h:297
double K_
Definition: imath.h:313
double fval_
Definition: imath.h:305

◆ dump_msg()

void VarBase::dump_msg ( )

Definition at line 96 of file imath.cc.

References dump_msg(), fval_, ival_, K_, kstring(), latency_, name_, nbits_, op_, p1_, p2_, range(), alignCSCRings::s, step_, AlCaHLTBitMon_QueryRunRegistry::string, and submitPVValidationJobs::t.

Referenced by dump_msg(), print_step(), trklet::VarAdd::VarAdd(), trklet::VarDSPPostadd::VarDSPPostadd(), and trklet::VarSubtract::VarSubtract().

96  {
97  char s[2048];
98  std::string u = kstring();
99  sprintf(s,
100  "Name = %s \t Op = %s \t nbits = %i \n ival = %li \t fval = %g \t K = %g Range = %f\n units = "
101  "%s\n step = %i, latency = %i\n",
102  name_.c_str(),
103  op_.c_str(),
104  nbits_,
105  ival_,
106  fval_,
107  K_,
108  range(),
109  u.c_str(),
110  step_,
111  latency_);
112  std::string t(s);
113  edm::LogVerbatim("Tracklet") << t;
114  if (p1_)
115  p1_->dump_msg();
116  if (p2_)
117  p2_->dump_msg();
118 }
Log< level::Info, true > LogVerbatim
int latency_
Definition: imath.h:302
double range() const
Definition: imath.h:246
VarBase * p1_
Definition: imath.h:298
VarBase * p2_
Definition: imath.h:299
std::string kstring() const
Definition: imath.cc:18
std::string op_
Definition: imath.h:301
void dump_msg()
Definition: imath.cc:96
long int ival_
Definition: imath.h:306
std::string name_
Definition: imath.h:297
double K_
Definition: imath.h:313
double fval_
Definition: imath.h:305

◆ fval()

double trklet::VarBase::fval ( ) const
inline

◆ has_delay()

bool VarBase::has_delay ( int  i)

Definition at line 165 of file imath.cc.

References mps_fire::i, pipe_delay(), and pipe_delays_.

165  {
166  //dumb sequential search
167  for (int pipe_delay : pipe_delays_)
168  if (pipe_delay == i)
169  return true;
170  return false;
171 }
std::vector< int > pipe_delays_
Definition: imath.h:317
static std::string pipe_delay(VarBase *v, int nbits, int delay)
Definition: imath.cc:173

◆ hls_print()

static void trklet::VarBase::hls_print ( const std::vector< VarBase *> &  v,
std::ofstream &  fs 
)
inlinestatic

Definition at line 276 of file imath.h.

References design_print(), compareTotals::fs, hls, and findQualityFiles::v.

Referenced by trklet::TrackletCalculator::TrackletCalculator().

276 { design_print(v, fs, hls); }
static struct trklet::VarBase::HLS hls
static void design_print(const std::vector< VarBase *> &v, std::ofstream &fs, Verilog)

◆ inputs()

void VarBase::inputs ( std::vector< VarBase *> *  vd)

Definition at line 205 of file imath.cc.

References inputs(), op_, p1_, p2_, p3_, and usedasinput_.

Referenced by design_print(), and inputs().

205  {
206  if (op_ == "def" && !usedasinput_) {
207  usedasinput_ = true;
208  vd->push_back(this);
209  } else {
210  if (p1_)
211  p1_->inputs(vd);
212  if (p2_)
213  p2_->inputs(vd);
214  if (p3_)
215  p3_->inputs(vd);
216  }
217 }
void inputs(std::vector< VarBase *> *vd)
Definition: imath.cc:205
VarBase * p1_
Definition: imath.h:298
VarBase * p2_
Definition: imath.h:299
VarBase * p3_
Definition: imath.h:300
std::string op_
Definition: imath.h:301
std::vector< DeviationSensor2D * > vd
bool usedasinput_
Definition: imath.h:321

◆ itos()

std::string VarBase::itos ( int  i)
static

◆ ival()

long int trklet::VarBase::ival ( ) const
inline

◆ K()

double trklet::VarBase::K ( ) const
inline

◆ Kmap()

std::map<std::string, int> trklet::VarBase::Kmap ( ) const
inline

◆ kstring()

std::string VarBase::kstring ( ) const

◆ latency()

int trklet::VarBase::latency ( ) const
inline

Definition at line 252 of file imath.h.

References latency_.

Referenced by trklet::VarCut::print(), print_step(), and VarBase().

252 { return latency_; }
int latency_
Definition: imath.h:302

◆ local_calculate()

virtual void trklet::VarBase::local_calculate ( )
inlinevirtual

◆ local_passes()

bool VarBase::local_passes ( ) const

Definition at line 315 of file imath.cc.

References DMR_cfg::cut, cuts_, globals_, ival_, K_, trklet::VarCut::lower_cut(), name_, passes(), trklet::imathGlobals::printCutInfo_, and trklet::VarCut::upper_cut().

Referenced by trklet::TrackletCalculatorBase::barrelSeeding(), trklet::TrackletCalculatorBase::diskSeeding(), trklet::TrackletCalculatorBase::overlapSeeding(), and trklet::VarFlag::passes().

315  {
316  bool passes = false;
317  for (const auto &cut : cuts_) {
318  const VarCut *const cast_cut = (VarCut *)cut;
319  const int lower_cut = cast_cut->lower_cut() / K_;
320  const int upper_cut = cast_cut->upper_cut() / K_;
321  passes = passes || (ival_ > lower_cut && ival_ < upper_cut);
322  if (globals_->printCutInfo_) {
323  edm::LogVerbatim("Tracklet") << " " << name_ << " "
324  << ((ival_ > lower_cut && ival_ < upper_cut) ? "PASSES" : "FAILS")
325  << " (required: " << lower_cut * K_ << " < " << ival_ * K_ << " < " << upper_cut * K_
326  << ")";
327  }
328  }
329  return passes;
330 }
Log< level::Info, true > LogVerbatim
imathGlobals * globals_
Definition: imath.h:296
void passes(std::map< const VarBase *, std::vector< bool > > &passes, const std::map< const VarBase *, std::vector< bool > > *const previous_passes=nullptr) const
Definition: imath.cc:332
long int ival_
Definition: imath.h:306
double upper_cut() const
Definition: imath.h:1072
std::vector< VarBase * > cuts_
Definition: imath.h:309
std::string name_
Definition: imath.h:297
double lower_cut() const
Definition: imath.h:1071
double K_
Definition: imath.h:313

◆ makeready()

void VarBase::makeready ( )

Definition at line 151 of file imath.cc.

References makeready(), p1_, p2_, p3_, pipe_counter_, pipe_delays_, readytoanalyze_, readytoprint_, and usedasinput_.

Referenced by makeready().

151  {
152  pipe_counter_ = 0;
153  pipe_delays_.clear();
154  readytoprint_ = true;
155  readytoanalyze_ = true;
156  usedasinput_ = false;
157  if (p1_)
158  p1_->makeready();
159  if (p2_)
160  p2_->makeready();
161  if (p3_)
162  p3_->makeready();
163 }
VarBase * p1_
Definition: imath.h:298
VarBase * p2_
Definition: imath.h:299
std::vector< int > pipe_delays_
Definition: imath.h:317
VarBase * p3_
Definition: imath.h:300
bool readytoprint_
Definition: imath.h:320
int pipe_counter_
Definition: imath.h:316
void makeready()
Definition: imath.cc:151
bool readytoanalyze_
Definition: imath.h:319
bool usedasinput_
Definition: imath.h:321

◆ maxval()

double trklet::VarBase::maxval ( ) const
inline

Definition at line 231 of file imath.h.

References maxval_.

231 { return maxval_; }
double maxval_
Definition: imath.h:324

◆ minval()

double trklet::VarBase::minval ( ) const
inline

Definition at line 230 of file imath.h.

References minval_.

230 { return minval_; }
double minval_
Definition: imath.h:323

◆ name()

std::string trklet::VarBase::name ( void  ) const
inline

◆ nbits()

int trklet::VarBase::nbits ( ) const
inline

◆ op()

std::string trklet::VarBase::op ( ) const
inline

Definition at line 209 of file imath.h.

References op_.

Referenced by print_step().

209 { return op_; }
std::string op_
Definition: imath.h:301

◆ p1()

VarBase* trklet::VarBase::p1 ( ) const
inline

◆ p2()

VarBase* trklet::VarBase::p2 ( ) const
inline

◆ p3()

VarBase* trklet::VarBase::p3 ( ) const
inline

Definition at line 212 of file imath.h.

References p3_.

Referenced by VarBase(), and trklet::VarDSPPostadd::VarDSPPostadd().

212 { return p3_; }
VarBase * p3_
Definition: imath.h:300

◆ passes()

void VarBase::passes ( std::map< const VarBase *, std::vector< bool > > &  passes,
const std::map< const VarBase *, std::vector< bool > > *const  previous_passes = nullptr 
) const

Definition at line 332 of file imath.cc.

References DMR_cfg::cut, cuts_, globals_, ival_, K_, trklet::VarCut::lower_cut(), name_, p1_, p2_, p3_, passes(), trklet::imathGlobals::printCutInfo_, and trklet::VarCut::upper_cut().

Referenced by local_passes(), trklet::VarCut::local_passes(), and passes().

333  {
334  if (p1_)
335  p1_->passes(passes, previous_passes);
336  if (p2_)
337  p2_->passes(passes, previous_passes);
338  if (p3_)
339  p3_->passes(passes, previous_passes);
340 
341  for (const auto &cut : cuts_) {
342  const VarCut *const cast_cut = (VarCut *)cut;
343  const int lower_cut = cast_cut->lower_cut() / K_;
344  const int upper_cut = cast_cut->upper_cut() / K_;
345  if (!previous_passes || (previous_passes && !previous_passes->count(this))) {
346  if (!passes.count(this))
347  passes[this];
348  passes.at(this).push_back(ival_ > lower_cut && ival_ < upper_cut);
349  if (globals_->printCutInfo_) {
350  edm::LogVerbatim("Tracklet") << " " << name_ << " "
351  << ((ival_ > lower_cut && ival_ < upper_cut) ? "PASSES" : "FAILS")
352  << " (required: " << lower_cut * K_ << " < " << ival_ * K_ << " < "
353  << upper_cut * K_ << ")";
354  }
355  }
356  }
357 }
Log< level::Info, true > LogVerbatim
VarBase * p1_
Definition: imath.h:298
imathGlobals * globals_
Definition: imath.h:296
VarBase * p2_
Definition: imath.h:299
void passes(std::map< const VarBase *, std::vector< bool > > &passes, const std::map< const VarBase *, std::vector< bool > > *const previous_passes=nullptr) const
Definition: imath.cc:332
VarBase * p3_
Definition: imath.h:300
long int ival_
Definition: imath.h:306
double upper_cut() const
Definition: imath.h:1072
std::vector< VarBase * > cuts_
Definition: imath.h:309
std::string name_
Definition: imath.h:297
double lower_cut() const
Definition: imath.h:1071
double K_
Definition: imath.h:313

◆ pipe_counter()

int trklet::VarBase::pipe_counter ( )
inline

Definition at line 271 of file imath.h.

References pipe_counter_.

271 { return pipe_counter_; }
int pipe_counter_
Definition: imath.h:316

◆ pipe_delay()

std::string VarBase::pipe_delay ( VarBase v,
int  nbits,
int  delay 
)
static

Definition at line 173 of file imath.cc.

References phase2TrackerDigitizer_cfi::delay, itos(), name(), nbits(), MillePedeFileConverter_cfg::out, pipe_delay_wire(), AlCaHLTBitMon_QueryRunRegistry::string, and findQualityFiles::v.

Referenced by has_delay(), pipe_delays(), and print_step().

173  {
174  //have we been delayed by this much already?
175  if (v->has_delay(delay))
176  return "";
177  v->add_delay(delay);
178  std::string name = v->name();
179  std::string name_delayed = name + "_delay" + itos(delay);
180  std::string out = "wire signed [" + itos(nbits - 1) + ":0] " + name_delayed + ";\n";
181  out = out + pipe_delay_wire(v, name_delayed, nbits, delay);
182  return out;
183 }
std::string name() const
Definition: imath.h:208
int nbits() const
Definition: imath.h:244
static std::string itos(int i)
Definition: imath.cc:16
static std::string pipe_delay_wire(VarBase *v, std::string name_delayed, int nbits, int delay)
Definition: imath.cc:196

◆ pipe_delay_wire()

std::string VarBase::pipe_delay_wire ( VarBase v,
std::string  name_delayed,
int  nbits,
int  delay 
)
static

Definition at line 196 of file imath.cc.

References phase2TrackerDigitizer_cfi::delay, itos(), name(), nbits(), MillePedeFileConverter_cfg::out, AlCaHLTBitMon_QueryRunRegistry::string, and findQualityFiles::v.

Referenced by design_print(), and pipe_delay().

196  {
197  std::string name = v->name();
198  std::string name_pipe = name + "_pipe" + itos(v->pipe_counter());
199  v->pipe_increment();
200  std::string out = "pipe_delay #(.STAGES(" + itos(delay) + "), .WIDTH(" + itos(nbits) + ")) " + name_pipe +
201  "(.clk(clk), .val_in(" + name + "), .val_out(" + name_delayed + "));\n";
202  return out;
203 }
std::string name() const
Definition: imath.h:208
int nbits() const
Definition: imath.h:244
static std::string itos(int i)
Definition: imath.cc:16

◆ pipe_delays()

std::string VarBase::pipe_delays ( const int  step)

Definition at line 184 of file imath.cc.

References MainPageGenerator::l, latency_, nbits(), MillePedeFileConverter_cfg::out, p1_, p2_, p3_, pipe_delay(), pipe_delays(), step_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by pipe_delays().

184  {
185  std::string out = "";
186  if (p1_)
187  out += p1_->pipe_delays(step);
188  if (p2_)
189  out += p2_->pipe_delays(step);
190  if (p3_)
191  out += p3_->pipe_delays(step);
192 
193  int l = step - latency_ - step_;
194  return (out + pipe_delay(this, nbits(), l));
195 }
int latency_
Definition: imath.h:302
int nbits() const
Definition: imath.h:244
VarBase * p1_
Definition: imath.h:298
std::string pipe_delays(const int step)
Definition: imath.cc:184
VarBase * p2_
Definition: imath.h:299
VarBase * p3_
Definition: imath.h:300
static std::string pipe_delay(VarBase *v, int nbits, int delay)
Definition: imath.cc:173
step
Definition: StallMonitor.cc:98

◆ pipe_increment()

void trklet::VarBase::pipe_increment ( )
inline

Definition at line 272 of file imath.h.

References pipe_counter_.

272 { pipe_counter_++; }
int pipe_counter_
Definition: imath.h:316

◆ print() [1/2]

virtual void trklet::VarBase::print ( std::ofstream &  fs,
Verilog  ,
int  l1 = 0,
int  l2 = 0,
int  l3 = 0 
)
inlinevirtual

Reimplemented in trklet::VarFlag, trklet::VarInv, trklet::VarDSPPostadd, trklet::VarMult, trklet::VarTimesC, trklet::VarNeg, trklet::VarShift, trklet::VarShiftround, trklet::VarNounits, trklet::VarSubtract, trklet::VarAdd, trklet::VarDef, trklet::VarParam, trklet::VarAdjustKR, and trklet::VarAdjustK.

Definition at line 257 of file imath.h.

References compareTotals::fs.

Referenced by print_step().

257  {
258  fs << "// VarBase here. Soemthing is wrong!! " << l1 << ", " << l2 << ", " << l3 << "\n";
259  }

◆ print() [2/2]

virtual void trklet::VarBase::print ( std::ofstream &  fs,
HLS  ,
int  l1 = 0,
int  l2 = 0,
int  l3 = 0 
)
inlinevirtual

Reimplemented in trklet::VarFlag, trklet::VarInv, trklet::VarMult, trklet::VarTimesC, trklet::VarNeg, trklet::VarShift, trklet::VarShiftround, trklet::VarNounits, trklet::VarSubtract, trklet::VarAdd, trklet::VarDef, trklet::VarParam, trklet::VarAdjustKR, and trklet::VarAdjustK.

Definition at line 260 of file imath.h.

References compareTotals::fs.

260  {
261  fs << "// VarBase here. Soemthing is wrong!! " << l1 << ", " << l2 << ", " << l3 << "\n";
262  }

◆ print_all() [1/2]

void VarBase::print_all ( std::ofstream &  fs,
Verilog   
)

Definition at line 459 of file imath_Verilog.cc.

References compareTotals::fs, mps_fire::i, print_step(), step_, and verilog.

Referenced by design_print().

459  {
460  for (int i = 0; i <= step_; ++i) {
461  fs << "//\n// STEP " << i << "\n\n";
462  print_step(i, fs, verilog);
463  }
464 }
void print_step(int step, std::ofstream &fs, Verilog)
static struct trklet::VarBase::Verilog verilog

◆ print_all() [2/2]

void VarBase::print_all ( std::ofstream &  fs,
HLS   
)

Definition at line 348 of file imath_HLS.cc.

References compareTotals::fs, hls, mps_fire::i, print_step(), and step_.

348  {
349  for (int i = 0; i <= step_; ++i) {
350  fs << "//\n// STEP " << i << "\n\n";
351  print_step(i, fs, hls);
352  }
353 }
void print_step(int step, std::ofstream &fs, Verilog)
static struct trklet::VarBase::HLS hls

◆ print_cuts() [1/2]

void VarBase::print_cuts ( std::map< const VarBase *, std::set< std::string > > &  cut_strings,
const int  step,
Verilog  ,
const std::map< const VarBase *, std::set< std::string > > *const  previous_cut_strings = nullptr 
) const

Definition at line 44 of file imath_Verilog.cc.

References DMR_cfg::cut, cuts_, itos(), K_, MainPageGenerator::l, latency_, trklet::VarCut::lower_cut(), name(), name_, p1_, p2_, p3_, print_cuts(), step_, AlCaHLTBitMon_QueryRunRegistry::string, trklet::VarCut::upper_cut(), and verilog.

Referenced by print_cuts().

47  {
48  if (p1_)
49  p1_->print_cuts(cut_strings, step, verilog, previous_cut_strings);
50  if (p2_)
51  p2_->print_cuts(cut_strings, step, verilog, previous_cut_strings);
52  if (p3_)
53  p3_->print_cuts(cut_strings, step, verilog, previous_cut_strings);
54 
55  int l = step - latency_ - step_;
57  if (l > 0)
58  name += "_delay" + itos(l);
59 
60  for (const auto& cut : cuts_) {
61  const VarCut* const cast_cut = (VarCut*)cut;
62  const int lower_cut = cast_cut->lower_cut() / K_;
63  const int upper_cut = cast_cut->upper_cut() / K_;
64  if (!previous_cut_strings || (previous_cut_strings && !previous_cut_strings->count(this))) {
65  if (!cut_strings.count(this))
66  cut_strings[this];
67  cut_strings.at(this).insert(name + " > " + itos(lower_cut) + " && " + name + " < " + itos(upper_cut));
68  }
69  }
70 }
std::string name() const
Definition: imath.h:208
int latency_
Definition: imath.h:302
VarBase * p1_
Definition: imath.h:298
VarBase * p2_
Definition: imath.h:299
static struct trklet::VarBase::Verilog verilog
VarBase * p3_
Definition: imath.h:300
static std::string itos(int i)
Definition: imath.cc:16
double upper_cut() const
Definition: imath.h:1072
std::vector< VarBase * > cuts_
Definition: imath.h:309
std::string name_
Definition: imath.h:297
double lower_cut() const
Definition: imath.h:1071
double K_
Definition: imath.h:313
step
Definition: StallMonitor.cc:98
void print_cuts(std::map< const VarBase *, std::set< std::string > > &cut_strings, const int step, Verilog, const std::map< const VarBase *, std::set< std::string > > *const previous_cut_strings=nullptr) const

◆ print_cuts() [2/2]

void VarBase::print_cuts ( std::map< const VarBase *, std::set< std::string > > &  cut_strings,
const int  step,
HLS  ,
const std::map< const VarBase *, std::set< std::string > > *const  previous_cut_strings = nullptr 
) const

Definition at line 39 of file imath_HLS.cc.

References DMR_cfg::cut, cuts_, hls, itos(), K_, trklet::VarCut::lower_cut(), name(), name_, p1_, p2_, p3_, print_cuts(), AlCaHLTBitMon_QueryRunRegistry::string, and trklet::VarCut::upper_cut().

42  {
43  if (p1_)
44  p1_->print_cuts(cut_strings, step, hls, previous_cut_strings);
45  if (p2_)
46  p2_->print_cuts(cut_strings, step, hls, previous_cut_strings);
47  if (p3_)
48  p3_->print_cuts(cut_strings, step, hls, previous_cut_strings);
49 
51 
52  for (const auto& cut : cuts_) {
53  const VarCut* const cast_cut = (VarCut*)cut;
54  const int lower_cut = cast_cut->lower_cut() / K_;
55  const int upper_cut = cast_cut->upper_cut() / K_;
56  if (!previous_cut_strings || (previous_cut_strings && !previous_cut_strings->count(this))) {
57  if (!cut_strings.count(this))
58  cut_strings[this];
59  cut_strings.at(this).insert(name + " > " + itos(lower_cut) + " && " + name + " < " + itos(upper_cut));
60  }
61  }
62 }
std::string name() const
Definition: imath.h:208
VarBase * p1_
Definition: imath.h:298
VarBase * p2_
Definition: imath.h:299
VarBase * p3_
Definition: imath.h:300
static std::string itos(int i)
Definition: imath.cc:16
double upper_cut() const
Definition: imath.h:1072
static struct trklet::VarBase::HLS hls
std::vector< VarBase * > cuts_
Definition: imath.h:309
std::string name_
Definition: imath.h:297
double lower_cut() const
Definition: imath.h:1071
double K_
Definition: imath.h:313
step
Definition: StallMonitor.cc:98
void print_cuts(std::map< const VarBase *, std::set< std::string > > &cut_strings, const int step, Verilog, const std::map< const VarBase *, std::set< std::string > > *const previous_cut_strings=nullptr) const

◆ print_step() [1/2]

void VarBase::print_step ( int  step,
std::ofstream &  fs,
Verilog   
)

Definition at line 402 of file imath_Verilog.cc.

References cms::cuda::assert(), DMR_cfg::cut, cuts_, dump_msg(), compareTotals::fs, latency(), name_, nbits(), op(), op_, p1_, p2_, p3_, pipe_delay(), print(), print_step(), readytoprint_, step(), step_, and verilog.

Referenced by print_all(), and print_step().

402  {
403  if (!readytoprint_)
404  return;
405  if (step > step_)
406  return;
407  int l1 = 0;
408  int l2 = 0;
409  int l3 = 0;
410  if (p1_) {
412  l1 = step_ - p1_->latency() - p1_->step();
413  }
414  if (p2_) {
416  l2 = step_ - p2_->latency() - p2_->step();
417  }
418  if (p3_) {
420  l3 = step_ - p3_->latency() - p3_->step();
421  }
422  if (step == step_) {
423  if (l1 < 0 || l2 < 0 || l3 < 0 || (l1 > 0 && l2 > 0 && l3 > 0)) {
424  char slog[100];
425  sprintf(slog, "%s::print_step(%i): something wrong with latencies! %i %i %i\n", name_.c_str(), step, l1, l2, l3);
426  edm::LogVerbatim("Tracklet") << slog;
427  dump_msg();
428  assert(0);
429  }
430  if (l1 > 0) {
431  if (p1_->op() != "const")
432  fs << pipe_delay(p1_, p1_->nbits(), l1);
433  else
434  l1 = 0;
435  }
436  if (l2 > 0) {
437  if (p2_->op() != "const")
438  fs << pipe_delay(p2_, p2_->nbits(), l2);
439  else
440  l2 = 0;
441  }
442  if (l3 > 0) {
443  if (p3_->op() != "const")
444  fs << pipe_delay(p3_, p3_->nbits(), l3);
445  else
446  l3 = 0;
447  }
448 
449  if (op_ == "flag") {
450  for (const auto& cut : cuts_)
451  fs << cut->cut_var()->pipe_delays(step_);
452  }
453 
454  print(fs, verilog, l1, l2, l3);
455  readytoprint_ = false;
456  }
457 }
Log< level::Info, true > LogVerbatim
void print_step(int step, std::ofstream &fs, Verilog)
int nbits() const
Definition: imath.h:244
VarBase * p1_
Definition: imath.h:298
VarBase * p2_
Definition: imath.h:299
assert(be >=bs)
static struct trklet::VarBase::Verilog verilog
VarBase * p3_
Definition: imath.h:300
std::string op_
Definition: imath.h:301
int step() const
Definition: imath.h:251
std::string op() const
Definition: imath.h:209
int latency() const
Definition: imath.h:252
void dump_msg()
Definition: imath.cc:96
virtual void print(std::ofstream &fs, Verilog, int l1=0, int l2=0, int l3=0)
Definition: imath.h:257
bool readytoprint_
Definition: imath.h:320
std::vector< VarBase * > cuts_
Definition: imath.h:309
std::string name_
Definition: imath.h:297
static std::string pipe_delay(VarBase *v, int nbits, int delay)
Definition: imath.cc:173
step
Definition: StallMonitor.cc:98

◆ print_step() [2/2]

void VarBase::print_step ( int  step,
std::ofstream &  fs,
HLS   
)

Definition at line 331 of file imath_HLS.cc.

References compareTotals::fs, hls, p1_, p2_, p3_, print(), print_step(), readytoprint_, and step_.

331  {
332  if (!readytoprint_)
333  return;
334  if (step > step_)
335  return;
336  if (p1_)
337  p1_->print_step(step, fs, hls);
338  if (p2_)
339  p2_->print_step(step, fs, hls);
340  if (p3_)
341  p3_->print_step(step, fs, hls);
342  if (step == step_) {
343  print(fs, hls, 0, 0, 0);
344  readytoprint_ = false;
345  }
346 }
void print_step(int step, std::ofstream &fs, Verilog)
VarBase * p1_
Definition: imath.h:298
VarBase * p2_
Definition: imath.h:299
VarBase * p3_
Definition: imath.h:300
virtual void print(std::ofstream &fs, Verilog, int l1=0, int l2=0, int l3=0)
Definition: imath.h:257
static struct trklet::VarBase::HLS hls
bool readytoprint_
Definition: imath.h:320
step
Definition: StallMonitor.cc:98

◆ print_truncation() [1/2]

void VarBase::print_truncation ( std::string &  t,
const std::string &  o1,
const int  ps,
Verilog   
) const

Definition at line 10 of file imath_Verilog.cc.

References itos(), name_, nbits_, CastorDigiReco::o1, and submitPVValidationJobs::t.

Referenced by trklet::VarAdd::print(), trklet::VarSubtract::print(), trklet::VarNounits::print(), trklet::VarTimesC::print(), and trklet::VarMult::print().

10  {
11  if (ps > 0) {
12  t += "wire signed [" + itos(nbits_ - 1) + ":0]" + name_ + ";\n";
13  t += "reg signed [" + itos(nbits_ + ps - 1) + ":0]" + name_ + "_tmp;\n";
14  t += "always @(posedge clk) " + name_ + "_tmp <= " + o1 + ";\n";
15  t += "assign " + name_ + " = " + name_ + "_tmp[" + itos(nbits_ + ps - 1) + ":" + itos(ps) + "];\n";
16  } else {
17  t += "reg signed [" + itos(nbits_ - 1) + ":0]" + name_ + ";\n";
18  t += "always @(posedge clk) " + name_ + " <= " + o1 + ";\n";
19  }
20 }
static std::string itos(int i)
Definition: imath.cc:16
std::string name_
Definition: imath.h:297

◆ print_truncation() [2/2]

void VarBase::print_truncation ( std::string &  t,
const std::string &  o1,
const int  ps,
HLS   
) const

Definition at line 11 of file imath_HLS.cc.

References itos(), name_, nbits_, CastorDigiReco::o1, and submitPVValidationJobs::t.

11  {
12  if (ps > 0) {
13  t += "const ap_int<" + itos(nbits_ + ps) + "> " + name_ + "_tmp = " + o1 + ";\n";
14  t += "const ap_int<" + itos(nbits_) + "> " + name_ + " = " + name_ + "_tmp >> " + itos(ps) + ";\n";
15  } else
16  t += "const ap_int<" + itos(nbits_) + "> " + name_ + " = " + o1 + ";\n";
17 }
static std::string itos(int i)
Definition: imath.cc:16
std::string name_
Definition: imath.h:297

◆ range()

double trklet::VarBase::range ( ) const
inline

Definition at line 246 of file imath.h.

References K_, and nbits_.

Referenced by analyze(), calculate(), dump(), dump_msg(), trklet::VarAdd::VarAdd(), trklet::VarDSPPostadd::VarDSPPostadd(), trklet::VarMult::VarMult(), and trklet::VarSubtract::VarSubtract().

246 { return (1 << (nbits_ - 1)) * K_; } // everything is signed
double K_
Definition: imath.h:313

◆ reset()

void trklet::VarBase::reset ( void  )
inline

Definition at line 236 of file imath.h.

References SiStripPI::max, maxval_, and minval_.

236  {
239 #ifdef IMATH_ROOT
240  h_->Clear();
241 #endif
242  }
double minval_
Definition: imath.h:323
double maxval_
Definition: imath.h:324

◆ shift()

int trklet::VarBase::shift ( ) const
inline

Definition at line 248 of file imath.h.

References Kmap_.

Referenced by trklet::VarAdjustK::print(), trklet::VarInv::VarInv(), trklet::VarNounits::VarNounits(), trklet::VarShift::VarShift(), and trklet::VarShiftround::VarShiftround().

248 { return Kmap_.at("2"); }
std::map< std::string, int > Kmap_
Definition: imath.h:314

◆ step()

int trklet::VarBase::step ( ) const
inline

Definition at line 251 of file imath.h.

References step_.

Referenced by design_print(), trklet::VarCut::print(), print_step(), and VarBase().

251 { return step_; }

◆ verilog_print()

static void trklet::VarBase::verilog_print ( const std::vector< VarBase *> &  v,
std::ofstream &  fs 
)
inlinestatic

Definition at line 275 of file imath.h.

References design_print(), compareTotals::fs, findQualityFiles::v, and verilog.

Referenced by trklet::TrackletCalculator::TrackletCalculator().

275 { design_print(v, fs, verilog); }
static struct trklet::VarBase::Verilog verilog
static void design_print(const std::vector< VarBase *> &v, std::ofstream &fs, Verilog)

Member Data Documentation

◆ cut_var_

VarBase* trklet::VarBase::cut_var_
protected

◆ cuts_

std::vector<VarBase *> trklet::VarBase::cuts_
protected

◆ fval_

double trklet::VarBase::fval_
protected

◆ globals_

imathGlobals* trklet::VarBase::globals_
protected

◆ hls

struct trklet::VarBase::HLS trklet::VarBase::hls
static

◆ ival_

long int trklet::VarBase::ival_
protected

◆ K_

double trklet::VarBase::K_
protected

◆ Kmap_

std::map<std::string, int> trklet::VarBase::Kmap_
protected

◆ latency_

int trklet::VarBase::latency_
protected

Definition at line 302 of file imath.h.

Referenced by add_latency(), dump_msg(), latency(), pipe_delays(), print_cuts(), and VarBase().

◆ maxval_

double trklet::VarBase::maxval_
protected

Definition at line 324 of file imath.h.

Referenced by analyze(), calcDebug(), maxval(), reset(), and VarBase().

◆ minval_

double trklet::VarBase::minval_
protected

Definition at line 323 of file imath.h.

Referenced by analyze(), calcDebug(), minval(), reset(), and VarBase().

◆ name_

std::string trklet::VarBase::name_
protected

◆ nbits_

int trklet::VarBase::nbits_
protected

◆ op_

std::string trklet::VarBase::op_
protected

◆ p1_

VarBase* trklet::VarBase::p1_
protected

◆ p2_

VarBase* trklet::VarBase::p2_
protected

◆ p3_

VarBase* trklet::VarBase::p3_
protected

◆ pipe_counter_

int trklet::VarBase::pipe_counter_
protected

Definition at line 316 of file imath.h.

Referenced by makeready(), pipe_counter(), pipe_increment(), and VarBase().

◆ pipe_delays_

std::vector<int> trklet::VarBase::pipe_delays_
protected

Definition at line 317 of file imath.h.

Referenced by add_delay(), has_delay(), makeready(), and VarBase().

◆ readytoanalyze_

bool trklet::VarBase::readytoanalyze_
protected

Definition at line 319 of file imath.h.

Referenced by analyze(), makeready(), and VarBase().

◆ readytoprint_

bool trklet::VarBase::readytoprint_
protected

Definition at line 320 of file imath.h.

Referenced by makeready(), print_step(), and VarBase().

◆ step_

int trklet::VarBase::step_
protected

◆ usedasinput_

bool trklet::VarBase::usedasinput_
protected

Definition at line 321 of file imath.h.

Referenced by inputs(), makeready(), and VarBase().

◆ val_

double trklet::VarBase::val_
protected

◆ verilog

struct trklet::VarBase::Verilog trklet::VarBase::verilog
static