D
Daku
Guest
Could some verilog guru please help me ? I am using ICarus Verilog
0.9.1. Using a very simple program, I am trying to assign to and read
from integer arrays. I declare this array as integer 'indexArray[0:MAX
-1];'
In the 'initial' block, I set all array elements to 0, and then inside
an 'always' block, I try to re-assign certain array elements,
depending on certain conditions. This fails. There are no compilation
errors.
Any suggestions, help would be greatly appreciated. Thanks in advance
for your help. The source code file contents are attached for
reference:
module arraytb;
parameter MAX = 10;
reg clock;
integer indexArray[0:MAX-1];
integer i;
integer j;
integer num;
initial
begin
$dumpfile("arraytb.vcd");
$dumpvars(1, arraytb);
clock = 1;
num = 0;
j = 0;
for(i = 0; i < MAX-1; i = i+1) indexArray = 0;
#100 $finish;
end
always
begin
#5 clock = !clock;
end
always @ (posedge clock)
begin
if(num < MAX)
$display("clock= %b num = %d j = %d array value=%d\n", clock,
num, j, indexArray[j]);
indexArray[j] = 1; //Does not work !!!
j = j+1;
num = num + 1;
end
endmodule
0.9.1. Using a very simple program, I am trying to assign to and read
from integer arrays. I declare this array as integer 'indexArray[0:MAX
-1];'
In the 'initial' block, I set all array elements to 0, and then inside
an 'always' block, I try to re-assign certain array elements,
depending on certain conditions. This fails. There are no compilation
errors.
Any suggestions, help would be greatly appreciated. Thanks in advance
for your help. The source code file contents are attached for
reference:
module arraytb;
parameter MAX = 10;
reg clock;
integer indexArray[0:MAX-1];
integer i;
integer j;
integer num;
initial
begin
$dumpfile("arraytb.vcd");
$dumpvars(1, arraytb);
clock = 1;
num = 0;
j = 0;
for(i = 0; i < MAX-1; i = i+1) indexArray = 0;
#100 $finish;
end
always
begin
#5 clock = !clock;
end
always @ (posedge clock)
begin
if(num < MAX)
$display("clock= %b num = %d j = %d array value=%d\n", clock,
num, j, indexArray[j]);
indexArray[j] = 1; //Does not work !!!
j = j+1;
num = num + 1;
end
endmodule