define usage in verilog and Macro

`define is very useful in verilog and here are some examples for that which will be useful to debug and develop smart macros.

  • Simple usage of define is with ifdef and ifndef as shown . pass with compilation as  +define+XYZ

`ifdef XYZ




  • Define with some value associated with it.


  • Defines used as macros for repetitive code.

`define ABC(num) \

num :  abc =  xyz_“num“; 

Use in code as follows



num is integer argument passed , and to append it to string “num“ is used.

same way a string argument also can be appended.

`define ABC(string) 

  abc =  reg_“string“; 




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s