I need to use a 2D array for a coordinate system in a module, and I've created the test code below to test creating and accessing values in the array. This code should turn on an LED led output when the led output is 1'b1, but currently the LED stays off (I've troubleshooted all other code besides the 2D array stuff, it works when I use a 1D array here).
input clk;
reg [7:0] check[9:0];
reg ledreg;
output led;
initial begin
check[0][0] = 1'b1;
ledreg = 1'b0;
end
always @(posedge clk) begin
if (check[0][0] == 1'b1) begin
ledreg = 1'b1;
end
end
assign led = ledreg;
I'm not sure if my array initialization syntax is off reg [7:0] check[9:0] or the value checking syntax is off check[0][0] == 1'b1, or if this is a SystemVerilog feature that doesn't work with just Verilog (I don't have SystemVerilog but this code compiles without error, so I don't think that's it).
How do I check a value in a 2D array so that I can do things when it has a certain value?
clktogging in your code? please make sure that it does. Also, please use non-blocking assignment<=in the posedge logic.