Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / niu_scam_ctl.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: niu_scam_ctl.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/**********************************************************
37***********************************************************
38
39 Project : Niu
40
41 File name : niu_scam_ctl.v
42
43 Module(s) name : niu_scam_ctl
44
45 Parent modules : niu_scam.v
46
47 Child modules :
48
49 Author's name : George Chu
50
51 Date : April. 2004
52
53 Description :
54
55 Synthesis Notes:
56
57 Modification History:
58 Date Description
59 ---- -----------
60
61************************************************************
62***********************************************************/
63
64`timescale 1ns/10ps
65
66`include "niu_scam.h"
67
68module niu_scam_ctl (
69 cam_compare_d,
70 pio_wt_d,
71 pio_rd_d,
72 pio_sel_d,
73 reset,
74 cam_clk,
75 cmp_enc,
76 cmp_busy,
77 cam_valid,
78 clr_cam,
79 c_scam_st,
80 wt_data,
81 wt_mask,
82 rd_data,
83 rd_mask,
84 pio_rd_vld,
85 c_pio_rw_st
86 );
87
88input cam_compare_d; // initiate compare operation
89input pio_wt_d;
90input pio_rd_d;
91input pio_sel_d;
92input reset;
93input cam_clk;
94output cmp_enc;
95output cmp_busy;
96output cam_valid;
97output clr_cam;
98output c_scam_st;
99output wt_data;
100output wt_mask;
101output rd_data;
102output rd_mask;
103output pio_rd_vld;
104output c_pio_rw_st;
105
106/**********************************************************/
107reg /*geo*/ cmp_enc;
108reg cmp_busy;
109reg cam_valid;
110reg clr_cam;
111reg c_scam_st;
112
113wire wt_data;
114wire wt_mask;
115wire rd_data;
116wire rd_mask;
117reg pio_rd_vld;
118reg c_pio_rw_st;
119
120/*--------------------------------------------------------*/
121reg inc_cyc_cnt;
122reg n_cmp_busy;
123reg n_cam_valid;
124reg n_clr_scam;
125
126reg n_scam_st;
127
128wire [2:0] pio_cam_cyc_1 = 3'h2; // geo, real 3-1=2
129wire [2:0] pio_cam_cyc_2 = 3'h1; // geo, real 3-2=1
130
131wire [2:0] cyc_cnt;
132
133wire n_cmp_enc = (cyc_cnt==pio_cam_cyc_2[2:0]) && (c_scam_st==`NIU_SCAM_CMP);
134
135/*--------------------------------------------------------*/
136reg n_catch_pio_rd;
137reg catch_pio_rd;
138
139reg n_pio_rw_st;
140
141/**********************************************************/
142 always @(cam_compare_d or
143 cyc_cnt or
144 pio_cam_cyc_1 or
145 cmp_busy or
146 c_scam_st
147 ) begin
148
149 inc_cyc_cnt = 1'h0;
150 n_cam_valid = 1'h0;
151 n_clr_scam = 1'h0;
152 n_scam_st = `NIU_SCAM_IDL;
153
154 n_cmp_busy = cmp_busy;
155
156 case (c_scam_st) //synopsys parallel_case
157 (`NIU_SCAM_IDL):
158 begin
159 if (cam_compare_d) begin
160 inc_cyc_cnt = 1'h1;
161 n_cmp_busy = 1'h1;
162 n_scam_st = `NIU_SCAM_CMP;
163 end
164 else begin
165 n_cmp_busy = 1'h0;
166 n_scam_st = `NIU_SCAM_IDL;
167 end
168 end
169 (`NIU_SCAM_CMP):
170 begin
171 if (cyc_cnt>=pio_cam_cyc_1) begin
172 n_cmp_busy = 1'h0;
173 n_cam_valid = 1'h1;
174 n_clr_scam = 1'h1;
175 n_scam_st = `NIU_SCAM_IDL;
176 end
177 else begin
178 inc_cyc_cnt = 1'h1;
179 n_scam_st = `NIU_SCAM_CMP;
180 end
181 end
182 default:
183 begin
184 n_cmp_busy = 1'h0;
185 n_cam_valid = 1'h1;
186 n_clr_scam = 1'h1;
187 n_scam_st = `NIU_SCAM_IDL;
188 end
189 endcase
190 end
191
192 niu_scam_cnt_i_r_3 cam_cnt_i_r_3_0(.incr(inc_cyc_cnt), .rs(clr_cam), .ck(cam_clk), .qo(cyc_cnt[2:0]));
193
194/**********************************************************/
195 always @(pio_wt_d or pio_rd_d or
196 c_pio_rw_st
197 ) begin
198
199 n_catch_pio_rd = 1'h0;
200 n_pio_rw_st = `NIU_SCAM_PIO_IDL;
201
202 case (c_pio_rw_st) //synopsys parallel_case
203 (`NIU_SCAM_PIO_IDL):
204 begin
205 if (pio_wt_d || pio_rd_d) begin
206 n_catch_pio_rd = pio_rd_d;
207 n_pio_rw_st = `NIU_SCAM_PIO_OUT;
208 end
209 else begin
210 n_catch_pio_rd = 1'h0;
211 n_pio_rw_st = `NIU_SCAM_PIO_IDL;
212 end
213 end
214 (`NIU_SCAM_PIO_OUT):
215 begin
216 n_catch_pio_rd = 1'h0;
217 n_pio_rw_st = `NIU_SCAM_PIO_IDL;
218 end
219 default:
220 begin
221 n_catch_pio_rd = 1'h0;
222 n_pio_rw_st = `NIU_SCAM_PIO_IDL;
223 end
224 endcase
225 end
226
227 assign wt_data = pio_wt_d && !pio_sel_d && (c_pio_rw_st==`NIU_SCAM_PIO_IDL) && !cmp_busy;
228 assign wt_mask = pio_wt_d && pio_sel_d && (c_pio_rw_st==`NIU_SCAM_PIO_IDL) && !cmp_busy;
229 assign rd_data = pio_rd_d && !pio_sel_d && (c_pio_rw_st==`NIU_SCAM_PIO_IDL);
230 assign rd_mask = pio_rd_d && pio_sel_d && (c_pio_rw_st==`NIU_SCAM_PIO_IDL);
231
232/**********************************************************/
233
234 always @(posedge cam_clk)
235 if (reset)
236 begin
237/*geo*/ cmp_enc <= #1 (1'h0);
238 cmp_busy <= #1 (1'h0);
239 cam_valid <= #1 (1'h0);
240 clr_cam <= #1 (1'h1);
241 c_scam_st <= #1 (1'h0);
242
243 catch_pio_rd <= #1 (1'h0);
244 pio_rd_vld <= #1 (1'h0);
245 c_pio_rw_st <= #1 (`NIU_SCAM_PIO_IDL);
246 end
247 else
248 begin
249/*geo*/ cmp_enc <= #1 (n_cmp_enc);
250 cmp_busy <= #1 (n_cmp_busy);
251 cam_valid <= #1 (n_cam_valid);
252 clr_cam <= #1 (n_clr_scam);
253 c_scam_st <= #1 (n_scam_st);
254
255 catch_pio_rd <= #1 (n_catch_pio_rd);
256 pio_rd_vld <= #1 (catch_pio_rd);
257 c_pio_rw_st <= #1 (n_pio_rw_st);
258 end
259
260endmodule