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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [or1200/] [rtl/] [verilog/] [rf.v] - Blame information for rev 205

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

Line No. Rev Author Line
1 161 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's register file inside CPU                           ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Instantiation of register file memories                     ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - make it smaller and faster                               ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 203 lampret
// Revision 1.3  2001/08/09 13:39:33  lampret
48
// Major clean-up.
49
//
50 168 lampret
// Revision 1.2  2001/07/22 03:31:54  lampret
51
// Fixed RAM's oen bug. Cache bypass under development.
52
//
53 166 lampret
// Revision 1.1  2001/07/20 00:46:21  lampret
54
// Development version of RTL. Libraries are missing.
55 161 lampret
//
56 166 lampret
//
57 161 lampret
 
58 203 lampret
// synopsys translate_off
59 168 lampret
`include "timescale.v"
60 203 lampret
// synopsys translate_on
61 168 lampret
`include "defines.v"
62 161 lampret
 
63 168 lampret
module rf(
64
        // Clock and reset
65
        clk, rst,
66 161 lampret
 
67 168 lampret
        // Write i/f
68
        addrw, dataw, we,
69
 
70
        // Read i/f
71 205 lampret
        id_freeze, addra, addrb, dataa, datab,
72 168 lampret
 
73
        // Debug
74
        rfa_tqa, rfb_tqa, rfa_tmuxed, rfb_tmuxed, tp1w
75 161 lampret
);
76
 
77
parameter dw = `OPERAND_WIDTH;
78
parameter aw = `REGFILE_ADDR_WIDTH;
79
 
80 168 lampret
//
81
// I/O
82
//
83 161 lampret
 
84 168 lampret
//
85
// Clock and reset
86
//
87
input                           clk;
88
input                           rst;
89 161 lampret
 
90 168 lampret
//
91
// Write i/f
92
//
93
input   [aw-1:0]         addrw;
94
input   [dw-1:0]         dataw;
95
input                           we;
96 161 lampret
 
97 168 lampret
//
98
// Read i/f
99
//
100 205 lampret
input                           id_freeze;
101 168 lampret
input   [aw-1:0]         addra;
102
input   [aw-1:0]         addrb;
103
output  [dw-1:0]         dataa;
104
output  [dw-1:0]         datab;
105 161 lampret
 
106 168 lampret
//
107
// Debug
108
//
109
output  [31:0]                   rfa_tqa;
110
output  [31:0]                   rfb_tqa;
111
output  [`TP1R_WIDTH-1:0]        rfa_tmuxed;
112
output  [`TP1R_WIDTH-1:0]        rfb_tmuxed;
113
input   [`TP1W_WIDTH-1:0]        tp1w;
114 161 lampret
 
115 168 lampret
//
116
// Internal wires and regs
117
//
118
wire    [dw-1:0]         from_rfa;
119
wire    [dw-1:0]         from_rfb;
120
wire    [dw-1:0]         t_dataw; // for test port
121
wire    [aw-1:0]         t_addrw; // for test port
122
wire    [aw-1:0]         t_addra; // for test port
123
wire    [aw-1:0]         t_addrb; // for test port
124
reg     [dw:0]                   dataa_saved;
125
reg     [dw:0]                   datab_saved;
126 161 lampret
 
127 168 lampret
//
128
// Simple assignments
129
//
130
assign rfa_tqa = 32'b0;
131
assign rfb_tqa = 32'b0;
132
assign rfa_tmuxed = `TP1R_WIDTH'b0;
133
assign rfb_tmuxed = `TP1R_WIDTH'b0;
134 161 lampret
 
135 168 lampret
//
136
// Operand A comes from RF or from saved A register
137
//
138 161 lampret
assign dataa = (dataa_saved[32]) ? dataa_saved[31:0] : from_rfa;
139 168 lampret
 
140
//
141
// Operand B comes from RF or from saved B register
142
//
143 161 lampret
assign datab = (datab_saved[32]) ? datab_saved[31:0] : from_rfb;
144
 
145 168 lampret
//
146 161 lampret
// Stores operand from RF_A into temp reg when pipeline is frozen
147 168 lampret
//
148 161 lampret
always @(posedge clk or posedge rst)
149
        if (rst) begin
150
                dataa_saved <= #1 33'b0;
151
        end
152 205 lampret
        else if (id_freeze & !dataa_saved[32]) begin
153 161 lampret
                dataa_saved <= #1 {1'b1, from_rfa};
154
        end
155 205 lampret
        else if (!id_freeze)
156
                dataa_saved <= #1 33'b0;
157 161 lampret
 
158 168 lampret
//
159 161 lampret
// Stores operand from RF_B into temp reg when pipeline is frozen
160 168 lampret
//
161 161 lampret
always @(posedge clk or posedge rst)
162
        if (rst) begin
163
                datab_saved <= #1 33'b0;
164
        end
165 205 lampret
        else if (id_freeze & !datab_saved[32]) begin
166 161 lampret
                datab_saved <= #1 {1'b1, from_rfb};
167
        end
168 205 lampret
        else if (!id_freeze)
169
                datab_saved <= #1 33'b0;
170 161 lampret
 
171 168 lampret
//
172 203 lampret
// Instantiation of register file two-port RAM A
173 168 lampret
//
174 203 lampret
generic_tpram_32x32 rf_a(
175 168 lampret
        // Port A
176
        .clk_a(clk),
177
        .rst_a(rst),
178
        .ce_a(1'b1),
179 203 lampret
        .we_a(1'b0),
180 168 lampret
        .oe_a(1'b1),
181
        .addr_a(addra),
182 203 lampret
        .di_a(32'h0000_0000),
183 168 lampret
        .do_a(from_rfa),
184 161 lampret
 
185 168 lampret
        // Port B
186
        .clk_b(clk),
187
        .rst_b(rst),
188
        .ce_b(we),
189
        .we_b(we),
190 203 lampret
        .oe_b(1'b0),
191 168 lampret
        .addr_b(addrw),
192 203 lampret
        .di_b(dataw),
193
        .do_b()
194 161 lampret
);
195
 
196 168 lampret
//
197 203 lampret
// Instantiation of register file two-port RAM B
198 168 lampret
//
199 203 lampret
generic_tpram_32x32 rf_b(
200 168 lampret
        // Port A
201
        .clk_a(clk),
202
        .rst_a(rst),
203
        .ce_a(1'b1),
204 203 lampret
        .we_a(1'b0),
205 168 lampret
        .oe_a(1'b1),
206
        .addr_a(addrb),
207 203 lampret
        .di_a(32'h0000_0000),
208 168 lampret
        .do_a(from_rfb),
209 161 lampret
 
210 168 lampret
        // Port B
211
        .clk_b(clk),
212
        .rst_b(rst),
213
        .ce_b(we),
214
        .we_b(we),
215 203 lampret
        .oe_b(1'b0),
216 168 lampret
        .addr_b(addrw),
217 203 lampret
        .di_b(dataw),
218
        .do_b()
219 161 lampret
);
220
 
221
endmodule

powered by: WebSVN 2.1.0

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