I want to write or of ifdef
I have tried 2 possible ways as below :
- `ifdef (A || B)
- `ifdef (A or B)
- `ifdef A || B
ifdef A ||
ifdef B
Can you please suggest how can I do oring of ifdef?
Thanks in advance
Regards
I want to write or of ifdef
I have tried 2 possible ways as below :
ifdef A ||
ifdef BCan you please suggest how can I do oring of ifdef?
Thanks in advance
Regards
`ifdef A
`define AorB
`elsif B
`define AorB
`endif
`idfef AorB
...
`endif
You would nest the `ifdef to define AandB
module temp;
initial begin
`ifdef FULL_RATE
$display("I am in full rate");
`endif
`ifdef HALF_RATE or QURD_RATE
$display("I am in else part");
`endif
end
endmodule
Here I am passing define [FULL_RATE or HALF_RATE or QUAD_RATE] through command line argument.
Now above mentioned line
`ifdef HALF_RATE or QURD_RATE
giving us compilation error as below
– Compiling module temp
** Error: temp.sv(7): near “or”: syntax error, unexpected or
Our requirement :
when we pass HALF_RATE or QUAD_RATE same piece of code should get execute.
In reply to Niyati:
I already answered your question.
Replace A with HALF_RATE, B with QUAD_RATE, and AorB with HALForQUAD_RATE
In reply to dave_59:
But
`ifdef HALF_RATE or QURD_RATE
giving us compilation error as below
– Compiling module temp
** Error: temp.sv(7): near “or”: syntax error, unexpected or
In reply to Niyati:
module temp;
initial begin
`ifdef FULL_RATE
$display("I am in full rate");
`endif
`ifdef HALF_RATE
`define HALForQUAD_RATE
`elsif QUAD_RATE
`define HALForQUAD_RATE
`endif
`ifdef HALForQUAD_RATE
$display("I am in else part");
`endif
end
endmodule
In reply to dave_59:
`ifdef A
`define AorB
`elsif B
`define AorB
`endif
`idfef AorB
...
`endif
You would nest the `ifdef to define AandB
So you mean, we need to replicate the code twice? :(((
Isn’t there any shortcut available?
In reply to 1978bubun:
There is no replication of SV code, just the `define AorB.