yupina-chan
Member level 2
hi. i have a question on using for loop.
for example, i have an 'always block' then i use for loop inside like this one:
1. will it take 256 clock cycles for the ram to be filled with 8'b00001011? or it only takes one posedge clk?
2. i initialized my ram with zeros using for loop before the always block. is this the right thing to do, like it can be synthesized well in the real board implementation?
3. also, my process needs to restore the values inside a certain process? can i use for?
3. what's the best way of coding my code above?
for example, i have an 'always block' then i use for loop inside like this one:
Code:
integer i;
integer count = 0;
reg [7:0] ram [255:0];
initial begin
for (i=0; i<256; i+1)
ram[i]=0;
end
always @(posedge clk)begin
count <= count + 1;
if(count == 5) //condition to restore ram contents
for (i=0; i<256; i+ 1)
ram[i]<=0;
else // fill ram with 8'b00001011
for (i=0; i<256; i+ 1)
ram[i]<=8'b00001011;
end
1. will it take 256 clock cycles for the ram to be filled with 8'b00001011? or it only takes one posedge clk?
2. i initialized my ram with zeros using for loop before the always block. is this the right thing to do, like it can be synthesized well in the real board implementation?
3. also, my process needs to restore the values inside a certain process? can i use for?
3. what's the best way of coding my code above?