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