CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Attributes
trklet::VarMult Class Reference

#include <imath.h>

Inheritance diagram for trklet::VarMult:
trklet::VarBase

Public Member Functions

void local_calculate () override
 
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
 
 VarMult (imathGlobals *globals, std::string name, VarBase *p1, VarBase *p2, double range=-1, int nmax=18)
 
 ~VarMult () 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 ()
 
bool calculate (int debug_level)
 
bool calculate ()
 
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
 
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 ()
 

Protected Attributes

int ps_
 
- 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_
 

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
 

Detailed Description

Definition at line 802 of file imath.h.

Constructor & Destructor Documentation

trklet::VarMult::VarMult ( imathGlobals globals,
std::string  name,
VarBase p1,
VarBase p2,
double  range = -1,
int  nmax = 18 
)
inline

Definition at line 804 of file imath.h.

References alignCSCRings::e, trklet::VarBase::K(), trklet::VarBase::K_, trklet::VarBase::Kmap(), trklet::VarBase::Kmap_, n0, trklet::VarBase::nbits(), trklet::VarBase::nbits_, trklet::VarBase::op_, funct::pow(), ps_, and trklet::VarBase::range().

805  : VarBase(globals, name, p1, p2, nullptr, MULT_LATENCY) {
806  op_ = "mult";
807 
808  const std::map<std::string, int> map1 = p1->Kmap();
809  const std::map<std::string, int> map2 = p2->Kmap();
810  for (const auto &it : map1) {
811  if (Kmap_.find(it.first) == Kmap_.end())
812  Kmap_[it.first] = it.second;
813  else
814  Kmap_[it.first] = Kmap_[it.first] + it.second;
815  }
816  for (const auto &it : map2) {
817  if (Kmap_.find(it.first) == Kmap_.end())
818  Kmap_[it.first] = it.second;
819  else
820  Kmap_[it.first] = Kmap_[it.first] + it.second;
821  }
822  K_ = p1->K() * p2->K();
823  int s0 = Kmap_["2"];
824 
825  int n0 = p1->nbits() + p2->nbits();
826  if (range > 0) {
827  n0 = log2(range / K_) + 1e-9;
828  n0 = n0 + 2;
829  }
830  if (n0 < nmax) {
831  ps_ = 0;
832  nbits_ = n0;
833  } else {
834  ps_ = n0 - nmax;
835  nbits_ = nmax;
836  Kmap_["2"] = s0 + ps_;
837  K_ = K_ * pow(2, ps_);
838  }
839  }
double K() const
Definition: imath.h:246
VarBase(imathGlobals *globals, std::string name, VarBase *p1, VarBase *p2, VarBase *p3, int l)
Definition: imath.h:161
std::string op_
Definition: imath.h:300
VarBase * p1() const
Definition: imath.h:209
#define MULT_LATENCY
Definition: imath.h:139
int n0
Definition: AMPTWrapper.h:44
double range() const
Definition: imath.h:245
VarBase * p2() const
Definition: imath.h:210
int nbits() const
Definition: imath.h:243
std::string name() const
Definition: imath.h:207
std::map< std::string, int > Kmap_
Definition: imath.h:313
double K_
Definition: imath.h:312
std::map< std::string, int > Kmap() const
Definition: imath.h:244
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
trklet::VarMult::~VarMult ( )
overridedefault

Member Function Documentation

void VarMult::local_calculate ( )
overridevirtual

Reimplemented from trklet::VarBase.

Definition at line 173 of file imath_calculate.cc.

References trklet::VarBase::fval(), trklet::VarBase::fval_, trklet::VarBase::ival(), trklet::VarBase::ival_, trklet::VarBase::p1_, trklet::VarBase::p2_, and ps_.

173  {
174  fval_ = p1_->fval() * p2_->fval();
175  ival_ = (p1_->ival() * p2_->ival()) >> ps_;
176 }
long int ival() const
Definition: imath.h:213
VarBase * p1_
Definition: imath.h:297
VarBase * p2_
Definition: imath.h:298
long int ival_
Definition: imath.h:305
double fval() const
Definition: imath.h:212
double fval_
Definition: imath.h:304
void VarMult::print ( std::ofstream &  fs,
Verilog  ,
int  l1 = 0,
int  l2 = 0,
int  l3 = 0 
)
overridevirtual

Reimplemented from trklet::VarBase.

Definition at line 270 of file imath_Verilog.cc.

References cms::cuda::assert(), trklet::VarBase::itos(), trklet::VarBase::K_, trklet::VarBase::kstring(), trklet::VarBase::name(), trklet::VarBase::nbits_, trklet::VarBase::p1_, trklet::VarBase::p2_, trklet::VarBase::print_truncation(), ps_, AlCaHLTBitMon_QueryRunRegistry::string, submitPVValidationJobs::t, and trklet::VarBase::verilog.

270  {
271  assert(l3 == 0);
272  assert(p1_);
273  std::string n1 = p1_->name();
274  if (l1 > 0)
275  n1 = n1 + "_delay" + itos(l1);
276  assert(p2_);
277  std::string n2 = p2_->name();
278  if (l2 > 0)
279  n2 = n2 + "_delay" + itos(l2);
280  std::string o1 = n1 + " * " + n2;
281 
282  std::string t = "";
283  print_truncation(t, o1, ps_, verilog);
284  fs << "// " << nbits_ << " bits \t " << kstring() << "\t" << K_ << "\n" << t;
285 }
VarBase * p1_
Definition: imath.h:297
std::string kstring() const
Definition: imath.cc:18
VarBase * p2_
Definition: imath.h:298
assert(be >=bs)
static struct trklet::VarBase::Verilog verilog
static std::string itos(int i)
Definition: imath.cc:16
void print_truncation(std::string &t, const std::string &o1, const int ps, Verilog) const
std::string name() const
Definition: imath.h:207
double K_
Definition: imath.h:312
void VarMult::print ( std::ofstream &  fs,
HLS  ,
int  l1 = 0,
int  l2 = 0,
int  l3 = 0 
)
overridevirtual

Reimplemented from trklet::VarBase.

Definition at line 245 of file imath_HLS.cc.

References cms::cuda::assert(), trklet::VarBase::hls, trklet::VarBase::K_, trklet::VarBase::kstring(), trklet::VarBase::name(), trklet::VarBase::nbits_, trklet::VarBase::p1_, trklet::VarBase::p2_, trklet::VarBase::print_truncation(), ps_, AlCaHLTBitMon_QueryRunRegistry::string, and submitPVValidationJobs::t.

245  {
246  assert(l1 == 0);
247  assert(l2 == 0);
248  assert(l3 == 0);
249  assert(p1_);
250  std::string n1 = p1_->name();
251  assert(p2_);
252  std::string n2 = p2_->name();
253  std::string o1 = n1 + " * " + n2;
254 
255  std::string t = "";
256  print_truncation(t, o1, ps_, hls);
257  fs << "// " << nbits_ << " bits \t " << kstring() << "\t" << K_ << "\n" << t;
258 }
VarBase * p1_
Definition: imath.h:297
std::string kstring() const
Definition: imath.cc:18
VarBase * p2_
Definition: imath.h:298
assert(be >=bs)
static struct trklet::VarBase::HLS hls
void print_truncation(std::string &t, const std::string &o1, const int ps, Verilog) const
std::string name() const
Definition: imath.h:207
double K_
Definition: imath.h:312

Member Data Documentation

int trklet::VarMult::ps_
protected

Definition at line 846 of file imath.h.

Referenced by local_calculate(), print(), and VarMult().