module test;
bit [7:0] a = 8'hFF;
bit en = 1;
initial begin
a = en? {(a+1)}[7:0]:0;
end
endmodule
What is meant by {(a+1)} [7:0] ?
What is the difference between the following statements:
a = en? {(a+1)}[7:0]:0;
a = en?(a+1):0;
module test;
bit [7:0] a = 8'hFF;
bit en = 1;
initial begin
a = en? {(a+1)}[7:0]:0;
end
endmodule
What is meant by {(a+1)} [7:0] ?
What is the difference between the following statements:
a = en? {(a+1)}[7:0]:0;
a = en?(a+1):0;
In reply to Asraful_21:
{expression} [range]
Is a part select of a concatenation. In your example, it is selecting the 8-bit LSB of the result of the addition of (a+1). The result of the addition is 32’h0000000000000100, so the lower 8-bits would be 8’h00. There is no difference in behavior for the example you gave because the result of the conditional ?: operator is going to get truncated anyways.
There would be a difference if you had
a = en? {(a+1)} >> 1 : 0; // results in 8'h80
a = en? {(a+1)}[7:0] >> 1 : 0; // results in 8'h00