CMS 3D CMS Logo

List of all members | Public Member Functions
trklet::VarDef Class Reference

#include <imath.h>

Inheritance diagram for trklet::VarDef:
trklet::VarBase

Public Member Functions

void print (std::ofstream &fs, Verilog, int l1=0, int l2=0, int l3=0) override
 
void print (std::ofstream &fs, HLS, int l1=0, int l2=0, int l3=0) override
 
void set_fval (double fval)
 
void set_ival (int ival)
 
 VarDef (imathGlobals *globals, std::string name, std::string units, double fmax, double K)
 
 VarDef (imathGlobals *globals, std::string name, VarBase *p)
 
 ~VarDef () override=default
 
- Public Member Functions inherited from trklet::VarBase
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 ()
 
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 ()
 

Additional Inherited Members

- Static Public Member Functions inherited from trklet::VarBase
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 inherited from trklet::VarBase
static struct trklet::VarBase::HLS hls
 
static struct trklet::VarBase::Verilog verilog
 
- Protected Attributes inherited from trklet::VarBase
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 466 of file imath.h.

Constructor & Destructor Documentation

◆ VarDef() [1/2]

trklet::VarDef::VarDef ( imathGlobals globals,
std::string  name,
std::string  units,
double  fmax,
double  K 
)
inline

Definition at line 469 of file imath.h.

References funct::abs(), MillePedeFileConverter_cfg::e, trklet::VarBase::K(), trklet::VarBase::K_, trklet::VarBase::Kmap_, cmsLHEtoEOSManager::l, trklet::VarBase::nbits_, trklet::VarBase::op_, funct::pow(), and units().

470  : VarBase(globals, name, nullptr, nullptr, nullptr, 1) {
471  op_ = "def";
472  K_ = K;
473  nbits_ = log2(fmax / K) + 1.999999; //plus one to round up
474  if (!units.empty())
475  Kmap_[units] = 1;
476  else {
477  //defining a constant, K should be a power of two
478  int l = log2(K);
479  if (std::abs(pow(2, l) / K - 1) > 1e-5) {
480  char slog[100];
481  snprintf(slog, 100, "defining unitless constant, yet K is not a power of 2! %g, %g", K, pow(2, l));
482  edm::LogVerbatim("Tracklet") << slog;
483  }
484  Kmap_["2"] = l;
485  }
486  }
Log< level::Info, true > LogVerbatim
std::string name() const
Definition: imath.h:208
VarBase(imathGlobals *globals, std::string name, VarBase *p1, VarBase *p2, VarBase *p3, int l)
Definition: imath.h:162
std::string op_
Definition: imath.h:301
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double K() const
Definition: imath.h:247
std::map< std::string, int > Kmap_
Definition: imath.h:314
TString units(TString variable, Char_t axis)
double K_
Definition: imath.h:313
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ VarDef() [2/2]

trklet::VarDef::VarDef ( imathGlobals globals,
std::string  name,
VarBase p 
)
inline

Definition at line 488 of file imath.h.

References trklet::VarBase::K_, trklet::VarBase::Kmap_, trklet::VarBase::nbits_, trklet::VarBase::op_, and AlCaHLTBitMon_ParallelJobs::p.

488  : VarBase(globals, name, nullptr, nullptr, nullptr, 1) {
489  op_ = "def";
490  K_ = p->K();
491  nbits_ = p->nbits();
492  Kmap_ = p->Kmap();
493  }
std::string name() const
Definition: imath.h:208
VarBase(imathGlobals *globals, std::string name, VarBase *p1, VarBase *p2, VarBase *p3, int l)
Definition: imath.h:162
std::string op_
Definition: imath.h:301
std::map< std::string, int > Kmap_
Definition: imath.h:314
double K_
Definition: imath.h:313

◆ ~VarDef()

trklet::VarDef::~VarDef ( )
overridedefault

Member Function Documentation

◆ print() [1/2]

void VarDef::print ( std::ofstream &  fs,
Verilog  ,
int  l1 = 0,
int  l2 = 0,
int  l3 = 0 
)
overridevirtual

Reimplemented from trklet::VarBase.

Definition at line 115 of file imath_Verilog.cc.

References cms::cuda::assert(), compareTotals::fs, trklet::VarBase::itos(), trklet::VarBase::K_, trklet::VarBase::kstring(), trklet::VarBase::name_, trklet::VarBase::nbits_, AlCaHLTBitMon_QueryRunRegistry::string, and submitPVValidationJobs::t.

115  {
116  assert(l1 == 0);
117  assert(l2 == 0);
118  assert(l3 == 0);
119 
120  std::string t = "reg signed [" + itos(nbits_ - 1) + ":0]" + name_ + ";\n";
121  t = t + "always @(posedge clk) " + name_ + " <= " + name_ + "_wire;\n";
122  fs << "// units " << kstring() << "\t" << K_ << "\n" << t;
123 }
std::string kstring() const
Definition: imath.cc:18
assert(be >=bs)
static std::string itos(int i)
Definition: imath.cc:16
std::string name_
Definition: imath.h:297
double K_
Definition: imath.h:313

◆ print() [2/2]

void VarDef::print ( std::ofstream &  fs,
HLS  ,
int  l1 = 0,
int  l2 = 0,
int  l3 = 0 
)
overridevirtual

Reimplemented from trklet::VarBase.

Definition at line 102 of file imath_HLS.cc.

References cms::cuda::assert(), compareTotals::fs, trklet::VarBase::K_, trklet::VarBase::kstring(), trklet::VarBase::name_, and trklet::VarBase::nbits_.

102  {
103  assert(l1 == 0);
104  assert(l2 == 0);
105  assert(l3 == 0);
106 
107  fs << "// units " << kstring() << "\t" << K_ << "\n";
108  fs << "const ap_int<" << nbits_ << "> " << name_ << " = " << name_ << "_wire;\n";
109 }
std::string kstring() const
Definition: imath.cc:18
assert(be >=bs)
std::string name_
Definition: imath.h:297
double K_
Definition: imath.h:313

◆ set_fval()

void trklet::VarDef::set_fval ( double  fval)
inline

Definition at line 494 of file imath.h.

References trklet::VarBase::fval(), trklet::VarBase::fval_, trklet::VarBase::ival_, trklet::VarBase::K_, and trklet::VarBase::val_.

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

494  {
495  fval_ = fval;
496  if (fval > 0)
497  ival_ = fval / K_;
498  else
499  ival_ = fval / K_ - 1;
500  val_ = ival_ * K_;
501  }
double fval() const
Definition: imath.h:213
double val_
Definition: imath.h:307
long int ival_
Definition: imath.h:306
double K_
Definition: imath.h:313
double fval_
Definition: imath.h:305

◆ set_ival()

void trklet::VarDef::set_ival ( int  ival)
inline