source: XOpenSparcT1/trunk/T1-CPU/lsu/lsu_stb_rwdp.v @ 6

Revision 6, 13.5 KB checked in by pntsvt00, 13 years ago (diff)

versione iniziale opensparc

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