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

Subversion Repositories steelcore

[/] [rtl/] [integer_file.v] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 rafaelcalc
//////////////////////////////////////////////////////////////////////////////////
2
// Engineer: Rafael de Oliveira Calçada (rafaelcalcada@gmail.com)
3
// 
4
// Create Date: 02.04.2020 23:23:16
5
// Module Name: register_file
6
// Project Name: Steel Core 
7
// Description: 32-bit Integer Register File
8
// 
9
// Dependencies: globals.vh
10
// 
11
// Version 0.03
12
// 
13
//////////////////////////////////////////////////////////////////////////////////
14
 
15
/*********************************************************************************
16
 
17
MIT License
18
 
19
Copyright (c) 2020 Rafael de Oliveira Calçada
20
 
21
Permission is hereby granted, free of charge, to any person obtaining a copy
22
of this software and associated documentation files (the "Software"), to deal
23
in the Software without restriction, including without limitation the rights
24
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
copies of the Software, and to permit persons to whom the Software is
26
furnished to do so, subject to the following conditions:
27
 
28
The above copyright notice and this permission notice shall be included in all
29
copies or substantial portions of the Software.
30
 
31
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
SOFTWARE.
38
 
39
********************************************************************************/
40
 
41
`timescale 1ns / 1ps
42
`include "globals.vh"
43
 
44
module integer_file(
45
 
46
    input wire CLK,
47
 
48
    // connections with pipeline stage 2
49
    input wire [4:0] RS_1_ADDR,
50
    input wire [4:0] RS_2_ADDR,
51
    output wire [31:0] RS_1,
52
    output wire [31:0] RS_2,
53
 
54
    // connections with pipeline stage 3
55
    input wire [4:0] RD_ADDR,
56
    input wire WR_EN,
57
    input wire [31:0] RD
58
 
59
    );
60
 
61
    wire [31:0] rs1_wire;
62
    wire [31:0] rs2_wire;
63
    wire [31:1] enable;
64
    wire fwd_op1_enable;
65
    wire fwd_op2_enable;
66
    wire op1_zero;
67
    wire op2_zero;
68
    wire [31:0] reg_en;
69
    reg [31:0] rs1_reg;
70
    reg [31:0] rs2_reg;
71
    wire rs1_addr_is_x0;
72
    wire rs2_addr_is_x0;
73
    reg [31:0] Q [31:1];
74
 
75
    integer i;
76
 
77
    initial
78
    begin
79
        for(i = 1; i < 32; i = i+1) Q[i] <= 32'b0;
80
    end
81
 
82
    always @(posedge CLK)
83
        if(WR_EN) Q[RD_ADDR] <= RD;
84
 
85
    assign rs1_addr_is_x0 = RS_1_ADDR == 5'b00000;
86
    assign rs2_addr_is_x0 = RS_2_ADDR == 5'b00000;
87
    assign fwd_op1_enable = (RS_1_ADDR == RD_ADDR && WR_EN == 1'b1) ? 1'b1 : 1'b0;
88
    assign fwd_op2_enable = (RS_2_ADDR == RD_ADDR && WR_EN == 1'b1) ? 1'b1 : 1'b0;
89
    assign op1_zero = rs1_addr_is_x0 == 1'b1 ? 1'b1 : 1'b0;
90
    assign op2_zero = rs2_addr_is_x0 == 1'b1 ? 1'b1 : 1'b0;
91
    assign rs1_wire = fwd_op1_enable == 1'b1 ? RD : Q[RS_1_ADDR];
92
    assign rs2_wire = fwd_op2_enable == 1'b1 ? RD : Q[RS_2_ADDR];
93
    assign RS_1 = op1_zero == 1'b1 ? 32'h00000000 : rs1_wire;
94
    assign RS_2 = op2_zero == 1'b1 ? 32'h00000000 : rs2_wire;
95
 
96
endmodule

powered by: WebSVN 2.1.0

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