Skip to content

Commit

Permalink
i have to define the integer i outside the always block.
Browse files Browse the repository at this point in the history
Variable declaration in unnamed block requires SystemVerilog.
  • Loading branch information
KavinduMethpura committed Dec 30, 2024
1 parent c918b04 commit 05c90f2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
File renamed without changes.
Empty file removed Registers/RegFileTest.v
Empty file.
6 changes: 4 additions & 2 deletions Registers/RegFile.v → Registers/RegisterFile.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module RegisterFile (
// Register array (32 registers of 32 bits)
reg [31:0] registers [31:0];

// Declare loop variable outside the procedural block for Verilog compatibility
integer i;

// Read logic
assign readData1 = (readReg1 != 0) ? registers[readReg1] : 32'b0; // R0 is always 0
assign readData2 = (readReg2 != 0) ? registers[readReg2] : 32'b0;
Expand All @@ -21,7 +24,6 @@ module RegisterFile (
always @(posedge clk or posedge rst) begin
if (rst) begin
// Reset all registers to 0
integer i;
for (i = 0; i < 32; i = i + 1) begin
registers[i] <= 32'b0;
end
Expand All @@ -31,4 +33,4 @@ module RegisterFile (
end
end

endmodule
endmodule

0 comments on commit 05c90f2

Please sign in to comment.