Forum Discussion
Altera_Forum
Honored Contributor
15 years ago --- Quote Start --- Hey all; I'm trien to write a loop in verilog to initialize all the entries in an array of 128 to a value of zero, and I'm having the following error: procedural continuous assignment to register is not supported ==================================== here is my code :: ==================================== // Instruction Memory module imem(clk, reset, wr_enable,fetch_enable, mem_out, address, mem_in); input clk; input reset; input wr_enable; input fetch_enable; // this will control startin or stopin running stored commands input [4:0] address; output [31:0]mem_out; input [31:0]mem_in; reg [31 :0]mem_out; reg [31 :0]array_reg[127:0]; //can save 128 instruction integer i; initial while(i< 128) begin assign i = i+1; mem_out<= 32'hfffff;
end
always @(posedge clk)
begin
if(fetch_enable)
begin
if (reset)
begin
mem_out <= 32'd0;
end
else
if(!wr_enable)
begin
mem_out <= array_reg[address];
end
else
array_reg[address] <= mem_in;
end
end
endmodule
===================================
thaanks in advance :)
--- quote end ---
hi,
you are using the assign statement with an integer. that's not allowed.
assign i = i+1 --> change to i = i + 1;
do really want to initialize "mem_out". "mem_out" is already set to a defined state
with the reset signal.
in case you would like to init your ram "array_reg" change your code to :
integer i;
integer p;
initial
begin
i = i+1;
p = 128;
for (i=0; i<p; i=i+1)
array_reg<= 32'hffffffff; end Using "while" is not recommended. Have a look into the "db" folder. You will find a so-called <>.mif file. Look into the file and you could see the init values for the ram. Kind regards GPK