rsrinivas
Advanced Member level 1
- Joined
- Oct 10, 2006
- Messages
- 411
- Helped
- 50
- Reputation
- 100
- Reaction score
- 11
- Trophy points
- 1,298
- Location
- bengalooru
- Activity points
- 3,689
hi all
i have built a register file which has to initialize to zero on reset.
say an array of 16 registers which are 64 bits wide each.
howdo i initialize them on reset.
module regfil1(clk,rst,addrread,addrwrite,din, writep, readp, dout);
input clk;
input rst;
input [63:0] din;
input readp;
input writep;
input [4:0] addrread;
input [4:0] addrwrite;
output [63:0] dout;
parameter MAX_COUNT = 5'b01111; // topmost address in register file.
reg signed [63:0] dout;
always @(posedge clk) //problem here works only on posedge clk
begin : rst_blk
integer i;
if(rst)
for(i=0;i<=MAX_COUNT;i = i+1)
begin
regbank <= 64'h0000000000000000;
end
else if (writep == 1'b1) begin
regbank[addrwrite] <= din;
end
end
always @(posedge clk)
begin
if(readp == 1'b1 && !rst) begin
dout <= regbank[addrread];
end
end
endmodule
it works only on posedge clk, does the for loop work on each posedge clk or is concurrent i.e at a posedge clk the whole of for loop is executed
any alterations or suggestions pls
i have built a register file which has to initialize to zero on reset.
say an array of 16 registers which are 64 bits wide each.
howdo i initialize them on reset.
module regfil1(clk,rst,addrread,addrwrite,din, writep, readp, dout);
input clk;
input rst;
input [63:0] din;
input readp;
input writep;
input [4:0] addrread;
input [4:0] addrwrite;
output [63:0] dout;
parameter MAX_COUNT = 5'b01111; // topmost address in register file.
reg signed [63:0] dout;
always @(posedge clk) //problem here works only on posedge clk
begin : rst_blk
integer i;
if(rst)
for(i=0;i<=MAX_COUNT;i = i+1)
begin
regbank <= 64'h0000000000000000;
end
else if (writep == 1'b1) begin
regbank[addrwrite] <= din;
end
end
always @(posedge clk)
begin
if(readp == 1'b1 && !rst) begin
dout <= regbank[addrread];
end
end
endmodule
it works only on posedge clk, does the for loop work on each posedge clk or is concurrent i.e at a posedge clk the whole of for loop is executed
any alterations or suggestions pls