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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [rtl/] [twoway/] [FT64_regfile1w3r_oc.v] - Blame information for rev 57

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 57 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2018  Robert Finch, Waterloo
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@finitron.ca
7
//       ||
8
//
9
// This source file is free software: you can redistribute it and/or modify 
10
// it under the terms of the GNU Lesser General Public License as published 
11
// by the Free Software Foundation, either version 3 of the License, or     
12
// (at your option) any later version.                                      
13
//                                                                          
14
// This source file is distributed in the hope that it will be useful,      
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
17
// GNU General Public License for more details.                             
18
//                                                                          
19
// You should have received a copy of the GNU General Public License        
20
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
21
//
22
//
23
// Register file with two write ports and six read ports.
24
// ============================================================================
25
//
26
`include "FT64_config.vh"
27
 
28
module FT64_regfileRam_sim(clka, ena, wea, addra, dina, clkb, enb, addrb, doutb);
29
parameter WID=64;
30
parameter RBIT = 11;
31
input clka;
32
input ena;
33
input [7:0] wea;
34
input [RBIT:0] addra;
35
input [WID-1:0] dina;
36
input clkb;
37
input enb;
38
input [RBIT:0] addrb;
39
output [WID-1:0] doutb;
40
 
41
integer n;
42
(* RAM_STYLE="BLOCK" *)
43
reg [64:0] mem [0:4095];
44
reg [RBIT:0] raddrb;
45
 
46
initial begin
47
        for (n = 0; n < 4096; n = n + 1)
48
                mem[n] = 0;
49
end
50
 
51
always @(posedge clka) if (ena & wea[0]) mem[addra][7:0] <= dina[7:0];
52
always @(posedge clka) if (ena & wea[1]) mem[addra][15:8] <= dina[15:8];
53
always @(posedge clka) if (ena & wea[2]) mem[addra][23:16] <= dina[23:16];
54
always @(posedge clka) if (ena & wea[3]) mem[addra][31:24] <= dina[31:24];
55
always @(posedge clka) if (ena & wea[4]) mem[addra][39:32] <= dina[39:32];
56
always @(posedge clka) if (ena & wea[5]) mem[addra][47:40] <= dina[47:40];
57
always @(posedge clka) if (ena & wea[6]) mem[addra][55:48] <= dina[55:48];
58
always @(posedge clka) if (ena & wea[7]) mem[addra][63:56] <= dina[63:56];
59
 
60
always @(posedge clkb)
61
        raddrb <= addrb;
62
assign doutb = mem[raddrb];
63
 
64
endmodule
65
 
66
module FT64_regfile1w3r_oc(clk, wr0, we0, wa0, i0,
67
        rclk, ra0, ra1, ra2, o0, o1, o2);
68
parameter WID=64;
69
parameter RBIT = 11;
70
input clk;
71
input wr0;
72
input [7:0] we0;
73
input [RBIT:0] wa0;
74
input [WID-1:0] i0;
75
input rclk;
76
input [RBIT:0] ra0;
77
input [RBIT:0] ra1;
78
input [RBIT:0] ra2;
79
output [WID-1:0] o0;
80
output [WID-1:0] o1;
81
output [WID-1:0] o2;
82
 
83
reg wr;
84
reg [RBIT:0] wa;
85
reg [WID-1:0] i;
86
reg [7:0] we;
87
wire [WID-1:0] o00, o01, o02;
88
 
89
integer n;
90
 
91
`ifdef SIM
92
FT64_regfileRam_sim urf10 (
93
  .clka(clk),
94
  .ena(wr),
95
  .wea(we),
96
  .addra(wa),
97
  .dina(i),
98
  .clkb(rclk),
99
  .enb(1'b1),
100
  .addrb(ra0),
101
  .doutb(o00)
102
);
103
 
104
FT64_regfileRam_sim urf11 (
105
  .clka(clk),
106
  .ena(wr),
107
  .wea(we),
108
  .addra(wa),
109
  .dina(i),
110
  .clkb(rclk),
111
  .enb(1'b1),
112
  .addrb(ra1),
113
  .doutb(o01)
114
);
115
 
116
FT64_regfileRam_sim urf12 (
117
  .clka(clk),
118
  .ena(wr),
119
  .wea(we),
120
  .addra(wa),
121
  .dina(i),
122
  .clkb(rclk),
123
  .enb(1'b1),
124
  .addrb(ra2),
125
  .doutb(o02)
126
);
127
 
128
`else
129
FT64_regfileRam urf10 (
130
  .clka(clk),
131
  .ena(wr),
132
  .wea(we),
133
  .addra(wa),
134
  .dina(i),
135
  .clkb(rclk),
136
  .enb(1'b1),
137
  .web(8'b0),
138
  .addrb(ra0),
139
  .dinb(64'h00),
140
  .doutb(o00)
141
);
142
 
143
FT64_regfileRam urf11 (
144
  .clka(clk),
145
  .ena(wr),
146
  .wea(we),
147
  .addra(wa),
148
  .dina(i),
149
  .clkb(rclk),
150
  .enb(1'b1),
151
  .web(8'b0),
152
  .addrb(ra1),
153
  .dinb(64'h00),
154
  .doutb(o01)
155
);
156
 
157
FT64_regfileRam urf12 (
158
  .clka(clk),
159
  .ena(wr),
160
  .wea(we),
161
  .addra(wa),
162
  .dina(i),
163
  .clkb(rclk),
164
  .enb(1'b1),
165
  .web(8'b0),
166
  .addrb(ra2),
167
  .dinb(64'h00),
168
  .doutb(o02)
169
);
170
 
171
`endif
172
 
173
always @*
174
begin
175
        wr <= wr0;
176
        we <= we0;
177
        wa <= wa0;
178
        i <= i0;
179
end
180
 
181
assign o0[7:0] = ra0[4:0]==5'd0 ? {8{1'b0}} :
182
        (wr0 && we0[0] && (ra0==wa0)) ? i0[7:0] : o00[7:0];
183
assign o0[15:8] = ra0[4:0]==5'd0 ? {8{1'b0}} :
184
        (wr0 && we0[1] && (ra0==wa0)) ? i0[15:8] : o00[15:8];
