cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
7,356 Views
Registered: ‎08-02-2014

Use of variables in generate loops

Hello folks,

 

I am working with Spratan 3AN device for implementing the memory register space.

 

I have a 2d array from 0 to 31 with the size of 8 bits wide. I need to write and read from the register space ,

The value pointed by the address starting from 8'h10 should write to the memory array starting with the index 0.

 

//For Writing to the Register Space

 

genvar i;
generate
for (i = 10 ; i < (32 + 10) ; i = i + 1)
begin:
always @ (posedge clk or negedge reset)
begin
if (reset == 1'b0)
reg_bank[i-3] <= 'd0;
else if (wr_en == 1 && (addr >= 8'h10 && addr <= 8'h42) && (addr == i)) ;
begin
reg_bank[addr- 10] <= data_in;
end
end
end
endgenerate

 

-----> When I tried to write the value to the address from 8'h10, the data is getting written into the array (reg bank) of index (16-10), i.e, to the 6th location.

 

So, that seems to be unclear to me.

 

Please let me know, if anybody have accross the problem before.

 

 

 

0 Kudos
0 Replies