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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [lsu_stb_rwdp.v] - Blame information for rev 113

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 95 fafa1971
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: lsu_stb_rwdp.v
4
// Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
5
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6
// 
7
// The above named program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public
9
// License version 2 as published by the Free Software Foundation.
10
// 
11
// The above named program is distributed in the hope that it will be 
12
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
// General Public License for more details.
15
// 
16
// You should have received a copy of the GNU General Public
17
// License along with this work; if not, write to the Free Software
18
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19
// 
20
// ========== Copyright Header End ============================================
21 113 albert.wat
`ifdef SIMPLY_RISC_TWEAKS
22
`define SIMPLY_RISC_SCANIN .si(0)
23
`else
24
`define SIMPLY_RISC_SCANIN .si()
25
`endif
26 95 fafa1971
///////////////////////////////////////////////////////////////////
27
/*
28
//      Description:    Datapath for STB
29
//                              - Mainly for formatting stb data
30
*/
31
////////////////////////////////////////////////////////////////////////
32
// Global header file includes
33
////////////////////////////////////////////////////////////////////////
34 113 albert.wat
`include        "sys.h" // system level definition file which contains the 
35 95 fafa1971
                                        // time scale definition
36
 
37 113 albert.wat
`include "iop.h"
38 95 fafa1971
 
39
////////////////////////////////////////////////////////////////////////
40
// Local header file includes / local defines
41
////////////////////////////////////////////////////////////////////////
42
 
43
module lsu_stb_rwdp (/*AUTOARG*/
44
   // Outputs
45
   so, stb_rdata_ramd_buf, stb_rdata_ramd_b74_buf, lsu_stb_st_data_g,
46
   // Inputs
47
   rclk, si, se, rst_tri_en, exu_lsu_rs3_data_e,
48
   lsu_stb_data_early_sel_e, lsu_stb_data_final_sel_m,
49
   exu_lsu_rs2_data_e, lsu_st_sz_bhww_m, lsu_st_sz_dw_m,
50
   lsu_st_sz_bhw_m, lsu_st_sz_wdw_m, lsu_st_sz_b_m, lsu_st_sz_w_m,
51
   lsu_st_sz_hw_m, lsu_st_sz_hww_m, ffu_lsu_data, lsu_st_hw_le_g,
52
   lsu_st_w_or_dbl_le_g, lsu_st_x_le_g, lsu_swap_sel_default_g,
53
   lsu_swap_sel_default_byte_7_2_g, stb_rdata_ramd,
54
   stb_rdata_ramd_b74
55
   ) ;
56
 
57
   input  rclk ;
58
   input  si;
59
   output so;
60
   input  se;
61
   input  rst_tri_en;
62
 
63
input   [63:0]          exu_lsu_rs3_data_e ;    // data for store.
64
input   [3:0]            lsu_stb_data_early_sel_e ;// early source of data for stb
65
input                   lsu_stb_data_final_sel_m ;// early source of data for stb
66
input   [63:0]          exu_lsu_rs2_data_e ;    // rs2 data for cas.
67
input                   lsu_st_sz_bhww_m ;      // byte or hword or word
68
input                   lsu_st_sz_dw_m ;        // double word
69
input                   lsu_st_sz_bhw_m ;       // byte or hword
70
input                   lsu_st_sz_wdw_m ;       // word or dword
71
input                   lsu_st_sz_b_m ;         // byte
72
input                   lsu_st_sz_w_m ;         // word
73
input                   lsu_st_sz_hw_m ;        // hword
74
input                   lsu_st_sz_hww_m ;       // hword or word
75
input   [63:0]           ffu_lsu_data ;  // fp store data - m stage
76
//input                 lsu_bendian_access_g ;  // bendian st
77
//input                 lsu_stdbl_inst_m ;      // stdbl
78
 
79
   input        lsu_st_hw_le_g;
80
   input        lsu_st_w_or_dbl_le_g;
81
   input        lsu_st_x_le_g;
82
   input        lsu_swap_sel_default_g;
83
   input        lsu_swap_sel_default_byte_7_2_g;
84
 
85
   input [69:0] stb_rdata_ramd;
86
   input        stb_rdata_ramd_b74;
87
 
88
   output [69:0] stb_rdata_ramd_buf;
89
   output        stb_rdata_ramd_b74_buf;
90
 
91
output  [63:0]           lsu_stb_st_data_g ;     // data to be written to stb
92
 
93
wire    [7:0]    byte0, byte1, byte2, byte3 ;
94
wire    [7:0]    byte4, byte5, byte6, byte7 ;
95
wire    [7:0]    swap_byte0, swap_byte1, swap_byte2, swap_byte3 ;
96
wire    [7:0]    swap_byte4, swap_byte5, swap_byte6, swap_byte7 ;
97
 
98
wire    [63:0]   stb_st_data_g ;
99
wire    [63:0]   stb_st_data_early_e ;
100
wire    [63:0]   stb_st_data_early_m ;
101
wire    [63:0]   stb_st_data_final_m ;
102
wire            st_sz_bhww_g ;
103
wire            st_sz_dw_g ;
104
wire            st_sz_bhw_g ;
105
wire            st_sz_wdw_g ;
106
wire            st_sz_b_g ;
107
wire            st_sz_w_g ;
108
wire            st_sz_hw_g ;
109
wire            st_sz_hww_g ;
110
//wire          bendian ;
111
//wire          stdbl_g ;
112
 
113
   wire clk;
114
   assign clk = rclk;
115
 
116
//assign  stb_st_data_early_e[63:0] =       //@@ bw_u1_muxi41d_2x   
117
//        lsu_stb_data_early_sel_e[0] ? 64'hffff_ffff_ffff_ffff :                       // ldstub writes all ones
118
//                lsu_stb_data_early_sel_e[1] ? exu_lsu_rs2_data_e[63:0] :              // cas pkt1 uses rs2
119
//                      lsu_stb_data_early_sel_e[2] ? exu_lsu_rs3_data_e[63:0] :        // use rs3/rd data.
120
//                              lsu_stb_data_early_sel_e[3] ? {exu_lsu_rs2_data_e[31:0],exu_lsu_rs3_data_e[31:0]} :  
121
                                                                                        // else std non-alt
122
//                                              64'hxxxx_xxxx_xxxx_xxxx ;                               
123
 
124
mux4ds #(64) stb_st_data_early_e_mx (
125
 .in0 (64'hffff_ffff_ffff_ffff),
126
 .in1 (exu_lsu_rs2_data_e[63:0]),
127
 .in2 (exu_lsu_rs3_data_e[63:0]),
128
 .in3 ({exu_lsu_rs2_data_e[31:0],exu_lsu_rs3_data_e[31:0]}),
129
 .sel0(lsu_stb_data_early_sel_e[0]),
130
 .sel1(lsu_stb_data_early_sel_e[1]),
131
 .sel2(lsu_stb_data_early_sel_e[2]),
132
 .sel3(lsu_stb_data_early_sel_e[3]),
133
 .dout(stb_st_data_early_e[63:0]));
134
 
135
 
136
// Stage early data to m
137 113 albert.wat
dff_s #(64)  stgm_rs2     (             //@@ bw_u1_soffi_2x
138 95 fafa1971
        .din            (stb_st_data_early_e[63:0]),
139
        .q              (stb_st_data_early_m[63:0]),
140
        .clk            (clk),
141 113 albert.wat
        .se             (se), `SIMPLY_RISC_SCANIN, .so ()
