CMS 3D CMS Logo

vlib.h
Go to the documentation of this file.
1 #ifndef RVALS
2 #define RVALS 2 // max bits in reg/wire divided by 32
3 #endif
4 
9 #ifndef _VLIB_H_FILE_
10 #define _VLIB_H_FILE_
11 
12 #include <iostream>
13 #include <fstream>
14 #include <sstream>
15 #include <string>
16 #include <ctime>
17 #include <cstdio>
18 
19 #define MAXARG 2000
20 
21 typedef unsigned long long int rval;
22 #define Sizeofrval sizeof(rval)
23 
24 class module;
25 
27 
28 class Signal {
29 public:
30  Signal();
31  Signal(rval);
32  Signal(int);
33  Signal(unsigned int);
34  Signal(const char*);
35  Signal(int bits, rval value);
36  void create();
37  void init(int, int, const char*);
38  void init(const char* rname) { init(0, 0, rname); };
39  void init(Signal* shost, int h, int l, const char* rname);
40  void makemask();
41 #ifdef VGEN
42  std::string& getname() { return name; };
43  std::string& getorname() { return orname; };
44  std::string& getcatname();
45  void setname(std::string& rname) { name = rname; };
46  void setorname(std::string& rname) { orname = rname; };
47  void setbrackets(const char* l, const char* r) {
48  lb = l;
49  rb = r;
50  };
51 #endif
52  rval getr() { return r; };
53  int getint() { return (unsigned int)r; };
54  int getl() { return l; };
55  int geth() { return h; };
56  rval getmask() { return mask; };
57  void setr(rval rv) { r = rv & mask; };
58  void setrc(rval rv) { rc = rv & mask; };
59  void sethlmask(int high, int low, rval imask) {
60  h = high;
61  l = low;
62  mask = imask;
63  };
64  // bool getbool(){return (r != 0);};
65  bool getbool() { return (getval() != 0); };
66  int getposedge() { return pedge; };
67  int getnegedge() { return nedge; };
68  int getchange() { return change; };
69  void setchange(int ch) { change = ch; };
70  void setposedge(int ch) { pedge = ch; };
71  void setnegedge(int ch) { nedge = ch; };
72  void setalwaysn(int n) { alwaysn = (n == -1) ? 0 : n; };
73  int getalwaysn() { return alwaysn; };
74  void setprintable(int p) { printable = p; };
75  rval getval();
76 
77  Signal set(Signal);
80 
93 
100 
101  Signal operator!();
102  Signal operator~();
103  Signal* operator&();
104  Signal operator++() { return *this = *this + 1; };
105  Signal operator--() { return *this = *this - 1; };
107  return *this = *this + 1;
108  }; // postfix operators require some work (different names for operations and assignment printing?)
109  Signal operator--(int) { return *this = *this - 1; };
110 
111  friend Signal ror(Signal);
112  friend Signal rxor(Signal);
113  friend Signal rand(Signal);
114 
117 
119 
120  friend std::ostream& operator<<(std::ostream& stream, Signal s);
121 
122  void input(int, int, const char*);
123  void input(const char* rname) { input(0, 0, rname); };
124  void clock(const char* rname);
125 
126  void output(int, int, const char*);
127  void output(const char* rname) { output(0, 0, rname); };
128  void output(int high, int low, const char* rname, module* parent);
129  void output(const char* rname, module* parent);
130 
131  void inout(int, int, const char*);
132  void inout(const char* rname) { inout(0, 0, rname); };
133 
134  void reg(int, int, const char*);
135  void initreg(int, int, const char*);
136  void reg(const char* rname) { reg(0, 0, rname); };
137 
138  void wire(int, int, const char*);
139  void wire(int, int, const char*, int);
140  void wire(const char* rname) { wire(0, 0, rname); };
141 
142 protected:
143  rval r; // value holder
144  rval rc; // current value holder
145  int h, l; // high and low bit numbers
146  int hostl; // low bit of host
147  rval mask; // bit mask
148 #ifdef VGEN
150  std::string orname;
151  std::string lb, rb; // to distinguish between expression and variable
152  std::string obname;
153  std::string catname;
154 #endif
155  Signal* host; // this Signal is a portion of the host
157  Signal* ca2; // arguments of the comma operator
159  Signal* source; // pointer to source object
162  int alwaysn;
163  int inited;
165  int mode; // none, reg, wire, input, output, inout
166 };
167 
168 class parameter : public Signal {
169 public:
170  parameter(const char* rname, Signal arg);
171  operator int() { return (unsigned int)r; };
172 
173 protected:
174  void init(int, int, const char*);
175  void operator=(Signal arg);
176 };
177 
178 class memory {
179 public:
180  memory() { r = nullptr; };
181  ~memory();
182  void reg(int, int, int, int, const char*);
183  void reg(int nup, int ndown, const char* rname) { reg(0, 0, nup, ndown, rname); };
184 #ifdef VGEN
186 #else
188 #endif
189 
190 protected:
191 #ifdef VGEN
193 #endif
195  int up, down;
196 };
197 
198 class module {
199 public:
200  module();
201  virtual ~module();
202  void create();
203  void vendmodule();
204  void vbeginmodule();
205 
206  virtual void operator()(){};
207 
208  void init(const char*, const char*);
209  void init(const char*, const char*, module* fixt);
210  void init(const char*, const char*, int);
214  switcharg[switchn] = arg;
215  switchn++;
216  };
217  Signal getswitch() { return switcharg[switchn - 1]; };
218  void popswitch() { switchn--; }
221  void setchange(int c) { change = c; }
222  int getchange() { return change; }
223 #ifdef VGEN
224  void PrintHeader();
225 #endif
226 protected:
227 #ifdef VGEN
229  std::streambuf* outbuf;
230  std::ofstream vfile;
231 #endif
235  int switchn;
237  Signal* outreg[1000];
238  int outregn;
241  int change;
242  int itern; // number of iterations, for diagnostics
243  rval passn; // number of pass
244 };
245 
246 class function : public module {
247 public:
248  function(){};
249  void init(int, int, const char*);
250  void vendfunction();
251  void vbeginfunction();
252  void makemask(int hpar, int lpar);
253 
254 protected:
255 #ifdef VGEN
256  string retname;
257 #endif
258  int h, l;
262 };
263 
264 #define MAXSTIM 10000
265 
266 class globcontrol {
267 public:
268  globcontrol();
269 #ifdef VGEN
270  void AddParameter(string ln) {
271  pars[npar] = ln;
272  npar++;
273  };
274  void AddDeclarator(string ln) {
275  decls[ndecl] = ln;
276  ndecl++;
277  };
278  void AddComment(string ln) {
279  ln += "\n";
280  decls[ndecl] = ln;
281  ndecl++;
282  };
283  void AddIO(string ln);
284  void Print();
285  string& PrintIO(bool col);
286  void Indent() {
287  indpos++;
288  PrepMargin();
289  };
290  void Outdent() {
291  indpos--;
292  PrepMargin();
293  };
294  string& getmargin() {
295  int t = nomargin;
296  nomargin = 0;
297  return (t) ? zeromargin : margin;
298  };
299  int getpos() { return indpos; };
300  void setpos(int pos) {
301  indpos = pos;
302  PrepMargin();
303  };
304  void setprintassign(int y) { pa = y; };
305  int printassign() { return pa; };
306  void enablemargin(int i) { nomargin = !i; };
307  int getenablemargin() { return !nomargin; };
308  void setFileOpen(int fo) { VFileOpen = fo; };
309  int getFileOpen() { return VFileOpen; };
310 #endif
311  void alwaysstart() {
312  alwayscnt = 0;
313  alwaysn++;
314  if (alwaysn == 0 || alwaysn == -1)
315  alwaysn = 1;
316  };
317  void alwayspush() {
318  if (alwayscnt >= 0)
319  alwayscnt++;
320  };
321  void alwayspop() {
322  if (alwayscnt > 0)
323  alwayscnt--;
324  if (alwayscnt == 0)
325  alwayscnt = -1;
326  };
327  int alwaysget() { return (alwayscnt > 0); };
328  int getalwaysn() { return (alwayscnt > 0) ? alwaysn : (-1); };
329 
330  void setchange(int i);
331  int getchange() { return change; };
332  void setparent(module* rparent) { parent = rparent; };
333  module* getparent() { return parent; };
334  void setfunction(int i) { functiondecl = i; };
335  int getfunction() {
336  int t = functiondecl;
337  functiondecl = 0;
338  return t;
339  };
340  int getce() { return ce; };
341  int setce(int c) {
342  ce = c;
343  return 1;
344  };
345  char* constant(int bits, char* val);
346  char* constant(int bits, int val);
347  void passn_inc() { passn++; };
348  rval getpassn() { return passn; }
349 
350 protected:
351 #ifdef VGEN
352  string pars[MAXARG];
353  int npar;
354 
355  string decls[MAXARG];
356  int ndecl;
357 
358  string dios[MAXARG];
359  int ndio;
360 
361  int indpos;
362  string margin, zeromargin;
363  void PrepMargin();
364  int nomargin;
365 
366  int pa;
367  string outln;
368 #endif
370 
372  int alwaysn;
373 
374  int change;
376 
377  int VFileOpen; // shows if the comments can be written into the file, or they need to be added to declarators
378  int ce; // clock can be processed
379  char constring[RVALS * 32 + 32]; // string for text variables
380  rval passn; // pass number
381 };
382 
383 #ifdef VGEN
384 #define beginsystem
385 #define endsystem exit(0);
386 #else
387 #define beginsystem \
388  glc.setce(0); \
389  glc.passn_inc(); \
390  do { \
391  glc.setchange(0);
392 #define endsystem \
393  } \
394  while (glc.getchange() ? 1 : glc.getce() ? 0 : glc.setce(1)) \
395  ;
396 #endif
397 
398 #endif
Signal::operator()
Signal operator()(Signal, Signal)
Definition: vlib.cc:517
module::init
void init(const char *, const char *)
Definition: vlib.cc:922
Signal::pedge
int pedge
Definition: vlib.h:158
Signal::host
Signal * host
Definition: vlib.h:155
Signal::operator%
Signal operator%(Signal)
Definition: vlib.cc:305
DDAxes::y
module::switcharg
Signal switcharg[10]
Definition: vlib.h:234
mps_fire.i
i
Definition: mps_fire.py:355
Signal::operator!
Signal operator!()
Definition: vlib.cc:274
Signal::asgn
Signal asgn(Signal)
Definition: vlib.cc:459
Signal::setr
void setr(rval rv)
Definition: vlib.h:57
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
Signal::printable
int printable
Definition: vlib.h:164
module::popswitch
void popswitch()
Definition: vlib.h:218
module::operator()
virtual void operator()()
Definition: vlib.h:206
Signal::inout
void inout(int, int, const char *)
Definition: vlib.cc:717
globcontrol::getalwaysn
int getalwaysn()
Definition: vlib.h:328
Signal::setalwaysn
void setalwaysn(int n)
Definition: vlib.h:72
Signal::outhost
Signal * outhost
Definition: vlib.h:160
memory::down
int down
Definition: vlib.h:195
Signal::operator&&
Signal operator&&(Signal)
Definition: vlib.cc:306
Signal::input
void input(int, int, const char *)
Definition: vlib.cc:545
globcontrol::change
int change
Definition: vlib.h:374
Signal::change
int change
Definition: vlib.h:158
parameter::operator=
void operator=(Signal arg)
Definition: vlib.cc:799
Signal::operator++
Signal operator++(int)
Definition: vlib.h:106
module::module
module()
Definition: vlib.cc:913
Signal::getint
int getint()
Definition: vlib.h:53
Signal::create
void create()
Definition: vlib.cc:13
function::result
Signal result
Definition: vlib.h:261
globcontrol::ce
int ce
Definition: vlib.h:378
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
function::OldChange
int OldChange
Definition: vlib.h:260
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
function::vbeginfunction
void vbeginfunction()
Definition: vlib.cc:1086
cuy.col
col
Definition: cuy.py:1010
mtemp
Definition: vlib.h:26
pos
Definition: PixelAliasList.h:18
globcontrol::passn_inc
void passn_inc()
Definition: vlib.h:347
Signal::inited
int inited
Definition: vlib.h:163
Signal::output
void output(const char *rname)
Definition: vlib.h:127
memory::reg
void reg(int, int, int, int, const char *)
Definition: vlib.cc:840
Signal::getalwaysn
int getalwaysn()
Definition: vlib.h:73
Signal::operator--
Signal operator--()
Definition: vlib.h:105
Signal::operator<<
Signal operator<<(Signal)
Definition: vlib.cc:306
globcontrol::alwayspush
void alwayspush()
Definition: vlib.h:317
memory::reg
void reg(int nup, int ndown, const char *rname)
Definition: vlib.h:183
mwire
Definition: vlib.h:26
Signal::operator*
Signal operator*(Signal)
Definition: vlib.cc:305
globcontrol::globcontrol
globcontrol()
Definition: vlib.cc:1127
MAXARG
#define MAXARG
Definition: vlib.h:19
Signal::sethlmask
void sethlmask(int high, int low, rval imask)
Definition: vlib.h:59
function::init
void init(int, int, const char *)
Definition: vlib.cc:1071
Signal::alwaysn
int alwaysn
Definition: vlib.h:162
Signal::source
Signal * source
Definition: vlib.h:159
Signal::getnegedge
int getnegedge()
Definition: vlib.h:67
mnum
Definition: vlib.h:26
memory::up
int up
Definition: vlib.h:195
Signal
Definition: vlib.h:28
Signal::operator~
Signal operator~()
Definition: vlib.cc:274
globcontrol::VFileOpen
int VFileOpen
Definition: vlib.h:377
Signal::getposedge
int getposedge()
Definition: vlib.h:66
Signal::nedge
int nedge
Definition: vlib.h:158
Signal::operator>
Signal operator>(Signal)
Definition: vlib.cc:361
SignalMode
SignalMode
Definition: vlib.h:26
module::outreg
Signal * outreg[1000]
Definition: vlib.h:237
Signal::reg
void reg(int, int, const char *)
Definition: vlib.cc:756
globcontrol::functiondecl
int functiondecl
Definition: vlib.h:369
Signal::wire
void wire(int, int, const char *)
Definition: vlib.cc:808
Signal::set
Signal set(Signal)
Definition: vlib.cc:452
alignCSCRings.s
s
Definition: alignCSCRings.py:92
globcontrol
Definition: vlib.h:266
RVALS
#define RVALS
Definition: vlib.h:2
Signal::rxor
friend Signal rxor(Signal)
Definition: vlib.cc:393
parameter
Definition: vlib.h:168
module::outregn
int outregn
Definition: vlib.h:238
rval
unsigned long long int rval
Definition: vlib.h:21
Signal::Signal
Signal()
Definition: vlib.cc:29
module::vbeginmodule
void vbeginmodule()
Definition: vlib.cc:971
module::setchange
void setchange(int c)
Definition: vlib.h:221
Signal::getl
int getl()
Definition: vlib.h:54
function::mask
rval mask
Definition: vlib.h:259
globcontrol::getchange
int getchange()
Definition: vlib.h:331
Signal::setposedge
void setposedge(int ch)
Definition: vlib.h:70
memory::memory
memory()
Definition: vlib.h:180
function::l
int l
Definition: vlib.h:258
Signal::l
int l
Definition: vlib.h:145
module::getswitch
Signal getswitch()
Definition: vlib.h:217
Signal::rand
friend Signal rand(Signal)
Definition: vlib.cc:379
Signal::output
void output(int, int, const char *)
Definition: vlib.cc:655
h
OrderedSet.t
t
Definition: OrderedSet.py:90
Signal::operator||
Signal operator||(Signal)
Definition: vlib.cc:308
globcontrol::getpassn
rval getpassn()
Definition: vlib.h:348
globcontrol::setfunction
void setfunction(int i)
Definition: vlib.h:334
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Signal::operator<
Signal operator<(Signal)
Definition: vlib.cc:361
Signal::operator-
Signal operator-(Signal)
Definition: vlib.cc:305
mreg
Definition: vlib.h:26
Signal::operator|
Signal operator|(Signal)
Definition: vlib.cc:306
memory::operator[]
Signal & operator[](Signal)
Definition: vlib.cc:883
Signal::operator^
Signal operator^(Signal)
Definition: vlib.cc:305
globcontrol::setchange
void setchange(int i)
Definition: vlib.cc:1206
module::AddOutReg
Signal * AddOutReg(Signal arg)
Definition: vlib.cc:1034
globcontrol::constring
char constring[2 *32+32]
Definition: vlib.h:379
module::tfixt
module * tfixt
Definition: vlib.h:240
memory::~memory
~memory()
Definition: vlib.cc:874
Signal::getchange
int getchange()
Definition: vlib.h:68
Signal::operator--
Signal operator--(int)
Definition: vlib.h:109
Signal::operator=
Signal operator=(Signal)
Definition: vlib.cc:417
module::posedge
Signal posedge(Signal)
Definition: vlib.cc:1004
Signal::ca2
Signal * ca2
Definition: vlib.h:157
module::negedge
Signal negedge(Signal)
Definition: vlib.cc:1019
rname
const G4String rname[NREG]
Definition: ParametrisedEMPhysics.cc:46
mnone
Definition: vlib.h:26
Signal::operator&
Signal * operator&()
Definition: vlib.cc:276
Signal::operator>>
Signal operator>>(Signal)
Definition: vlib.cc:306
Signal::operator==
Signal operator==(Signal)
Definition: vlib.cc:361
globcontrol::getparent
module * getparent()
Definition: vlib.h:333
globcontrol::alwayscnt
int alwayscnt
Definition: vlib.h:371
createfilelist.int
int
Definition: createfilelist.py:10
globcontrol::getfunction
int getfunction()
Definition: vlib.h:335
plotscripts.getname
def getname(r)
Definition: plotscripts.py:2032
Signal::getbool
bool getbool()
Definition: vlib.h:65
globcontrol::alwaysstart
void alwaysstart()
Definition: vlib.h:311
module::OuterIndPos
int OuterIndPos
Definition: vlib.h:233
value
Definition: value.py:1
parameter::parameter
parameter(const char *rname, Signal arg)
Definition: vlib.cc:782
Signal::initreg
void initreg(int, int, const char *)
Definition: vlib.cc:766
Signal::geth
int geth()
Definition: vlib.h:55
globcontrol::setparent
void setparent(module *rparent)
Definition: vlib.h:332
Signal::operator>=
Signal operator>=(Signal)
Definition: vlib.cc:361
globcontrol::constant
char * constant(int bits, char *val)
Definition: vlib.cc:1208
memory::r
Signal * r
Definition: vlib.h:194
module::itern
int itern
Definition: vlib.h:242
Signal::r
rval r
Definition: vlib.h:140
Signal::operator,
Signal operator,(Signal)
Definition: vlib.cc:324
Signal::makemask
void makemask()
Definition: vlib.cc:202
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
module
Definition: vlib.h:198
globcontrol::parent
module * parent
Definition: vlib.h:375
Signal::hostl
int hostl
Definition: vlib.h:146
Signal::ca1
Signal * ca1
Definition: vlib.h:156
Signal::outreg
Signal * outreg
Definition: vlib.h:161
globcontrol::passn
rval passn
Definition: vlib.h:380
globcontrol::alwaysn
int alwaysn
Definition: vlib.h:372
Signal::operator++
Signal operator++()
Definition: vlib.h:104
Signal::getr
rval getr()
Definition: vlib.h:52
module::change
int change
Definition: vlib.h:241
Signal::getval
rval getval()
Definition: vlib.cc:415
globcontrol::alwayspop
void alwayspop()
Definition: vlib.h:321
module::runperiod
void(* runperiod)()
Definition: vlib.h:239
minput
Definition: vlib.h:26
module::ifelse
Signal ifelse(Signal, Signal, Signal)
Definition: vlib.cc:1044
function::makemask
void makemask(int hpar, int lpar)
Definition: vlib.cc:1061
bits
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
Definition: EventSelector-behavior.doc:35
Signal::clock
void clock(const char *rname)
Definition: vlib.cc:603
Signal::operator!=
Signal operator!=(Signal)
Definition: vlib.cc:362
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
heppy_batch.val
val
Definition: heppy_batch.py:351
module::pushswitch
void pushswitch(Signal arg)
Definition: vlib.h:213
Signal::mask
rval mask
Definition: vlib.h:147
Signal::setnegedge
void setnegedge(int ch)
Definition: vlib.h:71
Signal::setchange
void setchange(int ch)
Definition: vlib.h:69
Signal::mode
int mode
Definition: vlib.h:165
moutput
Definition: vlib.h:26
Signal::ror
friend Signal ror(Signal)
Definition: vlib.cc:365
globcontrol::getce
int getce()
Definition: vlib.h:340
Signal::getmask
rval getmask()
Definition: vlib.h:56
Signal::h
int h
Definition: vlib.h:145
module::vendmodule
void vendmodule()
Definition: vlib.cc:992
Signal::operator/
Signal operator/(Signal)
Definition: vlib.cc:305
function
Definition: vlib.h:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
parameter::init
void init(int, int, const char *)
Definition: vlib.cc:790
Signal::operator+
Signal operator+(Signal)
Definition: vlib.cc:305
Signal::init
void init(int, int, const char *)
Definition: vlib.cc:208
Signal::rc
rval rc
Definition: vlib.h:144
funct::void
TEMPL(T2) struct Divides void
Definition: Factorize.h:29
funct::arg
A arg
Definition: Factorize.h:36
module::create
void create()
Definition: vlib.cc:906
Signal::setprintable
void setprintable(int p)
Definition: vlib.h:74
module::instname
std::string instname
Definition: vlib.h:232
minout
Definition: vlib.h:26
Signal::init
void init(const char *rname)
Definition: vlib.h:38
globcontrol::setce
int setce(int c)
Definition: vlib.h:341
Signal::operator<=
Signal operator<=(Signal)
Definition: vlib.cc:361
function::h
int h
Definition: vlib.h:258
Signal::setrc
void setrc(rval rv)
Definition: vlib.h:58
Signal::inout
void inout(const char *rname)
Definition: vlib.h:132
module::~module
virtual ~module()
Definition: vlib.cc:915
Signal::input
void input(const char *rname)
Definition: vlib.h:123
class-composition.parent
parent
Definition: class-composition.py:88
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
module::getchange
int getchange()
Definition: vlib.h:222
module::switchn
int switchn
Definition: vlib.h:235
module::passn
rval passn
Definition: vlib.h:243
Signal::wire
void wire(const char *rname)
Definition: vlib.h:140
globcontrol::alwaysget
int alwaysget()
Definition: vlib.h:327
function::vendfunction
void vendfunction()
Definition: vlib.cc:1108
Signal::reg
void reg(const char *rname)
Definition: vlib.h:136
module::oldenmarg
int oldenmarg
Definition: vlib.h:236
memory
Definition: vlib.h:178
margin
Double_t margin
Definition: trackSplitPlot.h:45