Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / model / verilog / mem / fbdimm / design / polling_state_fsm.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: polling_state_fsm.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`ifdef AXIS_FBDIMM_NO_FSR
36`else
37module polling_state_fsm(ps_bit,link_clk,amb_id,polling_state_start,polling_state_end,amb_id_ok);
38
39
40parameter DS=0;
41
42input ps_bit;
43input link_clk;
44output [3:0] amb_id;
45input polling_state_start;
46output polling_state_end;
47output amb_id_ok;
48
49reg [2:0] SB2NB_Map;
50reg [11:0] tr_reg;
51reg [4:0] tr_state;
52reg [4:0] tr_count;
53reg [11:0] clk_trn_ptrn;
54reg [3:0] clk_grp;
55reg ts2_ready_reg;
56reg [3:0] amb_id_reg;
57reg [23:0] test_param_reg;
58reg [7:8] test_param_count;
59reg polling_state_start_reg,polling_state_end_reg;
60assign amb_id=amb_id_reg;
61reg [35:0] end_del_reg;
62reg first_frame_enddelimeter_ok;
63
64assign amb_id_ok = ( amb_id_reg == DS ) ? 1'b1 : 1'b0;
65
66initial begin
67tr_state=0;
68tr_count=5'h0;
69amb_id_reg=0;
70test_param_count=0;
71first_frame_enddelimeter_ok=0;
72end
73
74assign polling_state_end=polling_state_end_reg;
75
76always@(negedge link_clk) if ( polling_state_start )
77begin
78 case(tr_state)
79 `IDLE: begin
80
81 end_del_reg[35:0] <= 36'h0;
82 ts2_ready_reg=0;
83 tr_reg[11:0] <= {ps_bit, tr_reg[11:1] };
84
85 if (( {ps_bit, tr_reg[11:1]} == 12'b001111111110 ) &
86 first_frame_enddelimeter_ok )
87 polling_state_end_reg<=1;
88 else
89 polling_state_end_reg<=0;
90
91
92 if ( {ps_bit, tr_reg[11:1]} == 12'b011111111110 ) begin
93 tr_state<=`TS_TEST_1;
94`ifdef FBD_DBG
95 `PR_ALWAYS ("amb_init",`DBG_0,"AMB Detected POLLING");
96`endif
97 end
98
99 end
100 `TS_TEST_1: begin
101 case(tr_count)
102 4'b0000: begin tr_reg[0] <= ps_bit; tr_count=tr_count+5'h1; end
103 4'b0001: begin tr_reg[1] <= ps_bit; tr_count=tr_count+5'h1; end
104 4'b0010: begin tr_reg[2] <= ps_bit; tr_count=tr_count+5'h1;end
105 4'b0011: begin tr_reg[3] <= ps_bit; tr_count=tr_count+5'h1; end
106 4'b0100: begin tr_reg[4] <= ps_bit; tr_count=tr_count+5'h1; end
107 4'b0101: begin tr_reg[5] <= ps_bit; tr_count=tr_count+5'h1; end
108 4'b0110: begin tr_reg[6] <= ps_bit; tr_count=tr_count+5'h1; end
109 4'b0111: begin tr_reg[7] <= ps_bit; tr_count=tr_count+5'h1; end
110 4'b1000: begin tr_reg[8] <= ps_bit; tr_count=tr_count+5'h1; end
111 4'b1001: begin tr_reg[9] <= ps_bit; tr_count=tr_count+5'h1; end
112 4'b1010: begin tr_reg[10] <= ps_bit; tr_count=tr_count+5'h1; end
113 4'b1011: begin tr_reg[11] <= ps_bit; tr_state<=`TS_TEST_2;
114 tr_count=1;clk_grp=0; amb_id_reg[3:0]=tr_reg[3:0];SB2NB_Map=tr_reg[6:4];
115`ifdef FBD_DBG
116 `PR_ALWAYS ("amb_init",`DBG_4,"POLLING Control values: ambid=%h sb2nbmap %h",tr_reg[3:0],tr_reg[6:4]);
117`endif
118 end
119 endcase
120 end
121
122 `TS_TEST_2: begin
123 end_del_reg[35:0] <= { ps_bit, end_del_reg[35:1]};
124 if ( {ps_bit, end_del_reg[35:1]} == {12'b101010101010,12'b101010101010,12'b101010101010} )
125 begin
126`ifdef FBD_DBG
127 `PR_ALWAYS ("amb_init",`DBG_0,"AMB_INIT polling sequence end detected");
128
129`endif
130 first_frame_enddelimeter_ok<=1'b1;
131
132 tr_state<=`IDLE;
133 end
134
135
136 end
137
138 endcase
139
140
141end
142
143
144endmodule
145
146
147module polling_state_fsm_chk(ps_bit,link_clk,polling_state_start);
148
149
150parameter DS=0;
151
152input ps_bit;
153input link_clk;
154input polling_state_start;
155
156reg [2:0] SB2NB_Map;
157reg [71:0] tr_reg;
158reg [4:0] tr_state;
159reg [9:0] tr_count;
160reg [11:0] clk_trn_ptrn;
161reg [3:0] clk_grp;
162reg ts2_ready_reg;
163reg [3:0] amb_id_reg;
164reg [23:0] test_param_reg;
165reg [7:8] test_param_count;
166reg polling_state_start_reg,polling_state_end_reg;
167reg [35:0] end_del_reg;
168
169
170
171initial begin
172tr_state=0;
173tr_count=10'h0;
174amb_id_reg=0;
175test_param_count=0;
176end
177
178
179always@(posedge link_clk) if ( polling_state_start )
180begin
181 case(tr_state)
182 `IDLE: begin
183 ts2_ready_reg=0;
184 tr_reg[71:0] <= {ps_bit,tr_reg[71:1]};
185
186 if (tr_reg[71:60] == 12'b011111111110 ) begin
187 tr_state <= `TS_TEST_1;
188 end
189
190 end
191 `TS_TEST_1: begin
192 tr_reg[71:0] = {ps_bit,tr_reg[71:1]};
193 tr_count=tr_count+10'h1;
194
195 if ( (tr_count == 10'h3b) && (tr_reg[71:0] != 0 ) ) begin
196`ifdef AXIS_FBDIMM_HW
197`else
198
199 `PR_ALWAYS ("ch_mon",`DBG_0,"pol_reg: %h ",tr_reg);
200
201/* This is checked indirectly
202 if ( tr_reg[11:0] != 12'h7fe )
203 `PR_ALWAYS ("ch_mon",`DBG_0,"ERROR: 7fe pattern not found for polling state ");
204
205*/
206 if ( {tr_reg[23:18]} != {6'b00000} )
207 `PR_ALWAYS ("ch_mon",`DBG_0,"ERROR: grp1 pattern in polling is wrong! ");
208
209 if ( {tr_reg[34:29]} != {4'b0000} )
210 `PR_ALWAYS ("ch_mon",`DBG_0,"ERROR: NBwidthcapability pattern in polling is wrong! ");
211`endif
212
213 tr_count=10'h0;
214 tr_state=`IDLE;
215 end
216
217
218 end
219
220 endcase
221
222
223end
224
225
226endmodule
227
228`endif // AXIS_FBDIMM_NO_FSR