142 95 fafa1971
        );
143
 
144
assign  stb_st_data_final_m[63:0] =    //@@ bw_u1_muxi21_2x
145
        lsu_stb_data_final_sel_m ? stb_st_data_early_m[63:0] : ffu_lsu_data[63:0] ;       // mux in fpst data
146
 
147
// Precursor of data to be stored in stb
148
// For ldstub, all one's need to be written to stb.
149
// For cas/swap, data remains unmodified.
150
// Stage final data to g
151 113 albert.wat
dff_s #(64)  stgg_rs2     (             //@@ bw_u1_soffi_2x
152 95 fafa1971
        .din            (stb_st_data_final_m[63:0]),
153
        .q              (stb_st_data_g[63:0]),
154
        .clk            (clk),
155 113 albert.wat
        .se             (se), `SIMPLY_RISC_SCANIN, .so ()
156 95 fafa1971
        );
157
 
158 113 albert.wat
dff_s #(8)  stgm_sel     (             //@@ bw_u1_soff_8x
159 95 fafa1971
        .din            ({lsu_st_sz_bhww_m,lsu_st_sz_dw_m,lsu_st_sz_bhw_m,lsu_st_sz_wdw_m,
160
                        lsu_st_sz_b_m,lsu_st_sz_w_m,lsu_st_sz_hw_m,lsu_st_sz_hww_m}),
161
        .q              ({st_sz_bhww_g,st_sz_dw_g,st_sz_bhw_g,st_sz_wdw_g,
162
                        st_sz_b_g,st_sz_w_g,st_sz_hw_g,st_sz_hww_g}),
163
        .clk            (clk),
164 113 albert.wat
        .se             (se), `SIMPLY_RISC_SCANIN, .so ()
