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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_26/] [or1200/] [rtl/] [verilog/] [or1200_rfram_generic.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 871 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's register file generic memory                       ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Generic (flip-flop based) register file memory              ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - nothing                                                  ////
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
// $Log: not supported by cvs2svn $
46 1022 lampret
// Revision 1.1  2002/06/08 16:23:30  lampret
47
// Generic flip-flop based memory macro for register file.
48 871 lampret
//
49 1022 lampret
//
50 871 lampret
 
51
// synopsys translate_off
52
`include "timescale.v"
53
// synopsys translate_on
54
`include "or1200_defines.v"
55
 
56
module or1200_rfram_generic(
57
        // Clock and reset
58
        clk, rst,
59
 
60
        // Port A
61
        ce_a, addr_a, do_a,
62
 
63
        // Port B
64
        ce_b, addr_b, do_b,
65
 
66
        // Port W
67
        ce_w, we_w, addr_w, di_w
68
);
69
 
70
parameter dw = `OR1200_OPERAND_WIDTH;
71
parameter aw = `OR1200_REGFILE_ADDR_WIDTH;
72
 
73
//
74
// I/O
75
//
76
 
77
//
78
// Clock and reset
79
//
80
input                           clk;
81
input                           rst;
82
 
83
//
84
// Port A
85
//
86
input                           ce_a;
87
input   [aw-1:0]         addr_a;
88
output  [dw-1:0]         do_a;
89
 
90
//
91
// Port B
92
//
93
input                           ce_b;
94
input   [aw-1:0]         addr_b;
95
output  [dw-1:0]         do_b;
96
 
97
//
98
// Port W
99
//
100
input                           ce_w;
101
input                           we_w;
102
input   [aw-1:0]         addr_w;
103
input   [dw-1:0]         di_w;
104
 
105
//
106
// Internal wires and regs
107
//
108
reg     [aw-1:0]         intaddr_a;
109
reg     [aw-1:0]         intaddr_b;
110
reg     [32*dw-1:0]              mem;
111
reg     [dw-1:0]         do_a;
112
reg     [dw-1:0]         do_b;
113
 
114
//
115
// Write port
116
//
117
always @(posedge clk or posedge rst)
118
        if (rst) begin
119
                mem <= #1 1024'h0;
120
        end
121
        else if (ce_w & we_w)
122 1022 lampret
                case (addr_w)   // synopsys parallel_case
123 871 lampret
                        5'd00: mem[32*0+31:32*0] <= #1 di_w;
124
                        5'd01: mem[32*1+31:32*1] <= #1 di_w;
125
                        5'd02: mem[32*2+31:32*2] <= #1 di_w;
126
                        5'd03: mem[32*3+31:32*3] <= #1 di_w;
127
                        5'd04: mem[32*4+31:32*4] <= #1 di_w;
128
                        5'd05: mem[32*5+31:32*5] <= #1 di_w;
129
                        5'd06: mem[32*6+31:32*6] <= #1 di_w;
130
                        5'd07: mem[32*7+31:32*7] <= #1 di_w;
131
                        5'd08: mem[32*8+31:32*8] <= #1 di_w;
132
                        5'd09: mem[32*9+31:32*9] <= #1 di_w;
133
                        5'd10: mem[32*10+31:32*10] <= #1 di_w;
134
                        5'd11: mem[32*11+31:32*11] <= #1 di_w;
135
                        5'd12: mem[32*12+31:32*12] <= #1 di_w;
136
                        5'd13: mem[32*13+31:32*13] <= #1 di_w;
137
                        5'd14: mem[32*14+31:32*14] <= #1 di_w;
138
                        5'd15: mem[32*15+31:32*15] <= #1 di_w;
139
                        5'd16: mem[32*16+31:32*16] <= #1 di_w;
140
                        5'd17: mem[32*17+31:32*17] <= #1 di_w;
141
                        5'd18: mem[32*18+31:32*18] <= #1 di_w;
142
                        5'd19: mem[32*19+31:32*19] <= #1 di_w;
143
                        5'd20: mem[32*20+31:32*20] <= #1 di_w;
144
                        5'd21: mem[32*21+31:32*21] <= #1 di_w;
145
                        5'd22: mem[32*22+31:32*22] <= #1 di_w;
146
                        5'd23: mem[32*23+31:32*23] <= #1 di_w;
147
                        5'd24: mem[32*24+31:32*24] <= #1 di_w;
148
                        5'd25: mem[32*25+31:32*25] <= #1 di_w;
149
                        5'd26: mem[32*26+31:32*26] <= #1 di_w;
150
                        5'd27: mem[32*27+31:32*27] <= #1 di_w;
151
                        5'd28: mem[32*28+31:32*28] <= #1 di_w;
152
                        5'd29: mem[32*29+31:32*29] <= #1 di_w;
153
                        5'd30: mem[32*30+31:32*30] <= #1 di_w;
154 1022 lampret
                        default: mem[32*31+31:32*31] <= #1 di_w;
155 871 lampret
                endcase
156
 
157
//
158
// Read port A
159
//
160
always @(posedge clk or posedge rst)
161
        if (rst) begin
162
                intaddr_a <= #1 5'h00;
163
        end
164
        else if (ce_a)
165
                intaddr_a <= #1 addr_a;
166
 
167
always @(mem or intaddr_a)
168 1022 lampret
        case (intaddr_a)        // synopsys parallel_case
169 871 lampret
                5'd00: do_a = mem[32*0+31:32*0];
170
                5'd01: do_a = mem[32*1+31:32*1];
171
                5'd02: do_a = mem[32*2+31:32*2];
172
                5'd03: do_a = mem[32*3+31:32*3];
173
                5'd04: do_a = mem[32*4+31:32*4];
174
                5'd05: do_a = mem[32*5+31:32*5];
175
                5'd06: do_a = mem[32*6+31:32*6];
176
                5'd07: do_a = mem[32*7+31:32*7];
177
                5'd08: do_a = mem[32*8+31:32*8];
178
                5'd09: do_a = mem[32*9+31:32*9];
179
                5'd10: do_a = mem[32*10+31:32*10];
180
                5'd11: do_a = mem[32*11+31:32*11];
181
                5'd12: do_a = mem[32*12+31:32*12];
182
                5'd13: do_a = mem[32*13+31:32*13];
183
                5'd14: do_a = mem[32*14+31:32*14];
184
                5'd15: do_a = mem[32*15+31:32*15];
185
                5'd16: do_a = mem[32*16+31:32*16];
186
                5'd17: do_a = mem[32*17+31:32*17];
187
                5'd18: do_a = mem[32*18+31:32*18];
188
                5'd19: do_a = mem[32*19+31:32*19];
189
                5'd20: do_a = mem[32*20+31:32*20];
190
                5'd21: do_a = mem[32*21+31:32*21];
191
                5'd22: do_a = mem[32*22+31:32*22];
192
                5'd23: do_a = mem[32*23+31:32*23];
193
                5'd24: do_a = mem[32*24+31:32*24];
194
                5'd25: do_a = mem[32*25+31:32*25];
195
                5'd26: do_a = mem[32*26+31:32*26];
196
                5'd27: do_a = mem[32*27+31:32*27];
197
                5'd28: do_a = mem[32*28+31:32*28];
198
                5'd29: do_a = mem[32*29+31:32*29];
199
                5'd30: do_a = mem[32*30+31:32*30];
200 1022 lampret
                default: do_a = mem[32*31+31:32*31];
201 871 lampret
        endcase
202
 
203
//
204
// Read port B
205
//
206
always @(posedge clk or posedge rst)
207
        if (rst) begin
208
                intaddr_b <= #1 5'h00;
209
        end
210
        else if (ce_b)
211
                intaddr_b <= #1 addr_b;
212
 
213
always @(mem or intaddr_b)
214 1022 lampret
        case (intaddr_b)        // synopsys parallel_case
215 871 lampret
                5'd00: do_b = mem[32*0+31:32*0];
216
                5'd01: do_b = mem[32*1+31:32*1];
217
                5'd02: do_b = mem[32*2+31:32*2];
218
                5'd03: do_b = mem[32*3+31:32*3];
219
                5'd04: do_b = mem[32*4+31:32*4];
220
                5'd05: do_b = mem[32*5+31:32*5];
221
                5'd06: do_b = mem[32*6+31:32*6];
222
                5'd07: do_b = mem[32*7+31:32*7];
223
                5'd08: do_b = mem[32*8+31:32*8];
224
                5'd09: do_b = mem[32*9+31:32*9];
225
                5'd10: do_b = mem[32*10+31:32*10];
226
                5'd11: do_b = mem[32*11+31:32*11];
227
                5'd12: do_b = mem[32*12+31:32*12];
228
                5'd13: do_b = mem[32*13+31:32*13];
229
                5'd14: do_b = mem[32*14+31:32*14];
230
                5'd15: do_b = mem[32*15+31:32*15];
231
                5'd16: do_b = mem[32*16+31:32*16];
232
                5'd17: do_b = mem[32*17+31:32*17];
233
                5'd18: do_b = mem[32*18+31:32*18];
234
                5'd19: do_b = mem[32*19+31:32*19];
235
                5'd20: do_b = mem[32*20+31:32*20];
236
                5'd21: do_b = mem[32*21+31:32*21];
237
                5'd22: do_b = mem[32*22+31:32*22];
238
                5'd23: do_b = mem[32*23+31:32*23];
239
                5'd24: do_b = mem[32*24+31:32*24];
240
                5'd25: do_b = mem[32*25+31:32*25];
241
                5'd26: do_b = mem[32*26+31:32*26];
242
                5'd27: do_b = mem[32*27+31:32*27];
243
                5'd28: do_b = mem[32*28+31:32*28];
244
                5'd29: do_b = mem[32*29+31:32*29];
245
                5'd30: do_b = mem[32*30+31:32*30];
246 1022 lampret
                default: do_b = mem[32*31+31:32*31];
247 871 lampret
        endcase
248
 
249
endmodule

powered by: WebSVN 2.1.0

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