-
Notifications
You must be signed in to change notification settings - Fork 1
/
register_file.v
71 lines (62 loc) · 1.15 KB
/
register_file.v
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 09/28/2017 12:03:13 AM
// Design Name:
// Module Name: register_file
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module register_file
(
clk, //clock
raddr0,
rdata0,
raddr1,
rdata1,
waddr,
wdata,
wren
);
//Input Ports
input clk;
input [4:0] raddr0;
input [4:0] raddr1;
input [4:0] waddr;
input [31:0] wdata;
input wren;
//Output Ports
output [31:0] rdata0;
output [31:0] rdata1;
// Signal Declarations: reg
reg [31:0] reg_file [31:0];
// Combinational Logic
assign rdata0 = reg_file[raddr0];
assign rdata1 = reg_file[raddr1];
// Sequential Logic
integer i;
initial
begin
for(i = 0; i < 32; i = i+1)
begin
reg_file[i] = 0;
end
end
always @(posedge clk)
begin
if (wren) begin
reg_file[waddr] <= wdata;
end
end
endmodule