165 95 fafa1971
        );
166
 
167
// Now format data for st data.
168
assign  byte0[7:0] = stb_st_data_g[7:0] ; //@@ PASS
169
assign  byte1[7:0] = stb_st_data_g[15:8] ; //@@ PASS
170
assign  byte2[7:0] = stb_st_data_g[23:16] ; //@@ PASS
171
assign  byte3[7:0] = stb_st_data_g[31:24] ; //@@ PASS
172
assign  byte4[7:0] = stb_st_data_g[39:32] ; //@@ PASS
173
assign  byte5[7:0] = stb_st_data_g[47:40] ; //@@ PASS
174
assign  byte6[7:0] = stb_st_data_g[55:48] ; //@@ PASS
175
assign  byte7[7:0] = stb_st_data_g[63:56] ; //@@ PASS
176
 
177
 
178
//assign        bendian = lsu_bendian_access_g ;        // bendian store
179
 
180
// Control needs to move to lsu_stb_rwctl once this is fully tested.
181
 
182
// First do swap for big-endian vs little-endian case.
183
 
184
//wire  swap_sel_default ;
185
 
186
//assign        swap_sel_default = bendian | (~bendian & st_sz_b_g) ;
187
 
188
// swap byte0
189
//assign        swap_byte0[7:0] =               //@@ bw_u1_muxi41d_4x
190
//      lsu_swap_sel_default_g ? byte0[7:0] : 
191
//              lsu_st_hw_le_g ? byte1[7:0] :
192
//                      lsu_st_w_or_dbl_le_g ? byte3[7:0] :
193
//                              lsu_st_x_le_g ? byte7[7:0] : 8'bxxxx_xxxx ; 
194
 
195
mux4ds #(8) swap_byte0_mx (
196
  .in0 (byte0[7:0]), .sel0(lsu_swap_sel_default_g),
197
  .in1 (byte1[7:0]), .sel1(lsu_st_hw_le_g),
198
  .in2 (byte3[7:0]), .sel2(lsu_st_w_or_dbl_le_g),
199
  .in3 (byte7[7:0]), .sel3(lsu_st_x_le_g),
200
  .dout(swap_byte0[7:0]));
201
 
