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

Revision 6, 5.0 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_reg.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_exu_reg (/*AUTOARG*/
22   // Outputs
23   data_out, 
24   // Inputs
25   clk, se, thr_out, wen_w, thr_w, data_in_w
26   ) ;
27   parameter SIZE = 3;
28
29   input     clk;
30   input     se;
31   input [3:0]       thr_out;
32   input             wen_w;
33   input [3:0]       thr_w;
34   input [SIZE -1:0] data_in_w;
35
36   output [SIZE-1:0] data_out;
37
38   wire [SIZE-1:0]   data_thr0;
39   wire [SIZE-1:0]   data_thr1;
40   wire [SIZE-1:0]   data_thr2;
41   wire [SIZE-1:0]   data_thr3;
42   wire [SIZE-1:0]   data_thr0_next;
43   wire [SIZE-1:0]   data_thr1_next;
44   wire [SIZE-1:0]   data_thr2_next;
45   wire [SIZE-1:0]   data_thr3_next;
46
47   wire          wen_thr0_w;
48   wire          wen_thr1_w;
49   wire          wen_thr2_w;
50   wire          wen_thr3_w;
51
52   //////////////////////////////////
53   //  Output selection for reg
54   //////////////////////////////////
55`ifdef FPGA_SYN_1THREAD
56   assign        data_out[SIZE -1:0] = data_thr0[SIZE -1:0];
57   assign        wen_thr0_w = (thr_w[0] & wen_w);
58   // mux between new and current value
59   mux2ds #(SIZE) data_next0_mux(.dout(data_thr0_next[SIZE -1:0]),
60                               .in0(data_thr0[SIZE -1:0]),
61                               .in1(data_in_w[SIZE -1:0]),
62                               .sel0(~wen_thr0_w),
63                               .sel1(wen_thr0_w));   
64   dff_s #(SIZE) dff_reg_thr0(.din(data_thr0_next[SIZE -1:0]), .clk(clk), .q(data_thr0[SIZE -1:0]),
65                       .se(se), .si(), .so());
66`else // !`ifdef FPGA_SYN_1THREAD
67
68   // mux between the 4 regs
69   mux4ds #(SIZE) mux_data_out1(.dout(data_out[SIZE -1:0]), .sel0(thr_out[0]),
70                               .sel1(thr_out[1]), .sel2(thr_out[2]),
71                               .sel3(thr_out[3]), .in0(data_thr0[SIZE -1:0]),
72                               .in1(data_thr1[SIZE -1:0]), .in2(data_thr2[SIZE -1:0]),
73                               .in3(data_thr3[SIZE -1:0]));
74   
75   //////////////////////////////////////
76   //  Storage of reg
77   //////////////////////////////////////
78   // enable input for each thread
79   assign        wen_thr0_w = (thr_w[0] & wen_w);
80   assign        wen_thr1_w = (thr_w[1] & wen_w);
81   assign        wen_thr2_w = (thr_w[2] & wen_w);
82   assign        wen_thr3_w = (thr_w[3] & wen_w);
83
84   // mux between new and current value
85   mux2ds #(SIZE) data_next0_mux(.dout(data_thr0_next[SIZE -1:0]),
86                               .in0(data_thr0[SIZE -1:0]),
87                               .in1(data_in_w[SIZE -1:0]),
88                               .sel0(~wen_thr0_w),
89                               .sel1(wen_thr0_w));
90   mux2ds #(SIZE) data_next1_mux(.dout(data_thr1_next[SIZE -1:0]),
91                               .in0(data_thr1[SIZE -1:0]),
92                               .in1(data_in_w[SIZE -1:0]),
93                               .sel0(~wen_thr1_w),
94                               .sel1(wen_thr1_w));
95   mux2ds #(SIZE) data_next2_mux(.dout(data_thr2_next[SIZE -1:0]),
96                               .in0(data_thr2[SIZE -1:0]),
97                               .in1(data_in_w[SIZE -1:0]),
98                               .sel0(~wen_thr2_w),
99                               .sel1(wen_thr2_w));
100   mux2ds #(SIZE) data_next3_mux(.dout(data_thr3_next[SIZE -1:0]),
101                               .in0(data_thr3[SIZE -1:0]),
102                               .in1(data_in_w[SIZE -1:0]),
103                               .sel0(~wen_thr3_w),
104                               .sel1(wen_thr3_w));
105
106   // store new value
107   dff_s #(SIZE) dff_reg_thr0(.din(data_thr0_next[SIZE -1:0]), .clk(clk), .q(data_thr0[SIZE -1:0]),
108                       .se(se), .si(), .so());
109   dff_s #(SIZE) dff_reg_thr1(.din(data_thr1_next[SIZE -1:0]), .clk(clk), .q(data_thr1[SIZE -1:0]),
110                       .se(se), .si(), .so());
111   dff_s #(SIZE) dff_reg_thr2(.din(data_thr2_next[SIZE -1:0]), .clk(clk), .q(data_thr2[SIZE -1:0]),
112                       .se(se), .si(), .so());
113   dff_s #(SIZE) dff_reg_thr3(.din(data_thr3_next[SIZE -1:0]), .clk(clk), .q(data_thr3[SIZE -1:0]),
114                       .se(se), .si(), .so());
115`endif // !`ifdef FPGA_SYN_1THREAD
116   
117endmodule // sparc_exu_reg
Note: See TracBrowser for help on using the repository browser.