Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21607 Discussions

Can conditional builds be performed in VHDL?

Altera_Forum
Honored Contributor II
2,578 Views

I'm relatively new to VHDL and am looking for a way to perform conditional builds. I'm aware of the `ifdef that is available in Verilog, but am trying to find a comperable method in VHDL.

0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
1,105 Views

Depending on what you are doing perhaps the "generate" statement can help.

0 Kudos
Altera_Forum
Honored Contributor II
1,105 Views

I think a combination of generic parameters and the generate statement should do the job.

0 Kudos
Altera_Forum
Honored Contributor II
1,105 Views

I just tried a test case using the generate statement and generic parameter. That 

looks like it will do what I need. Thanks for the tip.
0 Kudos
Altera_Forum
Honored Contributor II
1,105 Views

Hi wolson, 

 

As I am a quite lazy, each time I have a repetitive structure to implement, I use the FOR-GENERATE statement (I am rather keen on coding with AHDL instead of VHDL but it's very similar). 

That works well nevertheless when it comes to use the PARAMETER statement (to parameterize a port size for instance), I do have some trouble to pass the parameters down along the project hierarchy (from the top-level entity to lower level entities). 

 

The "parameter value search order " section given in the Qts II help is a bit confusing so I was wondering whether you experienced a similar problem (I'm often use the PARAMETER statement in BDFs) ? ... 

 

Thanks. 

 

 

Oliver
0 Kudos
Altera_Forum
Honored Contributor II
1,105 Views

Oliver: 

 

I'm not familiar with AHDL, but I suspect that the "PARAMETER" statement you refer to 

is the same as VHDL's "generic". I've used that before, but for parameterizing between 

two levels only. I suspect that there would need to be a precedence rule when passing 

a parameter between multiple levels. 

 

In the case of my recent experiment with generic/generate, I used that to cut down on 

editing between simulation vs. system build versions. The previous engineer for this 

project would comment out and uncomment portions of code each time. I modified 

the lower level entity with a generic to default as a simulation version by generating 

it's own signals normally passed in on input ports from the higher level entity. The 

higher level entity that instantiates the lower overrides the lower level entities’ 

generic default by passing in a value to use the system build version of code.
0 Kudos
Reply