08-19-2021 05:04 AM
I want a piece of code executed when the conditional variable is set to a random natural number. There is no other way than to use the Default tag for that as the Condition allows only for == and !=.
I also want this code NOT to execute when this variable is set to 0 or UNSET. Can I do that somehow? I tried comparing with FALSE, null, 0, undefined, nothing works.
Vit
08-19-2021 06:01 AM
Hi Thomas,
@Thomas444 wrote:
I want a piece of code executed when the conditional variable is set to a random natural number. There is no other way than to use the Default tag for that as the Condition allows only for == and !=.
Do you need to use a conditional "variable" in your use case? Especially when the conditional item can have "random" values!?
Why not use an ordinary case structure?
@Thomas444 wrote:
I also want this code NOT to execute when this variable is set to 0 or UNSET. Can I do that somehow? I tried comparing with FALSE, null, 0, undefined, nothing works.
What do you mean by "nothing works"? Is your code executed when you compare your conditional item with "0"?
Again: why not use an ordinary case structure?
Why are you using the conditional disable structure at all?
08-19-2021 09:15 AM
The question is quite general so I didn't feel like getting into details.
So I have this FPGA application with different C series module types and I want to implement a piece of code only when certain modules of given type are used. It can be like 3x 9232s and 2x 9421s, up to 8 modules for cRIO 9057. I use conditional disables for counting the modules because it's quite neat (I just change it in one place and it gets implemented through the code) but I have to specify either:
or:
The second approach is straightforward, but when the conditional symbol is undefined, the default case is selected here. Does the undefined symbol always fall in the default case, or does it have some value i can use to trigger such state? Basically I would like to make constant = 0 and undefined constant the same meaning.
08-19-2021 09:26 AM
In general a conditional disable structure is kind of like an ifdef which tells the compiler to ignore disabled code. In your case some interfaces to modules may not allow compilation if the modules are not present.
If that isn't an issue you can go with a case structure which is like a switch or if/then/else statement.
08-19-2021 02:00 PM
Hi Thomas,
@Thomas444 wrote:
The second approach is straightforward, but when the conditional symbol is undefined, the default case is selected here. Does the undefined symbol always fall in the default case, or does it have some value i can use to trigger such state? Basically I would like to make constant = 0 and undefined constant the same meaning.
When the symbol is undefined then it's value is not "==0". So the default case of the CDS is selected…
What's the problem in setting the symbol to "0"?
@Thomas444 wrote:
The question is quite general so I didn't feel like getting into details.
It really helps to know about the reason for your question!
I understand you want to reduce fabric usage on FPGA whenever possible, and using the CDS to react on the installed modules sounds like a good idea!
That's why I was insiting on using plain case structures: on modern computers available RAM most often isn't a problem aymore…
08-20-2021 02:43 AM
What's the problem in setting the symbol to "0"?
I just end up having bunch of conditional disable symbols which have to be set up with every target I have in my project. But I recently found out that CDSes can be set up programatically so I probably could make a script for that.