-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregfile.v
More file actions
40 lines (37 loc) · 959 Bytes
/
regfile.v
File metadata and controls
40 lines (37 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 12/28/2023 09:56:49 PM
// Design Name:
// Module Name: regfile
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module regfile(
input clk,
input we3,
input [4:0] ra1,ra2,wa3,
input [31:0] wd3,
output [31:0] rd1,rd2
);
reg [31:0] rf[31:0];
//3 port register file
//read 2 ports combnationaly
//write thried port on rising edge
//register 0 is always zero
always@(posedge clk)
if(we3) rf[wa3]<=wd3;
assign rd1=(ra1 !=0)? rf[ra1]:0;
assign rd2=(ra2 !=0)? rf[ra2]:0;
endmodule