-
Notifications
You must be signed in to change notification settings - Fork 0
/
reg_file.v
38 lines (31 loc) · 948 Bytes
/
reg_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
/*******************************************************************
*
* Module: RegFile.v
* Project: RISCV_Pipelines_Processor
* Author: Menna Elzahar mennaelzahar@aucegypt.edu
Mariam Mousa mariamhmousa@aucegypt.edu
Salma Aly smaly@aucegypt.edu
* Description: this module represents the register file.
**********************************************************************/
module RegFile (
input clk, rst,
input [4:0] readreg1, readreg2, writereg,
input [31:0] writedata,
input regwrite,
output [31:0] readdata1, output [31:0] readdata2 );
reg [31:0]load = 0;
wire [31:0] Q [0:31];
genvar i;
generate
for(i = 0; i < 32; i=i+1) begin: myblock
reg_32bit register(~clk, rst, load[i], writedata, Q[i]);
end
endgenerate
assign readdata1 = Q[readreg1];
assign readdata2 = Q[readreg2];
always@(*) begin
load=0;
if(regwrite && writereg!=0)
load[writereg] = 1;
end
endmodule