Passing parameter to `include file

The favorite HDL language in North America

Passing parameter to `include file

Postby ericew » Tue May 10, 2011 1:40 am

Hi,

I would like to pass a parameter to the `include file. The following is my codes

`define HIER testbench.module_1.shift_register.register_bank
parameter TOTAL_ADDR_WIDTH = 43;
`include "../tb/self_check.v"
`undef HIER

`define HIER testbench.module_2.shift_register.register_bank
parameter TOTAL_ADDR_WIDTH = 59;
`include "../tb/self_check.v"
`undef HIER

`define HIER testbench.module_3.shift_register.register_bank
parameter TOTAL_ADDR_WIDTH = 67;
`include "../tb/self_check.v"
`undef HIER

This looks definitely ok but only when i do it once. But if I do it more than once, how do I pass the parameter to the `include file? Defining same parameter for several times will give compilation error.
Btw, I need to stick to the parameter name as TOTAL_ADDR_WIDTH as I would like to reuse the self_check.v.

Question:
1. Is this the correct way of doing it? (reusing the self_check.v in such way)
2. What is the proper way of passing the parameter to the `include file in the case showing above? What exactly syntax I should use?

Thanks!
ericew
 
Posts: 1
Joined: Tue May 10, 2011 12:34 am

Return to Verilog HDL