I'm trying to compile a code similar to this:
`define CORES_NUM 4
reg [1:0] core = 'h0;
reg [`CORES_NUM-1:0] result = 'h0;
integer i;
always @ (posedge clk) begin
case (core)
for (i = 0; i < `CORES_NUM; i = i + 1) begin
i: begin
result[i] <= 1;
end
end
endcase
end
Only one core is active at the moment. I expect that my code is equal to that:
case (core)
0: begin
result[0] <= 1;
end
1: begin
result[1] <= 1;
end
2: begin
result[2] <= 1;
end
3: begin
result[3] <= 1;
end
endcase
In other words, I need 'for loop' only for auto setting - if I change CORES_NUM, case states are automatically changed. But my code builds with errors. How can I use for loop in case statement?