I need to write 4 bytes from input pins to different parts of a register depending on a counter, with the code i have now I get this error:
Error (10734): Verilog HDL error at m.v(156): cnt is not a constant
How should I deal with it?
wire wren, rst;
wire [3:0] abcd;
reg [31:0] my_reg;
reg [3:0] cnt;
always @(posedge wren or posedge rst)
begin
if (rst == 1)
begin
my_reg <= 0;
end
else
begin
if (wren == 1)
begin
my_reg [4*cnt+3:4*cnt] <= abcd;
end
end
end