202
// swap byte1
203
//assign        swap_byte1[7:0] =               //@@ bw_u1_muxi41d_4x
204
//      lsu_swap_sel_default_g ? byte1[7:0] : 
205
//              lsu_st_hw_le_g ? byte0[7:0] :   
206
//                       lsu_st_w_or_dbl_le_g ? byte2[7:0] :
207
//                               lsu_st_x_le_g ? byte6[7:0] : 8'bxxxx_xxxx ; 
208
 
209
mux4ds #(8) swap_byte1_mx (
210
 .in0 (byte1[7:0]), .sel0(lsu_swap_sel_default_g),
211
 .in1 (byte0[7:0]), .sel1(lsu_st_hw_le_g),
212
 .in2 (byte2[7:0]), .sel2(lsu_st_w_or_dbl_le_g),
213
 .in3 (byte6[7:0]), .sel3(lsu_st_x_le_g),
214
 .dout (swap_byte1[7:0]));
215
 
216
// swap byte2
217
//assign        swap_byte2[7:0] =                //@@ bw_u1_muxi31d_4x
218
//      lsu_swap_sel_default_g ? byte2[7:0] : 
219
//              lsu_st_w_or_dbl_le_g ? byte1[7:0] :
220
//                      lsu_st_x_le_g ? byte5[7:0] : 8'bxxxx_xxxx ; 
221
 
222
mux3ds #(8) swap_byte2_mx (
223
  .in0 (byte2[7:0]), .sel0(lsu_swap_sel_default_byte_7_2_g),
224
  .in1 (byte1[7:0]), .sel1(lsu_st_w_or_dbl_le_g),
225
  .in2 (byte5[7:0]), .sel2(lsu_st_x_le_g),
226
  .dout (swap_byte2[7:0]));
227
 
228
// swap byte3
229
//assign        swap_byte3[7:0] =                 //@@ bw_u1_muxi31d_4x
230
//      lsu_swap_sel_default_g ? byte3[7:0] : 
231
//              lsu_st_w_or_dbl_le_g ? byte0[7:0] :
232
//                      lsu_st_x_le_g ? byte4[7:0] : 8'bxxxx_xxxx ; 
233
 
234
mux3ds #(8) swap_byte3_mx (
235
 .in0 (byte3[7:0]), .sel0(lsu_swap_sel_default_byte_7_2_g),
236
 .in1 (byte0[7:0]), .sel1(lsu_st_w_or_dbl_le_g),
237
 .in2 (byte4[7:0]), .sel2(lsu_st_x_le_g),
238
 .dout(swap_byte3[7:0]));
239
 
240
// swap byte4
241
//assign        swap_byte4[7:0] =                 //@@ bw_u1_muxi31d_4x
242
//      lsu_swap_sel_default_g ? byte4[7:0] : 
243
//               lsu_st_w_or_dbl_le_g ? byte7[7:0] :
244
//                       lsu_st_x_le_g ? byte3[7:0] : 8'bxxxx_xxxx ; 
245
 
246
mux3ds #(8) swap_byte4_mx (
247
.in0 (byte4[7:0]), .sel0(lsu_swap_sel_default_byte_7_2_g),
248
.in1 (byte7[7:0]), .sel1(lsu_st_w_or_dbl_le_g),
249
.in2 (byte3[7:0]), .sel2(lsu_st_x_le_g),
250
.dout(swap_byte4[7:0]));
251
 
252
// swap byte5
253
//assign        swap_byte5[7:0] =                 //@@ bw_u1_muxi31d_4x
254
//      lsu_swap_sel_default_g ? byte5[7:0] : 
255
//               lsu_st_w_or_dbl_le_g ? byte6[7:0] :
256
//                        lsu_st_x_le_g ? byte2[7:0] : 8'bxxxx_xxxx ; 
257
 
258
mux3ds #(8) swap_byte5_mx (
259
 .in0 (byte5[7:0]), .sel0(lsu_swap_sel_default_byte_7_2_g),
260
 .in1 (byte6[7:0]), .sel1(lsu_st_w_or_dbl_le_g),
