Author Topic: In Verilog, is it possible to define XXX only if a parameter is set?  (Read 1052 times)

0 Members and 1 Guest are viewing this topic.

Offline BrianHGTopic starter

  • Super Contributor
  • ***
  • Posts: 7738
  • Country: ca
In Verilog, is it possible to define XXX only if a parameter is set?

I have a bunch of portions of my code where I include or exclude using `ifdef XXXX, `else XXXX, endif.

However, instead of globally `define XXXX, for each instance of my module, I wish for that `define to be turned on or off based on a parameter.  Is there a way to do this?
 

Offline cruff

  • Regular Contributor
  • *
  • Posts: 70
  • Country: us
Re: In Verilog, is it possible to define XXX only if a parameter is set?
« Reply #1 on: August 16, 2022, 12:43:33 pm »
Not sure what you need to accomplish, but can you just use a regular parameter and use if statements within a generate block and test for parameter equal to zero or not?
 

Offline BrianHGTopic starter

  • Super Contributor
  • ***
  • Posts: 7738
  • Country: ca
Re: In Verilog, is it possible to define XXX only if a parameter is set?
« Reply #2 on: August 16, 2022, 01:07:24 pm »
That will only work for code I have inside the 'generate' & 'endgenerate'.
I have too may little snipets of code all over the place which are either there or not there depending on the option of the `define.
I'll stick with the good old `define for now unless I want to re-engineer the code.

My other choice is to have 2 version of the module, 1 with the enhanced features, one with the vanilla layer.
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4427
  • Country: dk
Re: In Verilog, is it possible to define XXX only if a parameter is set?
« Reply #3 on: August 16, 2022, 01:26:15 pm »
That will only work for code I have inside the 'generate' & 'endgenerate'.
I have too may little snipets of code all over the place which are either there or not there depending on the option of the `define.
I'll stick with the good old `define for now unless I want to re-engineer the code.

My other choice is to have 2 version of the module, 1 with the enhanced features, one with the vanilla layer.

make a file that contains `define XXXX use generate and param to conditionally include that file where you need it?
 

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 2501
  • Country: us
  • Yes, I do this for a living
Re: In Verilog, is it possible to define XXX only if a parameter is set?
« Reply #4 on: August 16, 2022, 02:40:32 pm »

My other choice is to have 2 version of the module, 1 with the enhanced features, one with the vanilla layer.

With VHDL, you could create two (or more) architectures for one entity, and select which one is used with a generic or a configuration. Just sayin'.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf