Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: niu_smx_regflag.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 ============================================ | |
35 | ||
36 | module niu_smx_regflag( | |
37 | /*AUTOARG*/ | |
38 | // Outputs | |
39 | rdata, rdata_bus, | |
40 | // Inputs | |
41 | clk, reset_l, set, rst0, rst1, set_addr, rst_addr0, rst_addr1, | |
42 | rst_first, rd, raddr | |
43 | ); | |
44 | ||
45 | // synopsys template | |
46 | ||
47 | parameter ADDR_WIDTH= 6; | |
48 | parameter ENTRY_SIZE= 1<<ADDR_WIDTH; | |
49 | ||
50 | ||
51 | input clk; | |
52 | input reset_l; | |
53 | input set; | |
54 | input rst0; | |
55 | input rst1; | |
56 | input [ADDR_WIDTH-1:0] set_addr; | |
57 | input [ADDR_WIDTH-1:0] rst_addr0; | |
58 | input [ADDR_WIDTH-1:0] rst_addr1; | |
59 | input rst_first; | |
60 | ||
61 | input rd; | |
62 | input [ADDR_WIDTH-1:0] raddr; | |
63 | output rdata; | |
64 | ||
65 | output [ENTRY_SIZE-1:0] rdata_bus; | |
66 | ||
67 | reg [ENTRY_SIZE-1:0] data; | |
68 | reg rdata; | |
69 | ||
70 | wire [ENTRY_SIZE-1:0] rdata_bus= data; | |
71 | ||
72 | wire [ENTRY_SIZE-1:0] decode_rst0_n; | |
73 | wire [ENTRY_SIZE-1:0] decode_rst1_n; | |
74 | wire [ENTRY_SIZE-1:0] decode_set_n; | |
75 | wire [ENTRY_SIZE-1:0] rst0_en_n= (decode_rst0_n & {ENTRY_SIZE{rst0}}); | |
76 | wire [ENTRY_SIZE-1:0] rst1_en_n= (decode_rst1_n & {ENTRY_SIZE{rst1}}); | |
77 | wire [ENTRY_SIZE-1:0] set_en_n= (decode_set_n & {ENTRY_SIZE{set}}); | |
78 | wire [ENTRY_SIZE-1:0] rst_en_n= rst0_en_n | rst1_en_n; | |
79 | wire [ENTRY_SIZE-1:0] data_rst_n= data & ~rst_en_n; | |
80 | wire [ENTRY_SIZE-1:0] data_set_n= data | set_en_n; | |
81 | ||
82 | // reset override set at same addr | |
83 | wire [ENTRY_SIZE-1:0] rf_data_n= data_set_n & ~rst_en_n; | |
84 | // set override reset at same addr | |
85 | wire [ENTRY_SIZE-1:0] sf_data_n= data_rst_n | set_en_n; | |
86 | ||
87 | integer i; | |
88 | ||
89 | always @(posedge clk) begin | |
90 | if(!reset_l) begin | |
91 | for(i=0; i<ENTRY_SIZE; i=i+1) | |
92 | data[i]<= `SMX_PD 1'b0; | |
93 | end | |
94 | else begin | |
95 | if(rst0 | rst1 | set) | |
96 | data<= `SMX_PD (rst_first)? rf_data_n : sf_data_n; | |
97 | end | |
98 | end | |
99 | ||
100 | always @(posedge clk) begin | |
101 | if(rd) begin | |
102 | rdata<= `SMX_PD data[raddr]; | |
103 | end | |
104 | end | |
105 | ||
106 | ||
107 | niu_smx_decode #(ADDR_WIDTH, ENTRY_SIZE) decode_set( | |
108 | .in (set_addr[ADDR_WIDTH-1:0]), | |
109 | .out (decode_set_n[ENTRY_SIZE-1:0]) | |
110 | ); | |
111 | niu_smx_decode #(ADDR_WIDTH, ENTRY_SIZE) decode_rst0( | |
112 | .in (rst_addr0[ADDR_WIDTH-1:0]), | |
113 | .out (decode_rst0_n[ENTRY_SIZE-1:0]) | |
114 | ); | |
115 | niu_smx_decode #(ADDR_WIDTH, ENTRY_SIZE) decode_rst1( | |
116 | .in (rst_addr1[ADDR_WIDTH-1:0]), | |
117 | .out (decode_rst1_n[ENTRY_SIZE-1:0]) | |
118 | ); | |
119 | ||
120 | ||
121 | endmodule | |
122 |