RegisterLogin  
Update Profile
   
You are here: Forum  
Minimize 
SVUG Community Forum
Subject: Advanced Use of define macro in SystemVerilog
Prev Next
You are not authorized to post a reply.

Author Messages
SandeepUser is Offline

Posts:2

04/23/2008 5:52 AM  
Hi,

Following is the excerpt from SystemVerilog LRM about important features of define macro.

1. In Verilog, the ‘define macro text can include a backslash ( \ ) at the end of a line to show continuation on the next line.

2. In SystemVerilog, the macro text can also include `", `\`" and ``.

An `" overrides the usual lexical meaning of ", and indicates that the expansion should include an actual quotation mark. This allows string literals to be constructed from macro arguments.
A `\`" indicates that the expansion should include the escape sequence \", e.g.

`define msg(x,y) `"x: `\`"y`\`"`"
This expands:
$display(`msg(left side,right side));
to:
$display("left side: \"right side\"");


3. A `` delimits lexical tokens without introducing white space, allowing identifiers to be constructed from arguments,

`define foo(f) f``_suffix
This expands:
`foo(bar)
to:
bar_suffix


Using these three simple features you can create generic/reusable components in SystemVerilog. Synopsys has widely used these features in their vmm for SystemVerilog library. Recall `channel, `atomic_gen and `scenario_gen macros of vmm.

To know details of Advanced use of these features and how it is used in VMM, please read this article.

Thanks,
Sandeep
You are not authorized to post a reply.
Forums > General Discussion > Main Discussion Area > Advanced Use of define macro in SystemVerilog



ActiveForums 3.7
  

 Copyright 2008 by SystemVerilog User Group Contact Us    Privacy Statement