summaryrefslogtreecommitdiff
path: root/rtl/core/regs/file.sv
blob: 1b1068242eb43e4d8809711b17fa577f191c2363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
`include "core/uarch.sv"

module core_reg_file
(
	input  logic     clk,
	input  reg_index rd_index,
	                 wr_index,
	input  logic     wr_enable,
	input  word      wr_value,

	output word      rd_value
);

	// Ver comentario en uarch.sv
	word file[30];

	always @(posedge clk)
		if(wr_enable)
			file[rd_index] <= wr_value;

	always @(posedge clk)
		rd_value <= wr_enable & (rd_index == wr_index) ? wr_value : file[rd_index];

endmodule