CMS 3D CMS Logo

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