icicle/rv32_regs.sv
Graham Edgecombe 22bce1bdeb Fix compatibility with iverilog
This commit:

 * changes the type of all output variables to logic
 * splits variable declaration and assignment
 * declares variables before modules that use the variables
2017-12-09 21:03:45 +00:00

34 lines
651 B
Systemverilog

`ifndef RV32_REGS
`define RV32_REGS
module rv32_regs (
input clk,
input stall_in,
/* control in */
input [4:0] rs1_in,
input [4:0] rs2_in,
input [4:0] rd_in,
input rd_write_in,
/* data in */
input [31:0] rd_value_in,
/* data out */
output logic [31:0] rs1_value_out,
output logic [31:0] rs2_value_out
);
logic [31:0] regs [31:0];
always_ff @(posedge clk) begin
if (!stall_in) begin
rs1_value_out <= regs[rs1_in];
rs2_value_out <= regs[rs2_in];
end
if (rd_write_in && |rd_in)
regs[rd_in] <= rd_value_in;
end
endmodule
`endif