OpenCores
URL https://opencores.org/ocsvn/mips32r1/mips32r1/trunk

Subversion Repositories mips32r1

[/] [mips32r1/] [trunk/] [Hardware/] [XUPV5-LX110T_SoC/] [MIPS32-Pipelined-Hw/] [src/] [MIPS32/] [RegisterFile.v] - Blame information for rev 11

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ayersg
`timescale 1ns / 1ps
2
/*
3
 * File         : RegisterFile.v
4
 * Project      : University of Utah, XUM Project MIPS32 core
5
 * Creator(s)   : Grant Ayers (ayers@cs.utah.edu)
6
 *
7
 * Modification History:
8
 *   Rev   Date         Initials  Description of Change
9
 *   1.0   7-Jun-2011   GEA       Initial design.
10
 *
11
 * Standards/Formatting:
12
 *   Verilog 2001, 4 soft tab, wide column.
13
 *
14
 * Description:
15
 *   A Register File for a MIPS processor. Contains 32 general-purpose
16
 *   32-bit wide registers and two read ports. Register 0 always reads
17
 *   as zero.
18
 */
19
module RegisterFile(
20
    input  clock,
21
    input  reset,
22
    input  [4:0]  ReadReg1, ReadReg2, WriteReg,
23
    input  [31:0] WriteData,
24
    input  RegWrite,
25
    output [31:0] ReadData1, ReadData2
26
    );
27
 
28
    // Register file of 32 32-bit registers. Register 0 is hardwired to 0s
29
    reg [31:0] registers [1:31];
30
 
31
    // Initialize all to zero
32
    integer i;
33
    initial begin
34
        for (i=1; i<32; i=i+1) begin
35
            registers[i] <= 0;
36
        end
37
    end
38
 
39
    // Sequential (clocked) write.
40
    // 'WriteReg' is the register index to write. 'RegWrite' is the command.
41
    always @(posedge clock) begin
42
        if (reset) begin
43
            for (i=1; i<32; i=i+1) begin
44
                registers[i] <= 0;
45
            end
46
        end
47
        else begin
48
            if (WriteReg != 0)
49
                registers[WriteReg] <= (RegWrite) ? WriteData : registers[WriteReg];
50
        end
51
    end
52
 
53
    // Combinatorial Read. Register 0 is all 0s.
54
    assign ReadData1 = (ReadReg1 == 0) ? 32'h00000000 : registers[ReadReg1];
55
    assign ReadData2 = (ReadReg2 == 0) ? 32'h00000000 : registers[ReadReg2];
56
 
57 3 ayersg
endmodule
58 2 ayersg
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.