source: XOpenSparcT1/trunk/T1-CPU/mul/sparc_mul_cntl.v @ 6

Revision 6, 5.7 KB checked in by pntsvt00, 14 years ago (diff)

versione iniziale opensparc

Line 
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T1 Processor File: sparc_mul_cntl.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 ============================================
21module sparc_mul_cntl(
22  ecl_mul_req_vld,
23  spu_mul_req_vld,
24  spu_mul_acc,
25  spu_mul_areg_shf,
26  spu_mul_areg_rst,
27  spu_mul_mulres_lshft,
28  c0_act,
29  spick,
30  byp_sel,
31  byp_imm,
32  acc_imm,
33  acc_actc2,
34  acc_actc3,
35  acc_actc5,
36  acc_reg_enb,
37  acc_reg_rst,
38  acc_reg_shf,
39  x2,
40  mul_ecl_ack,
41  mul_spu_ack,
42  mul_spu_shf_ack,
43  rst_l,
44  rclk
45  );
46
47input           rclk;
48input           rst_l;                  // System rest
49input           ecl_mul_req_vld;        // Input request from EXU to MUL
50input           spu_mul_req_vld;        // Input request from SPU to MUL
51input           spu_mul_acc;            // 1: SPU mul op req will accumulate the ACCUM register
52input           spu_mul_areg_shf;       // ACCUM shift right 64-bit
53input           spu_mul_areg_rst;       // ACCUM reset; initialization of modular multiplication
54input           spu_mul_mulres_lshft;   // For x2 of op1*op2*2 left shift
55output          c0_act;                 // cycle-0 of muliplier operation
56output          spick;
57output          byp_sel;                // Bypass mux control
58output          byp_imm;
59output          acc_imm;
60output          acc_actc2, acc_actc3;   // accumulate enable for LSB-32 and All-96
61output          acc_actc5;              // accumulate enable for LSB-32 and All-96
62output          acc_reg_enb;            // ACCUM register enable
63output          acc_reg_rst;            // ACCUM register reset
64output          acc_reg_shf;            // ACCUM register shift select
65output          x2;
66output          mul_ecl_ack;            // Ack EXU multiplier operation is accepted.
67output          mul_spu_ack;            // Ack SPU multiplier operation is accepted.
68output          mul_spu_shf_ack;        // Ack SPU shift operation is accepted.
69
70reg             mul_ecl_ack_d;
71reg             mul_spu_ack_d;
72reg             c1_act;                 // Squash all mul requests from EXU and SPU if c1_act = 1
73reg             c2_act;                 // Squash bypass ACCUM mul request from SPU if c2_act = 1
74reg             c3_act;                 // Enable >>32 results back to CSA2 if c3_act = 1
75reg             favor_e;                // Flag for alternate picker, favor to EXU if f_state = 1
76reg             acc_actc1, acc_actc2, acc_actc3, acc_actc4, acc_actc5;
77reg             acc_reg_shf, acc_reg_rst; 
78
79wire            exu_req_vld, spu_req_vld;
80wire            epick;                  // Internal pick signals of exu, spu multiplier
81wire            nobyps;                 // Squash SPU bypass mul requests nobyps = 1
82wire            noshft;                 // Squash SPU bypass mul requests noshft = 1
83wire            acc_reg_shf_in;
84wire            spu_mul_byp = ~spu_mul_acc ; 
85wire            clk;
86
87
88/////////////////////////////////////////
89// Requests picker and general control //
90/////////////////////////////////////////
91
92assign clk = rclk ;
93
94assign  c0_act = epick | spick ;                                // Cycle0 of multiplier operation
95//assign        c1_act = mul_ecl_ack_d | mul_spu_ack_d ;                // Cycle1 of multiplier operation
96assign  nobyps = c1_act | acc_actc2 | acc_actc3 | acc_actc4 ;   // Cycles prevent the SPU bypass
97
98assign  x2 = spick & spu_mul_mulres_lshft;
99
100assign  exu_req_vld = ecl_mul_req_vld & ~c1_act ;
101assign  spu_req_vld = spu_mul_req_vld & ~c1_act & ~(nobyps & spu_mul_byp); 
102
103assign  epick = exu_req_vld & ( favor_e | ~spu_req_vld) ; 
104assign  spick = spu_req_vld & (~favor_e | ~exu_req_vld) ;
105
106// moved this one cycle earlier   
107assign    mul_spu_ack = rst_l & spick ;
108assign    mul_ecl_ack = rst_l & epick ;
109   
110always @(posedge clk)
111  begin
112        mul_ecl_ack_d <= rst_l & epick ;
113        mul_spu_ack_d <= rst_l & spick ;
114        c1_act <= rst_l & c0_act ;
115        c2_act <= rst_l & c1_act ; 
116        c3_act <= rst_l & c2_act ; 
117
118        favor_e <= rst_l & (mul_spu_ack_d & ~mul_ecl_ack_d);           
119  end
120
121/////////////////////////////////////////////////
122// SPU accumulate and bypass and shift control //
123/////////////////////////////////////////////////
124
125assign  byp_sel = spick & spu_mul_byp ; // SPU bypass operand is picked
126
127//////////////////////////////////////////////////////////////////////////
128//      No ACCUM >>= 64 allow if there are                              //
129//      1) accumulate mul before cycle4 which need to updated ACCUM     //
130//      2) Any mul at cyc3 which will use the same output mux at cyc-5  //
131//////////////////////////////////////////////////////////////////////////
132assign  noshft = acc_actc1 | acc_actc2 | c3_act | acc_actc4 ;
133
134                                                // Squash shifr if:
135assign  acc_reg_shf_in =   spu_mul_areg_shf &   // No shift request
136                          ~noshft           &   // SPU accum mul in cycle1~4 or EXU mul in cycle3
137                          ~acc_reg_shf ;        // reset SPU shift request for 1-cycle for signal upate
138
139always @(posedge clk)
140  begin
141        acc_reg_shf <= rst_l & acc_reg_shf_in ;         // latch ACCUM reg shift control
142
143        acc_reg_rst <=  spu_mul_areg_rst ;              // latch input control of ACCUM reg reset
144
145        acc_actc1 <= rst_l & (spick & spu_mul_acc) ;    // SPU MAC in cycle 1
146        acc_actc2 <= rst_l & acc_actc1 ;                        // SPU MAC in cycle 2
147        acc_actc3 <= rst_l & acc_actc2 ;                        // SPU MAC in cycle 3
148        acc_actc4 <= rst_l & acc_actc3 ;                        // SPU MAC in cycle 4
149        acc_actc5 <= rst_l & acc_actc4 ;                        // SPU MAC in cycle 5
150  end
151
152assign  mul_spu_shf_ack = acc_reg_shf;
153
154assign  byp_imm = acc_actc5 ;
155
156assign  acc_imm = (acc_actc2 & acc_actc4) | ((acc_actc2 | acc_actc3) & acc_actc5)  ; 
157
158assign  acc_reg_enb = acc_actc5 | acc_reg_shf;          // enable of ACCUM registers
159
160
161endmodule // sparc_mul_cntl
162
Note: See TracBrowser for help on using the repository browser.