CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/L1Trigger/CSCCommonTrigger/interface/vmac.h

Go to the documentation of this file.
00001 
00005 // Copyright (c) 2002, Alexander Madorsky, University of Florida/Physics. All rights reserved.
00006 
00007 
00008 #ifndef _VMAC_H_FILE_
00009 #define _VMAC_H_FILE_
00010 
00011 extern globcontrol glc;
00012 
00013 #ifdef VGEN
00014         #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);
00015 #else
00016         #define For(par1, par2, par3) for ((par1); ((par2).getbool()); (par3))
00017 #endif
00018 
00019 #ifdef VGEN
00020         #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);
00021 #else
00022         #define If(par) if ((par).getbool())
00023 #endif
00024 
00025 #ifdef VGEN
00026         #define Else std::cout << glc.getmargin() << "else " << flush;  glc.enablemargin(0);
00027 #else
00028         #define Else else
00029 #endif
00030 
00031 #define begin vbegin()
00032 #ifdef VGEN
00033         #define vbegin() glc.enablemargin(1); std::cout << "\n" << glc.getmargin() << "begin\n" << flush; glc.Indent();
00034 #else
00035         #define vbegin() { glc.alwayspush();
00036 #endif
00037 
00038 #define end vend()
00039 #ifdef VGEN
00040         #define vend() glc.Outdent(); std::cout << glc.getmargin() << "end\n" << flush;
00041 #else
00042         #define vend() glc.alwayspop(); }
00043 #endif
00044 
00045 #ifdef VGEN
00046         #define always(par) std::cout << glc.getmargin() << "always @(" << (par).getorname() << ") " << flush;  glc.enablemargin(0);
00047 #else
00048         #define always(par) glc.alwaysstart(); if ((par).getchange())
00049 #endif
00050 
00051 #ifdef VGEN
00052         #define assign std::cout << glc.getmargin() << "assign " << flush; glc.enablemargin(0);
00053 #else
00054         #define assign
00055 #endif
00056 
00057 #ifdef VGEN
00058         #define deassign(par) std::cout << glc.getmargin() << "deassign " << flush; std::cout << (par).getname() << ";\n" << flush; glc.enablemargin(1);
00059 #else
00060         #define deassign(par) ;
00061 #endif
00062 
00063 #ifdef VGEN
00064         #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();
00065 #else
00066 #define begincase(par) pushswitch((par)); if (0) {}
00067 #endif
00068 
00069 #define endcase vendcase()
00070 #ifdef VGEN
00071         #define vendcase() glc.Outdent(); std::cout << glc.getmargin() << "endcase\n" << flush;
00072 #else
00073         #define vendcase() popswitch();
00074 #endif
00075 
00076 #ifdef VGEN
00077         #define case1(par)       \
00078                                                 cout << glc.getmargin(); \
00079                                                 glc.setprintassign(0); std::cout << ((Signal)(par)).getcatname(); \
00080                                                 cout << " : " << flush; glc.setprintassign(1);  glc.enablemargin(0);
00081 #else
00082         #define case1(par) else if ((getswitch() == (par)).getbool())
00083 #endif
00084 
00085 #ifdef VGEN
00086         #define case2(par1, par2) \
00087                                                 glc.setprintassign(0); \
00088                                                 cout << glc.getmargin(); \
00089                                                 glc.setprintassign(0); std::cout << ((Signal)(par1)).getcatname(); std::cout << ", "; \
00090                                                 glc.setprintassign(0); std::cout << ((Signal)(par2)).getcatname();\
00091                                                 cout << " : " << flush; glc.setprintassign(1);  glc.enablemargin(0);
00092 #else
00093         #define case2(par1, par2) else if ( (getswitch() == (par1)).getbool() || (getswitch() == (par2)).getbool())
00094 #endif
00095 
00096 #ifdef VGEN
00097         #define case3(par1, par2, par3) \
00098                                                 glc.setprintassign(0); \
00099                                                 cout << glc.getmargin(); \
00100                                                 glc.setprintassign(0); std::cout << ((Signal)(par1)).getcatname(); std::cout << ", "; \
00101                                                 glc.setprintassign(0); std::cout << ((Signal)(par2)).getcatname(); std::cout << ", "; \
00102                                                 glc.setprintassign(0); std::cout << ((Signal)(par3)).getcatname(); \
00103                                                 cout << " : " << flush; glc.setprintassign(1);  glc.enablemargin(0);
00104 #else
00105         #define case3(par1, par2, par3) else if ( (getswitch() == (par1)).getbool() || (getswitch() == (par2)).getbool() || (getswitch() == (par3)).getbool())
00106 #endif
00107 
00108 
00109 #define Default vdefault()
00110 #ifdef VGEN
00111         #define vdefault() std::cout << glc.getmargin(); std::cout << "default : " << flush;  glc.enablemargin(0);
00112 #else
00113         #define vdefault() else
00114 #endif
00115 
00116 #define beginmodule vbeginmodule();     
00117 #define endmodule vendmodule();
00118 
00119 #ifdef VGEN
00120 #define modulebody
00121 #else
00122 #define modulebody \
00123 if (glc.getpassn() != passn) \
00124 { \
00125 /*      cout << itern << " " << instname << std::endl; */\
00126         itern = 0; \
00127 } \
00128 passn = glc.getpassn(); \
00129 if (!glc.getparent()->getchange()) \
00130 { \
00131         outregn = 0; \
00132         return; \
00133 } \
00134 else \
00135 { \
00136         itern++; \
00137 }
00138 
00139 #endif
00140 
00141 #define beginfunction vbeginfunction();
00142 #define endfunction vendfunction(); return (result);
00143 
00144 #ifdef VGEN
00145 #define functionbody
00146 #else
00147 //#define functionbody if (!glc.getparent()->getchange()) {vendfunction(); return (result);} 
00148 #define functionbody
00149 #endif
00150 
00151 
00152 #if (__GNUC__==2)||defined(_MSC_VER)
00153 #define or ||
00154 #endif
00155 #define makereg this
00156 
00157 #define endperiod glc.ResetEvents();
00158 
00159 #ifdef VGEN
00160         #define comment(par) if (glc.getFileOpen()) {std::cout << glc.getmargin(); std::cout << (par) << "\n" << flush;} else glc.AddComment((string)(par));
00161 #else
00162         #define comment(par)
00163 #endif
00164 
00165 #ifdef VGEN
00166         #define printv(par) std::cout << (par) << flush;
00167 #else
00168         #define printv(par)
00169 #endif
00170 
00171 
00172 #ifdef VGEN
00173         #define initio glc.setparent(this); glc.setFileOpen(0); 
00174 #else
00175         #define initio glc.setparent(this); glc.getparent()->setchange(0);
00176 #endif
00177 
00178 // these macros are different for all possible types of initializations,
00179 // because not all compilers yet support ISO C99 variadic macros (macros with variable number of parameters)
00180 // At the moment of writing, only GNU C++ compiler supports them.
00181 #define Reg(cl)                cl.reg(#cl)
00182 #define Reg_(cl, h, l)         cl.reg(h, l, #cl)
00183 #define Reg__(cl, h, l, t, b)  cl.reg(h, l, t, b, #cl);
00184 
00185 #define Wire(cl)               cl.wire(#cl)
00186 #define Wire_(cl, h, l)        cl.wire(h, l, #cl)
00187 #define Wire__(cl, h, l, t, b)    for (int __wi__ = b; __wi__ <= t; __wi__++) cl[__wi__].wire(h, l, #cl, __wi__)
00188 
00189 #define Input(cl)              cl.input(#cl)
00190 #define Input_(cl, h, l)       cl.input(h, l, #cl)
00191 #define Clock(cl)              cl.clock(#cl)
00192 
00193 #define Output(cl)             cl.output(#cl)
00194 #define Output_(cl, h, l)      cl.output(h, l, #cl)
00195 
00196 #define OutReg(cl)             cl.output(#cl, makereg)
00197 #define OutReg_(cl, h, l)      cl.output(h, l, #cl, makereg)
00198 
00199 #define Inout(cl)              cl.inout(#cl)
00200 #define Inout_(cl, h, l)       cl.inout(h, l, #cl)
00201 
00202 #define Module(md)                         md.init(#md, #md)
00203 #define Module_(md, fn)            md.init(#md, #fn)
00204 
00205 #define cns(b,v) glc.constant(b,v)
00206 
00207 #endif
00208