What is the difference between define and parameter ??

Status
Not open for further replies.

choonlle

Full Member level 2
Joined
Jul 18, 2006
Messages
126
Helped
20
Reputation
40
Reaction score
1
Trophy points
1,298
Location
AFRICA
Activity points
2,025
`define & parameter

What is the different between define and parameter ??



When we must use define ? otherwise parameter ?
 

Re: `define & parameter

Hi,

`define :
`define is a macro substitution like you #define in C language.
This defines a text macro that will be substituted wherever it occurs. Like
`define NPN npn_transistor will replace all `NPN with npn_transistor.
It is a text macro substitution.

parameter
parameter is used to define a constant whose value doesnot change during runtime.
So once you define a parameter it remains constant. The difference here is that this is a value substitution and it can be used for module instantiations as a changing value.
i.e. For each instantiation you can have a parameter value based on defparam definition.

parameter d = 5
# d;
a <= d;
this puts 5 in a after 5 simulation time.

Thats it. for further reference the LRM file for verilog. You can find the syntax and usage in it.
 

    choonlle

    Points: 2
    Helpful Answer Positive Rating
Re: `define & parameter

`define is gobal set!
parameter is local
 
Reactions: dkslc

    dkslc

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…