0 votes
in Verilog by (220 points)

What is define in Verilog and how do I use it?

2 Answers

0 votes
by (240 points)

Define is the preprocessor directive. It creates a macro for text substitution. This directive can be used both inside and outside module definitions. I usually define it in Verilog header files. After a text macro is defined, it can be used in the source description by using the (`) character, followed by the macro name.I use it to configure modules by using it directly in module specifications or by assigning it to module parameters. I'm comfortable to use verilog header files for this purpose because I can sort macros in regards to its types or meaning, and as a result ti is simple to change a configuration by switching header files and/or changing the macro in a convenient dedicated place.

packet_info_vector_o[i].packet_info.size_in_bytes <= 2+`BAUD_RATE_SIZE/8;

audio_extractor #(
) audio_extractor_inst_0 (
, .nrst_i(nrst)
, .clr_i(clr)
, .biphase_decoded_data_i(biphase_decoded_data[0])
, .audio_channels_o(audio_channels_0)
, .user_data_o(user_data_0)
, .channel_status_o(channel_status_0)
0 votes
by (200 points)

This is a macro in verilog that will substitute the text with a code. This is like parameters. For example( 'define Chunk_size 8). After defining this anywhre in the code Chunksize will be interpreted as 8.

Hardware Coder Community

© 2022 by Hardware Coder. User contributions are licensed under cc by-sa 4.0 with attribution required. Attribution means a link to the question, answer, user, etc on this site.

This site is owned and operated by Hardware Coder in McKinney, Texas.

Send Us A Message
About Us

By using this site, you agree to the following:

Privacy Policy
Terms and Conditions
DMCA Policy
Earnings Disclaimer
Legal Disclaimer