source: XOpenSparcT1/trunk/T1-CPU/spu/spu_maexp.v @ 6

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

versione iniziale opensparc

Line 
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T1 Processor File: spu_maexp.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
22module spu_maexp (
23
24/*outputs*/
25spu_maexp_e_rd_oprnd_sel,
26spu_maexp_shift_e,
27spu_maexp_e_data_wen,
28spu_maexp_incr_es_ptr,
29
30spu_maexp_es_max_init,
31spu_maexp_es_e_ptr_rst,
32
33spu_maexp_done_set,
34spu_maexp_memren,
35
36spu_maexp_start_mulred_aequb,
37spu_maexp_start_mulred_anoteqb,
38
39spu_mactl_stxa_force_abort,
40
41/*inputs*/
42spu_maaddr_esmax,
43spu_maaddr_esmod64,
44spu_madp_e_eq_one,
45spu_mared_red_done,
46
47spu_mactl_iss_pulse_dly,
48spu_mactl_expop,
49
50spu_mactl_kill_op,
51
52se,
53reset,
54rclk);
55
56input reset;
57input rclk;
58input se;
59
60input spu_maaddr_esmax;
61input spu_maaddr_esmod64;
62input spu_madp_e_eq_one;
63input spu_mared_red_done;
64
65input spu_mactl_iss_pulse_dly;
66input spu_mactl_expop;
67input spu_mactl_kill_op;
68input spu_mactl_stxa_force_abort;
69// --------------------------------------------------------------------------------
70
71output spu_maexp_e_rd_oprnd_sel;
72output spu_maexp_shift_e;
73output spu_maexp_e_data_wen;
74output spu_maexp_incr_es_ptr;
75output spu_maexp_es_max_init;
76output spu_maexp_es_e_ptr_rst;
77
78output spu_maexp_done_set;
79output spu_maexp_memren;
80
81output spu_maexp_start_mulred_aequb;
82output spu_maexp_start_mulred_anoteqb;
83
84// --------------------------------------------------------------------------------
85// --------------------------------------------------------------------------------
86
87wire spu_maexp_exp_done,tr2idle_frm_esmax,tr2rde_frm_idle,tr2rde_frm_esmax,
88     tr2gotomulred1_frm_rde,tr2gotomulred1_frm_esmax,tr2echk_frm_gotomulred1,
89     tr2gotomulred2_frm_echk,tr2esmax_frm_gotomulred2,tr2esmax_frm_echk;
90// --------------------------------------------------------------------------------
91// --------------------------------------------------------------------------------
92wire cur_rde_state;
93wire local_stxa_abort;
94// --------------------------------------------------------------------------------
95// --------------------------------------------------------------------------------
96// -------------------------------------------------------------------------
97// we need a state set to indcate exp is done, and when an
98// masync gets issued later, then the load asi is returned.
99wire spu_maexp_done_wen = (spu_maexp_exp_done | spu_mactl_kill_op |
100                                        local_stxa_abort) & spu_mactl_expop ;
101wire spu_maexp_done_rst = reset | spu_mactl_iss_pulse_dly;
102
103dffre_s    #(1) spu_maexp_done_ff (
104        .din(1'b1) , 
105        .q(spu_maexp_done_set),
106        .en(spu_maexp_done_wen),
107        .rst(spu_maexp_done_rst), .clk (rclk), .se(se), .si(), .so()); 
108
109// --------------------------------------------------------------------------------
110
111
112// this was causing rd and wr contention in idct when running random diags. cur_rde_state
113//cause perr which caused expop to go to idle, but maaeqb state machine was in progress
114//and then a ldop was started which caused a rd of mem for ldop and a write during
115//maaeqb op in progress.
116
117//assign local_stxa_abort = (cur_rde_state | spu_mared_red_done)  & spu_mactl_stxa_force_abort;
118assign local_stxa_abort =  spu_mared_red_done & spu_mactl_stxa_force_abort;
119
120wire state_reset = reset | spu_maexp_exp_done | spu_mactl_kill_op |
121                                        local_stxa_abort;
122
123// -------------------------------------------------------------------------------
124// -------------------------------------------------------------------------------
125
126wire expop_start = spu_mactl_iss_pulse_dly & spu_mactl_expop;
127
128// -------------------------------------------------------------------------------
129// -------------------------------------------------------------------------------
130// -------------------------------------------------------------------------------
131// -------------------------------------------------------------------------------
132dff_s    #(1) idle_state_ff (
133        .din(nxt_idle_state) , 
134        .q(cur_idle_state),
135        .clk (rclk), .se(se), .si(), .so()); 
136
137dffr_s  #(1) rde_state_ff (
138        .din(nxt_rde_state) ,
139        .q(cur_rde_state),
140        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
141
142dffr_s  #(1) gotomulred1_state_ff (
143        .din(nxt_gotomulred1_state) , 
144        .q(cur_gotomulred1_state),
145        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
146
147dffr_s  #(1) echk_state_ff (
148        .din(nxt_echk_state) ,
149        .q(cur_echk_state),
150        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
151
152dffr_s  #(1) gotomulred2_state_ff (
153        .din(nxt_gotomulred2_state) ,
154        .q(cur_gotomulred2_state),
155        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
156
157dffr_s  #(1) esmax_state_ff (
158        .din(nxt_esmax_state) ,
159        .q(cur_esmax_state),
160        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
161
162// -------------------------------------------------------------------------------
163// -------------------------------------------------------------------------------
164// -------------------------------------------------------------------------------
165// -------------------------------------------------------------------------------
166// -------------------------------------------------------------------------------
167// transition to idle state
168
169assign tr2idle_frm_esmax = spu_maaddr_esmax & cur_esmax_state;
170
171assign spu_maexp_exp_done = tr2idle_frm_esmax;
172
173assign  nxt_idle_state = (
174                         state_reset | 
175                         tr2idle_frm_esmax |
176                         (cur_idle_state & ~expop_start));
177
178// -------------------------------------------------------------------------------
179// transition to rde state
180
181assign tr2rde_frm_idle = cur_idle_state & expop_start;
182
183/*
184wire dly_tr2rde_frm_idle;
185dff_s #(1) dly_tr2rde_frm_idle_ff (
186        .din(tr2rde_frm_idle) ,
187        .q(dly_tr2rde_frm_idle),
188        .clk (rclk),
189        .clk (rclk)
190        , .se(se), .si(), .so());
191*/
192
193
194assign tr2rde_frm_esmax = cur_esmax_state & ~spu_maaddr_esmax & spu_maaddr_esmod64;
195
196assign nxt_rde_state = (
197                          tr2rde_frm_idle |
198                          tr2rde_frm_esmax );
199
200// -------------------------------------------------------------------------------
201// transition to gotomulred1 state
202
203assign tr2gotomulred1_frm_rde = cur_rde_state; 
204assign tr2gotomulred1_frm_esmax = cur_esmax_state & ~spu_maaddr_esmax & 
205                                                ~spu_maaddr_esmod64; 
206
207assign nxt_gotomulred1_state = (
208                          tr2gotomulred1_frm_rde |
209                          tr2gotomulred1_frm_esmax |
210                          (cur_gotomulred1_state & ~spu_mared_red_done) );
211
212// -------------------------------------------------------------------------------
213// transition to echk state
214
215assign tr2echk_frm_gotomulred1 = cur_gotomulred1_state & spu_mared_red_done; 
216
217assign nxt_echk_state = (
218                          tr2echk_frm_gotomulred1);
219
220// -------------------------------------------------------------------------------
221// transition to gotomulred2 state
222
223assign tr2gotomulred2_frm_echk = cur_echk_state & spu_madp_e_eq_one; 
224
225assign nxt_gotomulred2_state = (
226                          tr2gotomulred2_frm_echk |
227                          (cur_gotomulred2_state & ~spu_mared_red_done) );
228
229// -------------------------------------------------------------------------------
230// transition to esmax state
231
232
233assign tr2esmax_frm_gotomulred2 = cur_gotomulred2_state & spu_mared_red_done; 
234assign tr2esmax_frm_echk = cur_echk_state & ~spu_madp_e_eq_one; 
235
236assign nxt_esmax_state = (
237                          tr2esmax_frm_gotomulred2 |
238                          tr2esmax_frm_echk);
239
240// -------------------------------------------------------------------------------
241// -------------------------------------------------------------------------------
242// -------------------------------------------------------------------------------
243// -------------------------------------------------------------------------------
244// SEL XXNM OR XANM
245
246/*
247wire spu_maexp_xxnm_sel_set = tr2rde_frm_idle | tr2esmax_frm_echk |
248                                        tr2esmax_frm_gotomulred2;
249
250wire spu_maexp_xxnm_sel_rst = state_reset | tr2echk_frm_gotomulred1;
251
252dffre_s #(1) xxnm_set_ff (
253        .din(1'b1) ,
254        .q(spu_maexp_xxnm_sel_q),
255        .en(spu_maexp_xxnm_sel_set),
256        .rst(spu_maexp_xxnm_sel_rst), .clk (rclk),
257        .rst(spu_maexp_xxnm_sel_rst), .clk (rclk)
258        , .se(se), .si(), .so());
259
260assign spu_maexp_b_to_x_sel = spu_maexp_xxnm_sel_q;
261assign spu_maexp_b_to_a_sel = ~spu_maexp_xxnm_sel_q;
262*/
263
264// -------------------------------------------------------------------------------
265
266assign spu_maexp_e_rd_oprnd_sel = tr2rde_frm_idle | tr2rde_frm_esmax;
267assign spu_maexp_memren = spu_maexp_e_rd_oprnd_sel;
268
269assign spu_maexp_shift_e = nxt_esmax_state; // muxsel in madp
270// write enable when data is from mamem or a shift write
271assign spu_maexp_e_data_wen = cur_rde_state | nxt_esmax_state;
272
273//assign spu_maexp_incr_es_ptr = tr2echk_frm_gotomulred1;
274assign spu_maexp_incr_es_ptr = tr2rde_frm_esmax | tr2gotomulred1_frm_esmax;
275
276assign spu_maexp_es_max_init = tr2rde_frm_idle;
277
278assign spu_maexp_es_e_ptr_rst = state_reset;
279// -------------------------------------------------------------------------------
280
281
282//assign spu_maexp_start_mulred = tr2gotomulred1_frm_rde | tr2gotomulred1_frm_esmax |
283//                                      tr2gotomulred2_frm_echk ;
284
285
286assign spu_maexp_start_mulred_aequb = tr2gotomulred1_frm_rde | tr2gotomulred1_frm_esmax;
287assign spu_maexp_start_mulred_anoteqb = tr2gotomulred2_frm_echk;
288
289
290
291
292// -------------------------------------------------------------------------------
293
294endmodule
Note: See TracBrowser for help on using the repository browser.