1 | // ========== Copyright Header Begin ========================================== |
---|
2 | // |
---|
3 | // OpenSPARC T1 Processor File: sparc_exu_shft.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 | // Module Name: sparc_exu_shft |
---|
24 | // Description: This block implements right and left shifting of any amount |
---|
25 | // from 0 to 63. |
---|
26 | */ |
---|
27 | |
---|
28 | |
---|
29 | module sparc_exu_shft (/*AUTOARG*/ |
---|
30 | // Outputs |
---|
31 | shft_alu_shift_out_e, |
---|
32 | // Inputs |
---|
33 | ecl_shft_lshift_e_l, ecl_shft_op32_e, ecl_shft_shift4_e, |
---|
34 | ecl_shft_shift1_e, byp_alu_rs1_data_e, byp_alu_rs2_data_e, |
---|
35 | ecl_shft_enshift_e_l, ecl_shft_extendbit_e, |
---|
36 | ecl_shft_extend32bit_e_l |
---|
37 | ) ; |
---|
38 | input ecl_shft_lshift_e_l; // if 0 do left shift. else right shift |
---|
39 | input ecl_shft_op32_e; // indicates 32 bit operation so upper 32 = 0 |
---|
40 | //input [3:0] ecl_shft_shift16_e;// [48, 32, 16, 0] shift |
---|
41 | input [3:0] ecl_shft_shift4_e;// [12, 8, 4, 0] shift |
---|
42 | input [3:0] ecl_shft_shift1_e;// [3, 2, 1, 0] shift |
---|
43 | input [63:0] byp_alu_rs1_data_e; |
---|
44 | input [5:4] byp_alu_rs2_data_e; |
---|
45 | input ecl_shft_enshift_e_l;// enables inputs to shifter |
---|
46 | input ecl_shft_extendbit_e; |
---|
47 | input ecl_shft_extend32bit_e_l; |
---|
48 | |
---|
49 | output [63:0] shft_alu_shift_out_e; |
---|
50 | |
---|
51 | wire [63:0] shifter_input; // enabled input |
---|
52 | wire [63:0] shifter_input_b1;// buffered input |
---|
53 | wire [63:0] rshifterinput; // masked for 32-bit operation |
---|
54 | wire [63:0] rshifterinput_b1; // masked for 32-bit operation |
---|
55 | wire [63:0] lshift16; // output of the respective mux |
---|
56 | wire [63:0] rshift16; |
---|
57 | wire [63:0] lshift4; |
---|
58 | wire [63:0] rshift4; |
---|
59 | wire [63:0] lshift1; |
---|
60 | wire [63:0] rshift1; |
---|
61 | wire [63:0] lshift16_b1; // buffed output of the respective mux |
---|
62 | wire [63:0] rshift16_b1; |
---|
63 | wire [63:0] lshift4_b1; |
---|
64 | wire [63:0] rshift4_b1; |
---|
65 | wire [47:0] shft_extendbit_e; |
---|
66 | wire [3:0] shift16_e; |
---|
67 | wire shiftby_msb; |
---|
68 | wire extend32bit_e; |
---|
69 | |
---|
70 | assign shiftby_msb = byp_alu_rs2_data_e[5] & ~ecl_shft_op32_e; |
---|
71 | assign shift16_e[0] = ~shiftby_msb & ~byp_alu_rs2_data_e[4]; |
---|
72 | assign shift16_e[1] = ~shiftby_msb & byp_alu_rs2_data_e[4]; |
---|
73 | assign shift16_e[2] = shiftby_msb & ~byp_alu_rs2_data_e[4]; |
---|
74 | assign shift16_e[3] = shiftby_msb & byp_alu_rs2_data_e[4]; |
---|
75 | // enable inputs |
---|
76 | assign shifter_input[63:0] = byp_alu_rs1_data_e[63:0] & {64{~ecl_shft_enshift_e_l}}; |
---|
77 | |
---|
78 | // mux between left and right shifts |
---|
79 | dp_mux2es #(64) mux_shiftout(.dout(shft_alu_shift_out_e[63:0]), .in0(lshift1[63:0]), |
---|
80 | .in1(rshift1[63:0]), |
---|
81 | .sel(ecl_shft_lshift_e_l)); |
---|
82 | |
---|
83 | // mask out top for r_shift 32bit |
---|
84 | assign extend32bit_e = ~ecl_shft_extend32bit_e_l; |
---|
85 | dp_mux2es #(32) mux_rshift_extend(.dout(rshifterinput[63:32]), |
---|
86 | .in0(byp_alu_rs1_data_e[63:32]), |
---|
87 | .in1({32{extend32bit_e}}), |
---|
88 | .sel(ecl_shft_op32_e)); |
---|
89 | assign rshifterinput[31:0] = shifter_input[31:0]; |
---|
90 | |
---|
91 | assign shft_extendbit_e[47:0] = {48{ecl_shft_extendbit_e}}; |
---|
92 | |
---|
93 | // right shift muxes |
---|
94 | mux4ds #(64) mux_right16(.dout(rshift16[63:0]), |
---|
95 | .in0({shft_extendbit_e[47:0], rshifterinput_b1[63:48]}), |
---|
96 | .in1({shft_extendbit_e[47:16], rshifterinput_b1[63:32]}), |
---|
97 | .in2({shft_extendbit_e[47:32], rshifterinput_b1[63:16]}), |
---|
98 | .in3(rshifterinput_b1[63:0]), |
---|
99 | .sel0(shift16_e[3]), |
---|
100 | .sel1(shift16_e[2]), |
---|
101 | .sel2(shift16_e[1]), |
---|
102 | .sel3(shift16_e[0])); |
---|
103 | mux4ds #(64) mux_right4(.dout(rshift4[63:0]), |
---|
104 | .in0({shft_extendbit_e[47:36], rshift16_b1[63:12]}), |
---|
105 | .in1({shft_extendbit_e[47:40], rshift16_b1[63:8]}), |
---|
106 | .in2({shft_extendbit_e[47:44], rshift16_b1[63:4]}), |
---|
107 | .in3(rshift16_b1[63:0]), |
---|
108 | .sel0(ecl_shft_shift4_e[3]), |
---|
109 | .sel1(ecl_shft_shift4_e[2]), |
---|
110 | .sel2(ecl_shft_shift4_e[1]), |
---|
111 | .sel3(ecl_shft_shift4_e[0])); |
---|
112 | mux4ds #(64) mux_right1(.dout(rshift1[63:0]), |
---|
113 | .in0({shft_extendbit_e[47:45], rshift4_b1[63:3]}), |
---|
114 | .in1({shft_extendbit_e[47:46], rshift4_b1[63:2]}), |
---|
115 | .in2({shft_extendbit_e[47], rshift4_b1[63:1]}), |
---|
116 | .in3(rshift4_b1[63:0]), |
---|
117 | .sel0(ecl_shft_shift1_e[3]), |
---|
118 | .sel1(ecl_shft_shift1_e[2]), |
---|
119 | .sel2(ecl_shft_shift1_e[1]), |
---|
120 | .sel3(ecl_shft_shift1_e[0])); |
---|
121 | |
---|
122 | // buffer signals to right muxes |
---|
123 | dp_buffer #(64) buf_rshiftin(.dout(rshifterinput_b1[63:0]), .in(rshifterinput[63:0])); |
---|
124 | dp_buffer #(64) buf_rshift16(.dout(rshift16_b1[63:0]), .in(rshift16[63:0])); |
---|
125 | dp_buffer #(64) buf_rshift4(.dout(rshift4_b1[63:0]), .in(rshift4[63:0])); |
---|
126 | |
---|
127 | // left shift muxes |
---|
128 | mux4ds #(64) mux_left16(.dout(lshift16[63:0]), |
---|
129 | .in0({shifter_input_b1[15:0], {48{1'b0}}}), |
---|
130 | .in1({shifter_input_b1[31:0], {32{1'b0}}}), |
---|
131 | .in2({shifter_input_b1[47:0], {16{1'b0}}}), |
---|
132 | .in3(shifter_input_b1[63:0]), |
---|
133 | .sel0(shift16_e[3]), |
---|
134 | .sel1(shift16_e[2]), |
---|
135 | .sel2(shift16_e[1]), |
---|
136 | .sel3(shift16_e[0])); |
---|
137 | mux4ds #(64) mux_left4(.dout(lshift4[63:0]), |
---|
138 | .in0({lshift16_b1[51:0], {12{1'b0}}}), |
---|
139 | .in1({lshift16_b1[55:0], {8{1'b0}}}), |
---|
140 | .in2({lshift16_b1[59:0], {4{1'b0}}}), |
---|
141 | .in3(lshift16_b1[63:0]), |
---|
142 | .sel0(ecl_shft_shift4_e[3]), |
---|
143 | .sel1(ecl_shft_shift4_e[2]), |
---|
144 | .sel2(ecl_shft_shift4_e[1]), |
---|
145 | .sel3(ecl_shft_shift4_e[0])); |
---|
146 | mux4ds #(64) mux_left1(.dout(lshift1[63:0]), |
---|
147 | .in0({lshift4_b1[60:0], {3{1'b0}}}), |
---|
148 | .in1({lshift4_b1[61:0], {2{1'b0}}}), |
---|
149 | .in2({lshift4_b1[62:0], {1{1'b0}}}), |
---|
150 | .in3(lshift4_b1[63:0]), |
---|
151 | .sel0(ecl_shft_shift1_e[3]), |
---|
152 | .sel1(ecl_shft_shift1_e[2]), |
---|
153 | .sel2(ecl_shft_shift1_e[1]), |
---|
154 | .sel3(ecl_shft_shift1_e[0])); |
---|
155 | |
---|
156 | // buffer signals to left muxes |
---|
157 | dp_buffer #(64) buf_lshiftin(.dout(shifter_input_b1[63:0]), .in(shifter_input[63:0])); |
---|
158 | dp_buffer #(64) buf_lshift16(.dout(lshift16_b1[63:0]), .in(lshift16[63:0])); |
---|
159 | dp_buffer #(64) buf_lshift4(.dout(lshift4_b1[63:0]), .in(lshift4[63:0])); |
---|
160 | |
---|
161 | |
---|
162 | endmodule // sparc_exu_shft |
---|