Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Verilog: How to parameterize the module's name

Status
Not open for further replies.

redolution

Newbie level 2
Newbie level 2
Joined
Dec 12, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
16
In the testbench, what I tried to do is

module_name=adder;

module_name
module_name_0(...port-mapping...);

By doing this, every time I can just change the module_name, then the dut is done automatically, i.e., if module_name=adder, then the testbench will test adder, if module_name=divider then the testbench will test divider.

I've tried parameter and 'define, all didn't work. Please help!

Thank you!
 

It's very unusual that different module instantiations have identical port maps and can be driven by the same test bench, in so far the problem will rarely occur in regular Verilog projects.

But if it's the case with your project, what's so awful with writing complete module instantiations and selecting one or the other, e.g. by `ifdef macros?
 

In the testbench, what I tried to do is

module_name=adder;

module_name
module_name_0(...port-mapping...);

By doing this, every time I can just change the module_name, then the dut is done automatically, i.e., if module_name=adder, then the testbench will test adder, if module_name=divider then the testbench will test divider.

I've tried parameter and 'define, all didn't work. Please help!

Thank you!

What you are trying to do is not supported in the language definition, therefore it's illegal to do what you are trying to do. Maybe you should spend time reading the LRM.
 

In SystemVerilog, you can do

Code:
`define TEST(name) test_``name

`define MODULE_NAME adder


`TEST(MODULE_NAME)

which will expand to test_adder.
 
  • Like
Reactions: ads-ee

    ads-ee

    Points: 2
    Helpful Answer Positive Rating
Nice to know that, but as I've almost never been able to use SV due to lack of support in the tools I use, I've never gone through the latest LRM that thoroughly.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top