Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / dmu / rtl / dmu_psb_csrpipe_2.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dmu_psb_csrpipe_2.v
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35module dmu_psb_csrpipe_2
36 (
37 clk,
38 rst_l,
39 reg_in,
40 reg_out,
41 data0,
42 data1,
43 sel0,
44 sel1,
45 out
46 );
47
48//====================================================================
49// Polarity declarations
50//====================================================================
51input clk; // Clock signal
52input rst_l; // Reset signal
53input reg_in; // Set to constant. 0: sel* non-reg 1: sel* reg
54input reg_out; // Set to constant. 0: out non-reg 1: out registered
55input [`FIRE_CSRBUS_DATA_WIDTH-1:0] data0; // Read data
56input [`FIRE_CSRBUS_DATA_WIDTH-1:0] data1; // Read data
57input sel0; // Set to 1 if reg_in==0
58input sel1; // Set to 1 if reg_in==0
59output [`FIRE_CSRBUS_DATA_WIDTH-1:0] out; // Read data out
60
61//====================================================================
62// Type declarations
63//====================================================================
64wire clk; // Clock signal
65wire rst_l; // Reset signal
66wire reg_in; // Set to constant. 0: sel* non-reg 1: sel* reg
67wire reg_out; // Set to constant. 0: out non-reg 1: out registered
68wire [`FIRE_CSRBUS_DATA_WIDTH-1:0] data0; // Read data
69wire [`FIRE_CSRBUS_DATA_WIDTH-1:0] data1; // Read data
70wire sel0; // Set to 1 if reg_in==0
71wire sel1; // Set to 1 if reg_in==0
72wire [`FIRE_CSRBUS_DATA_WIDTH-1:0] out; // Read data out
73
74//====================================================================
75// Local variables
76//====================================================================
77reg [`FIRE_CSRBUS_DATA_WIDTH-1:0] out_p1;
78reg sel0_p1;
79reg sel1_p1;
80
81//====================================================================
82// Logic
83//====================================================================
84//select required ?
85wire sel0_int=reg_in?sel0_p1:sel0;
86wire sel1_int=reg_in?sel1_p1:sel1;
87
88//generate AND/OR
89wire [`FIRE_CSRBUS_DATA_WIDTH-1:0] out_d =
90 {`FIRE_CSRBUS_DATA_WIDTH { sel0_int } } & data0 |
91 {`FIRE_CSRBUS_DATA_WIDTH { sel1_int } } & data1;
92
93//reg out or combo
94assign out=reg_out?out_p1:out_d;
95
96//pipe control/data
97always @(posedge clk)
98 begin
99 if(~rst_l)
100 begin
101 sel0_p1<=1'b0;
102 sel1_p1<=1'b0;
103 out_p1<=`FIRE_CSRBUS_DATA_WIDTH'b0;
104 end
105 else
106 begin
107 sel0_p1<=sel0;
108 sel1_p1<=sel1;
109 out_p1<=out_d;
110 end
111 end
112
113endmodule // dmu_psb_csrpipe_2