CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
vmac.h
Go to the documentation of this file.
1 
5 // Copyright (c) 2002, Alexander Madorsky, University of Florida/Physics. All rights reserved.
6 
7 
8 #ifndef _VMAC_H_FILE_
9 #define _VMAC_H_FILE_
10 
11 extern globcontrol glc;
12 
13 #ifdef VGEN
14  #define For(par1, par2, par3) glc.setprintassign(0); std::cout << glc.getmargin() << "for (" << flush; std::cout << (par1).getname() << "; " << flush; glc.setprintassign(0); std::cout << (par2).getname() << "; " << flush; glc.setprintassign(0); std::cout << (par3).getname(); std::cout << ") " << flush; glc.setprintassign(1); glc.enablemargin(0);
15 #else
16  #define For(par1, par2, par3) for ((par1); ((par2).getbool()); (par3))
17 #endif
18 
19 #ifdef VGEN
20  #define If(par) glc.setprintassign(0); std::cout << glc.getmargin() << "if (" << flush; std::cout << (par).getname(); std::cout << ") " << flush; glc.setprintassign(1); glc.enablemargin(0);
21 #else
22  #define If(par) if ((par).getbool())
23 #endif
24 
25 #ifdef VGEN
26  #define Else std::cout << glc.getmargin() << "else " << flush; glc.enablemargin(0);
27 #else
28  #define Else else
29 #endif
30 
31 #define begin vbegin()
32 #ifdef VGEN
33  #define vbegin() glc.enablemargin(1); std::cout << "\n" << glc.getmargin() << "begin\n" << flush; glc.Indent();
34 #else
35  #define vbegin() { glc.alwayspush();
36 #endif
37 
38 #define end vend()
39 #ifdef VGEN
40  #define vend() glc.Outdent(); std::cout << glc.getmargin() << "end\n" << flush;
41 #else
42  #define vend() glc.alwayspop(); }
43 #endif
44 
45 #ifdef VGEN
46  #define always(par) std::cout << glc.getmargin() << "always @(" << (par).getorname() << ") " << flush; glc.enablemargin(0);
47 #else
48  #define always(par) glc.alwaysstart(); if ((par).getchange())
49 #endif
50 
51 #ifdef VGEN
52  #define assign std::cout << glc.getmargin() << "assign " << flush; glc.enablemargin(0);
53 #else
54  #define assign
55 #endif
56 
57 #ifdef VGEN
58  #define deassign(par) std::cout << glc.getmargin() << "deassign " << flush; std::cout << (par).getname() << ";\n" << flush; glc.enablemargin(1);
59 #else
60  #define deassign(par) ;
61 #endif
62 
63 #ifdef VGEN
64  #define begincase(par) glc.setprintassign(0); std::cout << glc.getmargin() << "case (" << flush; std::cout << (par).getcatname() << flush; std::cout << ")\n" << flush; glc.setprintassign(1); glc.Indent();
65 #else
66 #define begincase(par) pushswitch((par)); if (0) {}
67 #endif
68 
69 #define endcase vendcase()
70 #ifdef VGEN
71  #define vendcase() glc.Outdent(); std::cout << glc.getmargin() << "endcase\n" << flush;
72 #else
73  #define vendcase() popswitch();
74 #endif
75 
76 #ifdef VGEN
77  #define case1(par) \
78  cout << glc.getmargin(); \
79  glc.setprintassign(0); std::cout << ((Signal)(par)).getcatname(); \
80  cout << " : " << flush; glc.setprintassign(1); glc.enablemargin(0);
81 #else
82  #define case1(par) else if ((getswitch() == (par)).getbool())
83 #endif
84 
85 #ifdef VGEN
86  #define case2(par1, par2) \
87  glc.setprintassign(0); \
88  cout << glc.getmargin(); \
89  glc.setprintassign(0); std::cout << ((Signal)(par1)).getcatname(); std::cout << ", "; \
90  glc.setprintassign(0); std::cout << ((Signal)(par2)).getcatname();\
91  cout << " : " << flush; glc.setprintassign(1); glc.enablemargin(0);
92 #else
93  #define case2(par1, par2) else if ( (getswitch() == (par1)).getbool() || (getswitch() == (par2)).getbool())
94 #endif
95 
96 #ifdef VGEN
97  #define case3(par1, par2, par3) \
98  glc.setprintassign(0); \
99  cout << glc.getmargin(); \
100  glc.setprintassign(0); std::cout << ((Signal)(par1)).getcatname(); std::cout << ", "; \
101  glc.setprintassign(0); std::cout << ((Signal)(par2)).getcatname(); std::cout << ", "; \
102  glc.setprintassign(0); std::cout << ((Signal)(par3)).getcatname(); \
103  cout << " : " << flush; glc.setprintassign(1); glc.enablemargin(0);
104 #else
105  #define case3(par1, par2, par3) else if ( (getswitch() == (par1)).getbool() || (getswitch() == (par2)).getbool() || (getswitch() == (par3)).getbool())
106 #endif
107 
108 
109 #define Default vdefault()
110 #ifdef VGEN
111  #define vdefault() std::cout << glc.getmargin(); std::cout << "default : " << flush; glc.enablemargin(0);
112 #else
113  #define vdefault() else
114 #endif
115 
116 #define beginmodule vbeginmodule();
117 #define endmodule vendmodule();
118 
119 #ifdef VGEN
120 #define modulebody
121 #else
122 #define modulebody \
123 if (glc.getpassn() != passn) \
124 { \
125 /* cout << itern << " " << instname << std::endl; */\
126  itern = 0; \
127 } \
128 passn = glc.getpassn(); \
129 if (!glc.getparent()->getchange()) \
130 { \
131  outregn = 0; \
132  return; \
133 } \
134 else \
135 { \
136  itern++; \
137 }
138 
139 #endif
140 
141 #define beginfunction vbeginfunction();
142 #define endfunction vendfunction(); return (result);
143 
144 #ifdef VGEN
145 #define functionbody
146 #else
147 //#define functionbody if (!glc.getparent()->getchange()) {vendfunction(); return (result);}
148 #define functionbody
149 #endif
150 
151 
152 #if (__GNUC__==2)||defined(_MSC_VER)
153 #define or ||
154 #endif
155 #define makereg this
156 
157 #define endperiod glc.ResetEvents();
158 
159 #ifdef VGEN
160  #define comment(par) if (glc.getFileOpen()) {std::cout << glc.getmargin(); std::cout << (par) << "\n" << flush;} else glc.AddComment((string)(par));
161 #else
162  #define comment(par)
163 #endif
164 
165 #ifdef VGEN
166  #define printv(par) std::cout << (par) << flush;
167 #else
168  #define printv(par)
169 #endif
170 
171 
172 #ifdef VGEN
173  #define initio glc.setparent(this); glc.setFileOpen(0);
174 #else
175  #define initio glc.setparent(this); glc.getparent()->setchange(0);
176 #endif
177 
178 // these macros are different for all possible types of initializations,
179 // because not all compilers yet support ISO C99 variadic macros (macros with variable number of parameters)
180 // At the moment of writing, only GNU C++ compiler supports them.
181 #define Reg(cl) cl.reg(#cl)
182 #define Reg_(cl, h, l) cl.reg(h, l, #cl)
183 #define Reg__(cl, h, l, t, b) cl.reg(h, l, t, b, #cl);
184 
185 #define Wire(cl) cl.wire(#cl)
186 #define Wire_(cl, h, l) cl.wire(h, l, #cl)
187 #define Wire__(cl, h, l, t, b) for (int __wi__ = b; __wi__ <= t; __wi__++) cl[__wi__].wire(h, l, #cl, __wi__)
188 
189 #define Input(cl) cl.input(#cl)
190 #define Input_(cl, h, l) cl.input(h, l, #cl)
191 #define Clock(cl) cl.clock(#cl)
192 
193 #define Output(cl) cl.output(#cl)
194 #define Output_(cl, h, l) cl.output(h, l, #cl)
195 
196 #define OutReg(cl) cl.output(#cl, makereg)
197 #define OutReg_(cl, h, l) cl.output(h, l, #cl, makereg)
198 
199 #define Inout(cl) cl.inout(#cl)
200 #define Inout_(cl, h, l) cl.inout(h, l, #cl)
201 
202 #define Module(md) md.init(#md, #md)
203 #define Module_(md, fn) md.init(#md, #fn)
204 
205 #define cns(b,v) glc.constant(b,v)
206 
207 #endif
208 
globcontrol glc
Definition: vlib.cc:6