261
 .in2 (byte2[7:0]), .sel2(lsu_st_x_le_g),
262
 .dout(swap_byte5[7:0]));
263
 
264
// swap byte6
265
//assign        swap_byte6[7:0] =                 //@@ bw_u1_muxi31d_4x
266
//      lsu_swap_sel_default_g ? byte6[7:0] : 
267
//               lsu_st_w_or_dbl_le_g ? byte5[7:0] :
268
//                        lsu_st_x_le_g ? byte1[7:0] : 8'bxxxx_xxxx ; 
269
 
270
mux3ds #(8) swap_byte6_mx (
271
 .in0 (byte6[7:0]), .sel0 (lsu_swap_sel_default_byte_7_2_g),
272
 .in1 (byte5[7:0]), .sel1 (lsu_st_w_or_dbl_le_g),
273
 .in2 (byte1[7:0]), .sel2 (lsu_st_x_le_g),
274
 .dout(swap_byte6[7:0]));
275
 
276
// swap byte7
277
//assign        swap_byte7[7:0] =                 //@@ bw_u1_muxi31d_4x
278
//      lsu_swap_sel_default_g ? byte7[7:0] : 
279
//               lsu_st_w_or_dbl_le_g ? byte4[7:0] :
280
//                  lsu_st_x_le_g ? byte0[7:0] : 8'bxxxx_xxxx ; 
281
 
282
mux3ds #(8) swap_byte7_mx (
283
 .in0 (byte7[7:0]), .sel0 (lsu_swap_sel_default_byte_7_2_g),
284
 .in1 (byte4[7:0]), .sel1 (lsu_st_w_or_dbl_le_g),
285
 .in2 (byte0[7:0]), .sel2 (lsu_st_x_le_g),
286
 .dout (swap_byte7[7:0]));
287
 
288
// Now replicate date across 8 bytes.
289
 
290
// replicated byte0
291
assign  lsu_stb_st_data_g[7:0] = swap_byte0[7:0] ;        // all data sizes //@@ bw_u1_inv_8x
292
 
293
// replicated byte1
294
assign  lsu_stb_st_data_g[15:8] =                 //@@ bw_u1_muxi21_6x
295
                st_sz_b_g ? swap_byte0[7:0] : swap_byte1[7:0] ;
296
 
297
// replicated byte2
298
assign  lsu_stb_st_data_g[23:16] =                //@@ bw_u1_muxi21_6x
299
                st_sz_bhw_g ? swap_byte0[7:0] : swap_byte2[7:0] ;
300
 
301
// replicated byte3
302
//assign        lsu_stb_st_data_g[31:24] =                 //@@ bw_u1_muxi31d_6x
303
//              st_sz_b_g ? swap_byte0 :                        // swap_byte
304
//                      st_sz_hw_g ? swap_byte1 :       // hword
305
//                              st_sz_wdw_g ? swap_byte3 : // dword or word
306
//                                      8'bxxxx_xxxx ;
307
 
308
   wire st_sz_b_g_sel, st_sz_hw_g_sel, st_sz_wdw_g_sel;
309
   assign st_sz_b_g_sel = st_sz_b_g & ~rst_tri_en;
310
   assign st_sz_hw_g_sel = st_sz_hw_g & ~rst_tri_en;
311
   assign st_sz_wdw_g_sel = st_sz_wdw_g | rst_tri_en;
312
 
313
mux3ds #(8) rpl_byte3_mx (
314
  .in0 (swap_byte0[7:0]), .sel0 (st_sz_b_g_sel),
315
  .in1 (swap_byte1[7:0]), .sel1 (st_sz_hw_g_sel),
316
  .in2 (swap_byte3[7:0]), .sel2 (st_sz_wdw_g_sel),
317
  .dout (lsu_stb_st_data_g[31:24]));
318
 
