- Using SystemVerilog Assertions for Functional Coverage
- Using SystemVerilog Assertions for Creating Property-Based Checkers
- SystemVerilog Assertions Design Tricks and SVA Bind Files
- VMM and especially VMM data macro
Ans : Web (thanks to the all powerful demi-god of internet ... Google)
- http://www.google.co.in/#hl=en&safe=off&q=Systemverilog+Macro
- System Verilog LRM 3.1a : Section : 25.2
- Sandeep Vaniya's Advanced Use of define macro in SystemVerilog (not so advanced actually !!!)
// Example macro for a coverage class // Aim : want to get ABC_cp : coverpoint ABC {bins b = {1}; } // by calling `COV(ABC) `define COV(__name) __name``_cp : coverpoint __name {bins b = {1}; } // Next // What to do if I want cp_ABC in place of ABC_cp as for the above example // NOTE : I can't use cp_``__name as cp_ is not an input to the macro // Solution // Use nested macros `define PREFIX(__prefix, __name) __prefix``__name `define COV2(__name) `PREFIX(cp_,__name) : coverpoint __name {bins b = {1}; }Nested macro is not a new thing in SV. They are being extensively used in VMM data macro class. But no example of nested macro and achieving of addition pre_fix to variable name in `define macro is bit puzzling to me. I tried the above in vcs and seems to work perfectly fine.
Next, where not to use `define (SV other better alternatives to `define these cases)
Can I have a prefix and a suffix?
ReplyDeletee.g. to cover individual bits of a register, I might normally have:
covergroup cgMyReg0OnWrite @(Trigger);
cpToggleReg0Bit0 : coverpoint MyReg0[0];
cpToggleReg0Bit1 : coverpoint MyReg0[1];
cpToggleReg0Bit2 : coverpoint MyReg0[2];
cpToggleReg0Bit3 : coverpoint MyReg0[3];
endgroup
Repeat ad nauseum for MyReg1, MyReg2, MyReg3 etc.
I'd like to just write `REG_CG(Reg0) to expand to the group above. The following doesn't work:
`define REG_CG(Name) \
covergroup `PREFIX(cgMy, Name)``OnWrite @(Trigger); \
`PREFIX(cpToggle, Name``Bit0) : coverpoint `PREFIX(My, Name)``[0]; \
`PREFIX(cpToggle, Name``Bit1) : coverpoint `PREFIX(My, Name)``[1]; \
`PREFIX(cpToggle, Name``Bit2) : coverpoint `PREFIX(My, Name)``[2]; \
`PREFIX(cpToggle, Name``Bit3) : coverpoint `PREFIX(My, Name)``[3]; \
endgroup
In such situation I would have done this
ReplyDelete`define JOIN(__prefix,__name,__postfix) __prefix``__nanme``__posfix
`define REG_CG(__Name) \
covergroup `JOIN(cgMy,__Name,OnWrite) @(Trigger); \
`JOIN(cpToggle,__Name,Bit0) : coverpoint `JOIN(My,__Name,[0]); \
`JOIN(cpToggle,__Name,Bit1) : coverpoint `JOIN(My,__Name,[1]); \
`JOIN(cpToggle,__Name,Bit2) : coverpoint `JOIN(My,__Name,[2]); \
`JOIN(cpToggle,__Name,Bit3) : coverpoint `JOIN(My,__Name,[3]); \
endgroup
In my case i define the top level path for RTL as a macro whose value is passed from command line.
ReplyDeletei need to use that value to pass to a string variable. for example
`define TOP x.y
string F;
F="`TOP.a";
how would this look like ?