Consider the following Verilog code.
parameter C_SUB_WIDTH = 2;
parameter C_SUB_HEIGHT = 2;
parameter BIT_DEPTH = 12;
reg [5:0] single_block_width;
always @ (*) begin
if(BIT_DEPTH == 8) begin
case({C_SUB_HEIGHT == 1, C_SUB_WIDTH == 1})
2'b00: single_block_width = 6'd16;
2'b10: single_block_width = 6'd16;
2'b11: single_block_width = 6'd24;
default:single_block_width = 6'dx;
endcase
end
else if(BIT_DEPTH == 10) begin
case({C_SUB_HEIGHT == 1, C_SUB_WIDTH == 1})
2'b00: single_block_width = 6'd16;
2'b10: single_block_width = 6'd24;
2'b11: single_block_width = 6'd32;
default:single_block_width = 6'dx;
endcase
end
else if(BIT_DEPTH == 12) begin
case({C_SUB_HEIGHT == 1, C_SUB_WIDTH == 1})
2'b00: single_block_width = 6'd24;
2'b10: single_block_width = 6'd24;
2'b11: single_block_width = 6'd40;
default:single_block_width = 6'dx;
endcase
end
else begin
single_block_width = 6'dx;
end
end
Since C_SUB_WIDTH, C_SUB_HEIGHT and BIT_DEPTH are all parameters, would this make single_block_width, a parameter too?
If not, then how can I make single_block_width a parameter and set its' value based on above mentioned parameters?
I am using Xilinx Vivado to synthesize the above code. (Its has to be able to synthesize)
Thank you.
always @(*)with only parameters in the always block. Since the parameters never change, there is nothing for the block to be sensitive to, and the block never executes. SystemVerilog solves this with thealways_combconstruct which guarantees that it will execute the block at least once during time 0.