319
// replicated byte4
320
assign  lsu_stb_st_data_g[39:32] =                 //@@ bw_u1_muxi21_6x
321
        st_sz_bhww_g ? swap_byte0[7:0] : swap_byte4[7:0] ;        // dword
322
 
323
 
324
// replicated byte5
325
//assign        lsu_stb_st_data_g[47:40] =                 //@@ bw_u1_muxi31d_6x
326
//              st_sz_b_g ? swap_byte0 :                        // swap_byte 
327
//                      st_sz_hww_g ? swap_byte1 :      // hword or word
328
//                              st_sz_dw_g ? swap_byte5 : // dword
329
//                                      8'bxxxx_xxxx ;
330
 
331
    wire  st_sz_hww_g_sel, st_sz_dw_g_sel;
332
   assign st_sz_hww_g_sel = st_sz_hww_g & ~rst_tri_en;
333
   assign st_sz_dw_g_sel = st_sz_dw_g | rst_tri_en;
334
 
335
mux3ds #(8) rpl_byte5_mx (
336
  .in0 (swap_byte0[7:0]), .sel0(st_sz_b_g_sel),
337
  .in1 (swap_byte1[7:0]), .sel1(st_sz_hww_g_sel),
338
  .in2 (swap_byte5[7:0]), .sel2(st_sz_dw_g_sel),
339
  .dout(lsu_stb_st_data_g[47:40]));
340
 
341
// replicated byte6
342
//assign        lsu_stb_st_data_g[55:48] =                 //@@ bw_u1_muxi31d_6x
343
//              st_sz_bhw_g ? swap_byte0 :              // swap_byte or hword
344
//                      st_sz_w_g ? swap_byte2 :                // word
345
//                              st_sz_wdw_g ? swap_byte6 : // dword
346
//                                      8'bxxxx_xxxx ;
347
 
348
   wire   st_sz_bhw_g_sel, st_sz_w_g_sel;
349
   assign st_sz_bhw_g_sel = st_sz_bhw_g & ~rst_tri_en;
350
   assign st_sz_w_g_sel = st_sz_w_g & ~rst_tri_en;
351
 
352
 
353
mux3ds #(8) rpl_byte6_mx (
354
  .in0 (swap_byte0[7:0]),
355
  .in1 (swap_byte2[7:0]),
356
  .in2 (swap_byte6[7:0]),
357
  .sel0(st_sz_bhw_g_sel),
358
  .sel1(st_sz_w_g_sel),
359
  .sel2(st_sz_dw_g_sel),
360
  .dout(lsu_stb_st_data_g[55:48]));
361
 
362
// replicated byte7
363
//assign        lsu_stb_st_data_g[63:56] =                //@@ bw_u1_muxi41d_6x
364
//              st_sz_b_g ? swap_byte0 :                        // swap_byte
365
//                      st_sz_hw_g ? swap_byte1 :       // hword
366
//                              st_sz_w_g ? swap_byte3 :        // word
367
//                                      st_sz_dw_g ? swap_byte7 : // dword
368
//                                              8'bxxxx_xxxx ;
369
 
370
mux4ds #(8) rpl_byte7_mx (
371
  .in0(swap_byte0[7:0]), .sel0(st_sz_b_g_sel),
372
  .in1(swap_byte1[7:0]), .sel1(st_sz_hw_g_sel),
373
  .in2(swap_byte3[7:0]), .sel2(st_sz_w_g_sel),
374
  .in3(swap_byte7[7:0]), .sel3(st_sz_dw_g_sel),
375
  .dout (lsu_stb_st_data_g[63:56]));
376
 
377
//=========================================================
378
//stb rdata buffer
379
   assign stb_rdata_ramd_buf[69:0] = stb_rdata_ramd[69:0];
380
   assign stb_rdata_ramd_b74_buf = stb_rdata_ramd_b74;
381
 
382
endmodule

powered by: WebSVN 2.1.0

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