source: XOpenSparcT1/trunk/T1-CPU/exu/sparc_exu_alu.v @ 6

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

versione iniziale opensparc

Line 
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T1 Processor File: sparc_exu_alu.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_alu
24*/
25
26module sparc_exu_alu
27(
28 /*AUTOARG*/
29   // Outputs
30   so, alu_byp_rd_data_e, exu_ifu_brpc_e, exu_lsu_ldst_va_e, 
31   exu_lsu_early_va_e, exu_mmu_early_va_e, alu_ecl_add_n64_e, 
32   alu_ecl_add_n32_e, alu_ecl_log_n64_e, alu_ecl_log_n32_e, 
33   alu_ecl_zhigh_e, alu_ecl_zlow_e, exu_ifu_regz_e, exu_ifu_regn_e, 
34   alu_ecl_adderin2_63_e, alu_ecl_adderin2_31_e, 
35   alu_ecl_adder_out_63_e, alu_ecl_cout32_e, alu_ecl_cout64_e_l, 
36   alu_ecl_mem_addr_invalid_e_l, 
37   // Inputs
38   rclk, se, si, byp_alu_rs1_data_e, byp_alu_rs2_data_e_l, 
39   byp_alu_rs3_data_e, byp_alu_rcc_data_e, ecl_alu_cin_e, 
40   ifu_exu_invert_d, ecl_alu_log_sel_and_e, ecl_alu_log_sel_or_e, 
41   ecl_alu_log_sel_xor_e, ecl_alu_log_sel_move_e, 
42   ecl_alu_out_sel_sum_e_l, ecl_alu_out_sel_rs3_e_l, 
43   ecl_alu_out_sel_shift_e_l, ecl_alu_out_sel_logic_e_l, 
44   shft_alu_shift_out_e, ecl_alu_sethi_inst_e, ifu_lsu_casa_e
45   );
46   input rclk;
47   input se;
48   input si;
49   input [63:0] byp_alu_rs1_data_e;   // source operand 1
50   input [63:0] byp_alu_rs2_data_e_l;  // source operand 2
51   input [63:0] byp_alu_rs3_data_e;  // source operand 3
52   input [63:0] byp_alu_rcc_data_e;  // source operand for reg condition codes
53   input        ecl_alu_cin_e;            // cin for adder
54   input        ifu_exu_invert_d;
55   input  ecl_alu_log_sel_and_e;// These 4 wires are select lines for the logic
56   input  ecl_alu_log_sel_or_e;// block mux.  They are active high and choose the
57   input  ecl_alu_log_sel_xor_e;// output they describe.
58   input  ecl_alu_log_sel_move_e;
59   input  ecl_alu_out_sel_sum_e_l;// The following 4 are select lines for
60   input  ecl_alu_out_sel_rs3_e_l;// the output stage mux.  They are active high
61   input  ecl_alu_out_sel_shift_e_l;// and choose the output of the respective block.
62   input  ecl_alu_out_sel_logic_e_l;
63   input [63:0] shft_alu_shift_out_e;// result from shifter
64   input        ecl_alu_sethi_inst_e;
65   input        ifu_lsu_casa_e;
66   
67   output       so;
68   output [63:0] alu_byp_rd_data_e;          // alu result
69   output [47:0] exu_ifu_brpc_e;// branch pc output
70   output [47:0] exu_lsu_ldst_va_e; // address for lsu
71   output [10:3] exu_lsu_early_va_e; // faster bits for cache
72   output [7:0]  exu_mmu_early_va_e;
73   output        alu_ecl_add_n64_e;
74   output        alu_ecl_add_n32_e;
75   output        alu_ecl_log_n64_e;
76   output        alu_ecl_log_n32_e;
77   output        alu_ecl_zhigh_e;
78   output        alu_ecl_zlow_e;
79   output    exu_ifu_regz_e;              // rs1_data == 0
80   output    exu_ifu_regn_e;
81   output    alu_ecl_adderin2_63_e;
82   output    alu_ecl_adderin2_31_e;
83   output    alu_ecl_adder_out_63_e;
84   output    alu_ecl_cout32_e;       // To ecl of sparc_exu_ecl.v
85   output    alu_ecl_cout64_e_l;       // To ecl of sparc_exu_ecl.v
86   output    alu_ecl_mem_addr_invalid_e_l;// adder_out[63:48] not all 1 or all 0
87                               
88   wire         clk;
89   wire [63:0] logic_out;       // result of logic block
90   wire [63:0] adder_out;       // result of adder
91   wire [63:0] spr_out;         // result of sum predict
92   wire [63:0] zcomp_in;        // result going to zcompare
93   wire [63:0] va_e;            // complete va
94   wire [63:0] byp_alu_rs2_data_e;
95   wire        invert_e;
96   wire        ecl_alu_out_sel_sum_e;
97   wire        ecl_alu_out_sel_rs3_e;
98   wire        ecl_alu_out_sel_shift_e;
99   wire        ecl_alu_out_sel_logic_e;
100   assign      clk = rclk;
101   assign      byp_alu_rs2_data_e[63:0] = ~byp_alu_rs2_data_e_l[63:0];
102   assign      ecl_alu_out_sel_sum_e = ~ecl_alu_out_sel_sum_e_l;
103   assign      ecl_alu_out_sel_rs3_e = ~ecl_alu_out_sel_rs3_e_l;
104   assign      ecl_alu_out_sel_shift_e = ~ecl_alu_out_sel_shift_e_l;
105   assign      ecl_alu_out_sel_logic_e = ~ecl_alu_out_sel_logic_e_l;
106
107   // Zero comparison for exu_ifu_regz_e
108   sparc_exu_aluzcmp64 regzcmp(.in(byp_alu_rcc_data_e[63:0]), .zero64(exu_ifu_regz_e));
109   assign     exu_ifu_regn_e = byp_alu_rcc_data_e[63];
110
111   // mux between adder output and rs1 (for casa) for lsu va
112   dp_mux2es #(64)  lsu_va_mux(.dout(va_e[63:0]),
113                               .in0(adder_out[63:0]),
114                               .in1(byp_alu_rs1_data_e[63:0]),
115                               .sel(ifu_lsu_casa_e));
116   assign     exu_lsu_ldst_va_e[47:0] = va_e[47:0];
117   // for bits 10:4 we have a separate bus that is not used for cas
118   assign     exu_lsu_early_va_e[10:3] = adder_out[10:3];
119   // mmu needs bits 7:0
120   assign     exu_mmu_early_va_e[7:0] = adder_out[7:0];
121   
122   
123   // Adder
124   assign     exu_ifu_brpc_e[47:0] = adder_out[47:0];
125   assign     alu_ecl_adder_out_63_e = adder_out[63];
126   sparc_exu_aluaddsub addsub(.adder_out(adder_out[63:0]),
127                              /*AUTOINST*/
128                              // Outputs
129                              .spr_out  (spr_out[63:0]),
130                              .alu_ecl_cout64_e_l(alu_ecl_cout64_e_l),
131                              .alu_ecl_cout32_e(alu_ecl_cout32_e),
132                              .alu_ecl_adderin2_63_e(alu_ecl_adderin2_63_e),
133                              .alu_ecl_adderin2_31_e(alu_ecl_adderin2_31_e),
134                              // Inputs
135                              .clk      (clk),
136                              .se       (se),
137                              .byp_alu_rs1_data_e(byp_alu_rs1_data_e[63:0]),
138                              .byp_alu_rs2_data_e(byp_alu_rs2_data_e[63:0]),
139                              .ecl_alu_cin_e(ecl_alu_cin_e),
140                              .ifu_exu_invert_d(ifu_exu_invert_d));
141
142   // Logic/pass rs2_data
143   dff_s invert_d2e(.din(ifu_exu_invert_d), .clk(clk), .q(invert_e), .se(se), .si(), .so());
144   sparc_exu_alulogic logic(.rs1_data(byp_alu_rs1_data_e[63:0]),
145                            .rs2_data(byp_alu_rs2_data_e[63:0]),
146                            .isand(ecl_alu_log_sel_and_e),
147                            .isor(ecl_alu_log_sel_or_e),
148                            .isxor(ecl_alu_log_sel_xor_e),
149                            .pass_rs2_data(ecl_alu_log_sel_move_e),
150                            .inv_logic(invert_e), .logic_out(logic_out[63:0]),
151                            .ifu_exu_sethi_inst_e(ecl_alu_sethi_inst_e));
152
153   // Mux between sum predict and logic outputs for zcc
154   dp_mux2es #(64)  zcompmux(.dout(zcomp_in[63:0]),
155                           .in0(logic_out[63:0]),
156                           .in1(spr_out[63:0]),
157                           .sel(ecl_alu_out_sel_sum_e));
158
159   // Zero comparison for zero cc
160//   sparc_exu_aluzcmp64 zcccmp(.in(zcomp_in[63:0]), .zero64(alu_ecl_z64_e),
161//                          .zero32(alu_ecl_z32_e));
162   assign        alu_ecl_zlow_e = ~(|zcomp_in[31:0]);
163   assign        alu_ecl_zhigh_e = ~(|zcomp_in[63:32]);
164
165   // Get Negative ccs
166   assign   alu_ecl_add_n64_e = adder_out[63];
167   assign   alu_ecl_add_n32_e = adder_out[31];
168   assign   alu_ecl_log_n64_e = logic_out[63];
169   assign   alu_ecl_log_n32_e = logic_out[31];
170
171   
172   // Mux for output
173   mux4ds #(64) output_mux(.dout(alu_byp_rd_data_e[63:0]), 
174                         .in0(adder_out[63:0]),
175                         .in1(byp_alu_rs3_data_e[63:0]),
176                         .in2(shft_alu_shift_out_e[63:0]),
177                         .in3(logic_out[63:0]), 
178                         .sel0(ecl_alu_out_sel_sum_e),
179                         .sel1(ecl_alu_out_sel_rs3_e),
180                         .sel2(ecl_alu_out_sel_shift_e),
181                         .sel3(ecl_alu_out_sel_logic_e));
182
183   // memory address checks
184   sparc_exu_alu_16eql chk_mem_addr(.equal(alu_ecl_mem_addr_invalid_e_l),
185                                    .in(va_e[63:47]));
186   
187endmodule  // sparc_exu_alu
Note: See TracBrowser for help on using the repository browser.