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

Subversion Repositories openfire2

[/] [openfire2/] [trunk/] [rtl/] [openfire_regfile.v] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 toni32
/*      MODULE: openfire_regfile
2
 
3
        DESCRIPTION: This module instantiates two, dual-port aynchronous memories.  In
4
Xilinx parts this synthesizes to Select (LUT-based) RAM.  To handle half-word
5
and byte loads, MUXes and a feedback loop are used such that only the desired
6
portions of the previous word are modified.
7
 
8
AUTHOR:
9
Stephen Douglas Craven
10
Configurable Computing Lab
11
Virginia Tech
12
scraven@vt.edu
13
 
14
REVISION HISTORY:
15
Revision 0.2, 8/10/2005 SDC
16
Initial release
17
 
18
Revision 0.3 27/03/2007 Antonio J Anton
19
Removed memory load unalignment handling (moved to arbitrer)
20
 
21
COPYRIGHT:
22
Copyright (c) 2005 Stephen Douglas Craven
23
 
24
Permission is hereby granted, free of charge, to any person obtaining a copy of
25
this software and associated documentation files (the "Software"), to deal in
26
the Software without restriction, including without limitation the rights to
27
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
28
of the Software, and to permit persons to whom the Software is furnished to do
29
so, subject to the following conditions:
30
 
31
The above copyright notice and this permission notice shall be included in all
32
copies or substantial portions of the Software.
33
 
34
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40
SOFTWARE.
41
 
42
*/
43
`include "openfire_define.v"
44
 
45
module openfire_regfile (
46 4 toni32
`ifdef FSL_LINK
47
        fsl_s_data,
48
`endif
49 3 toni32
        reset, clock,
50
        regA_addr, regB_addr, regD_addr, result, pc_regfile,
51
        dmem_data, regfile_input_sel, we_regfile,
52
        we_alu_branch,
53
        regA, regB, regD, enable
54
);
55
 
56 4 toni32
input           reset;                          // From top level
57 3 toni32
input           clock;
58 4 toni32
input   [4:0]            regA_addr;              // From DECODE
59 3 toni32
input   [4:0]            regB_addr;
60
input   [4:0]            regD_addr;
61
input   [3:0]            regfile_input_sel;
62
input                           we_alu_branch;
63 4 toni32
input   [31:0]   result;                 // From EXECUTE
64 3 toni32
input   [`A_SPACE+1:0]   pc_regfile;
65
input                           we_regfile;
66
input                           enable;
67 4 toni32
input   [31:0]   dmem_data;              // From DMEM
68
`ifdef FSL_LINK
69
input   [31:0]   fsl_s_data;             // From FSL
70
`endif
71 3 toni32
 
72
output [31:0]    regA;
73
output [31:0]    regB;
74
output [31:0]    regD;
75
 
76
reg     [31:0]   input_data;
77
 
78
wire                            write_en;
79
wire    [31:0]   extended_pc;
80
 
81
// Write to registers on we_alu_branch OR we_load
82
//      UNLESS r0 is the target. r0 MUST always be zero. (|regD_addr) isolates R0
83
// Allow write on reset to load r0 with zero.
84
assign  write_en = reset ? 1'b1 : (we_alu_branch | we_regfile) & (|regD_addr) & enable;
85
 
86
// extended PC to datapath width
87
assign extended_pc[31:`A_SPACE+2] = 0;
88
assign extended_pc[`A_SPACE+1:0]  = pc_regfile;
89
 
90
// Input select into REGFILE
91
always@(
92
`ifdef FSL_LINK
93 4 toni32
                        fsl_s_data or
94 3 toni32
`endif
95
                        dmem_data or extended_pc or result or regfile_input_sel or write_en or clock
96
)
97
begin
98
        case(regfile_input_sel)
99
        `RF_dmem_byte:                  input_data <= dmem_data[31:24];         // update byte
100
        `RF_dmem_halfword:      input_data <= dmem_data[31:16];         // update halfword
101
        `RF_dmem_wholeword:     input_data <= dmem_data;                                // update word
102
        `RF_alu_result:         input_data <= result;
103
        `RF_pc:                                 input_data <= extended_pc;
104
`ifdef FSL_LINK
105 4 toni32
        `RF_fsl:                                        input_data <= fsl_s_data;
106 3 toni32
`endif
107
        default:
108
                begin
109
                        input_data <= 0;
110
//synthesis translate_off
111
                        if(write_en & ~clock & (regfile_input_sel != `RF_zero)) $display("ERROR! REGFILE input selector set to illegal value %d at PC %x", regfile_input_sel, pc_regfile);
112
//synthesis translate_on
113
                end
114
        endcase
115
end
116
 
117
// We need a 3-port register file -- create from 2, 2-port SRAMs
118
// Tie write ports together
119
openfire_rf_sram        RF_BANK0 (
120
        .clock(clock),
121
        .read_addr(regA_addr),
122
        .write_addr(regD_addr),
123
        .data_in(input_data),
124
        .we(write_en),
125
        .read_data_out(regA),
126
        .write_data_out(regD)
127
);
128
 
129
openfire_rf_sram        RF_BANK1 (
130
        .clock(clock),
131
        .read_addr(regB_addr),
132
        .write_addr(regD_addr),
133
        .data_in(input_data),
134
        .we(write_en),
135
        .read_data_out(regB),
136
        .write_data_out( )
137
);
138
 
139
endmodule

powered by: WebSVN 2.1.0

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