185
assign o0[23:16] = ra0[4:0]==5'd0 ? {8{1'b0}} :
186
        (wr0 && we0[2] && (ra0==wa0)) ? i0[23:16] : o00[23:16];
187
assign o0[31:24] = ra0[4:0]==5'd0 ? {8{1'b0}} :
188
        (wr0 && we0[3] && (ra0==wa0)) ? i0[31:24] : o00[31:24];
189
assign o0[39:32] = ra0[4:0]==5'd0 ? {8{1'b0}} :
190
        (wr0 && we0[4] && (ra0==wa0)) ? i0[39:32] : o00[39:32];
191
assign o0[47:40] = ra0[4:0]==5'd0 ? {8{1'b0}} :
192
        (wr0 && we0[5] && (ra0==wa0)) ? i0[47:40] : o00[47:40];
193
assign o0[55:48] = ra0[4:0]==5'd0 ? {8{1'b0}} :
194
        (wr0 && we0[6] && (ra0==wa0)) ? i0[55:48] : o00[55:48];
195
assign o0[63:56] = ra0[4:0]==5'd0 ? {8{1'b0}} :
196
        (wr0 && we0[7] && (ra0==wa0)) ? i0[63:56] : o00[63:56];
197
 
198
assign o1[7:0] = ra1[4:0]==5'd0 ? {8{1'b0}} :
199
        (wr0 && we0[0] && (ra1==wa0)) ? i0[7:0] : o01[7:0];
200
assign o1[15:8] = ra1[4:0]==5'd0 ? {8{1'b0}} :
201
        (wr0 && we0[1] && (ra1==wa0)) ? i0[15:8] : o01[15:8];
202
assign o1[23:16] = ra1[4:0]==5'd0 ? {8{1'b0}} :
203
        (wr0 && we0[2] && (ra1==wa0)) ? i0[23:16] : o01[23:16];
204
assign o1[31:24] = ra1[4:0]==5'd0 ? {8{1'b0}} :
205
        (wr0 && we0[3] && (ra1==wa0)) ? i0[31:24] : o01[31:24];
206
assign o1[39:32] = ra1[4:0]==5'd0 ? {8{1'b0}} :
207
        (wr0 && we0[4] && (ra1==wa0)) ? i0[39:32] : o01[39:32];
208
assign o1[47:40] = ra1[4:0]==5'd0 ? {8{1'b0}} :
209
        (wr0 && we0[5] && (ra1==wa0)) ? i0[47:40] : o01[47:40];
210
assign o1[55:48] = ra1[4:0]==5'd0 ? {8{1'b0}} :
211
        (wr0 && we0[6] && (ra1==wa0)) ? i0[55:48] : o01[55:48];
212
assign o1[63:56] = ra1[4:0]==5'd0 ? {8{1'b0}} :
213
        (wr0 && we0[7] && (ra1==wa0)) ? i0[63:56] : o01[63:56];
214
 
215
assign o2[7:0] = ra2[4:0]==5'd0 ? {8{1'b0}} :
216
        (wr0 && we0[0] && (ra2==wa0)) ? i0[7:0] : o02[7:0];
217
assign o2[15:8] = ra2[4:0]==5'd0 ? {8{1'b0}} :
218
        (wr0 && we0[1] && (ra2==wa0)) ? i0[15:8] : o02[15:8];
219
assign o2[23:16] = ra2[4:0]==5'd0 ? {8{1'b0}} :
220
        (wr0 && we0[2] && (ra2==wa0)) ? i0[23:16] : o02[23:16];
221
assign o2[31:24] = ra2[4:0]==5'd0 ? {8{1'b0}} :
222
        (wr0 && we0[3] && (ra2==wa0)) ? i0[31:24] : o02[31:24];
223
assign o2[39:32] = ra2[4:0]==5'd0 ? {8{1'b0}} :
224
        (wr0 && we0[4] && (ra2==wa0)) ? i0[39:32] : o02[39:32];
225
assign o2[47:40] = ra2[4:0]==5'd0 ? {8{1'b0}} :
226
        (wr0 && we0[5] && (ra2==wa0)) ? i0[47:40] : o02[47:40];
227
assign o2[55:48] = ra2[4:0]==5'd0 ? {8{1'b0}} :
228
        (wr0 && we0[6] && (ra2==wa0)) ? i0[55:48] : o02[55:48];
229
assign o2[63:56] = ra2[4:0]==5'd0 ? {8{1'b0}} :
230
        (wr0 && we0[7] && (ra2==wa0)) ? i0[63:56] : o02[63:56];
231
 
232
endmodule
233
 

powered by: WebSVN 2.1.0

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