Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: port_clk.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 | `timescale 1ns/10ps | |
36 | ||
37 | `define RX_CLK_SKEW 1 | |
38 | `define TX_CLK_SKEW 1 | |
39 | ||
40 | `include "neptune_defines.h" | |
41 | ||
42 | module port_clk( tx_clkp, | |
43 | tx_clkn, | |
44 | rx_clkp, | |
45 | rx_clkn, | |
46 | tx_config, | |
47 | rx_config); | |
48 | ||
49 | output tx_clkp, tx_clkn; | |
50 | output rx_clkp, rx_clkn; | |
51 | ||
52 | input [3:0] tx_config, rx_config; | |
53 | ||
54 | ||
55 | reg [3:0] old_tx_config, old_rx_config; | |
56 | reg rx_clkp; | |
57 | reg tx_clkp_int ; | |
58 | ||
59 | ||
60 | reg [2:0] skew; | |
61 | reg [2:0] org_skew; | |
62 | real tx_cycle; | |
63 | real rx_cycle; | |
64 | ||
65 | //assign #7 tx_clkp = tx_clkp_int; | |
66 | //assign #3 tx_clkp = rx_clkp; | |
67 | assign #3 tx_clkp = rx_clkn; | |
68 | initial | |
69 | begin | |
70 | old_tx_config = 0; | |
71 | #5 old_tx_config = tx_config; | |
72 | end | |
73 | initial | |
74 | begin | |
75 | old_rx_config = 0; | |
76 | #5 old_rx_config = rx_config; | |
77 | end | |
78 | initial | |
79 | begin | |
80 | tx_clkp_int = 0; | |
81 | rx_clkp = 0; | |
82 | skew = 1; | |
83 | org_skew = skew; | |
84 | end | |
85 | ||
86 | parameter txdelay_0 = 400, // Clock period for 10MBS (2.5Mhz) | |
87 | txdelay_1 = 200, // Clock period for 10MBS (2.5Mhz) | |
88 | txdelay_2 = 20, // Clock period for 100MBS (25 Mhz) | |
89 | txdelay_3 = 4, // Clock period for 1000MBS (125 Mhz) | |
90 | txdelay_4 = 0.4; // Clock period for 10GBS (156.25 Mhz) | |
91 | ||
92 | parameter rxdelay_0 = 400, // Clock period for 10MBS (2.5 Mhz) | |
93 | rxdelay_1 = 200, // Clock period for 10MBS (2.5 Mhz) | |
94 | rxdelay_2 = 20, // Clock period for 100MBS (25 Mhz) | |
95 | rxdelay_3 = 4, // Clock period for 1000MBS (125 Mhz) | |
96 | rxdelay_4 = 0.4; // Clock period for 10GBS (156.25 Mhz) | |
97 | ||
98 | assign tx_clkn = ~tx_clkp_int; | |
99 | assign rx_clkn = ~rx_clkp; | |
100 | ||
101 | always | |
102 | begin | |
103 | #0; | |
104 | case(tx_config) | |
105 | 0: tx_cycle = txdelay_0; | |
106 | 1: tx_cycle = txdelay_1; | |
107 | 2: tx_cycle = txdelay_2; | |
108 | 3: tx_cycle = txdelay_3; | |
109 | 4: tx_cycle = txdelay_4; | |
110 | default: | |
111 | begin | |
112 | tx_cycle=txdelay_3; // -- Added the default value as this causes simulation hang | |
113 | if($time>2) | |
114 | //$display("ERROR: %m Invalid tx_config %0d",tx_config); | |
115 | tx_cycle=txdelay_3; | |
116 | end | |
117 | endcase | |
118 | case(skew) | |
119 | 0: | |
120 | begin | |
121 | if(old_tx_config != tx_config) | |
122 | begin | |
123 | old_tx_config = tx_config; | |
124 | repeat(2) @(posedge `TOP.core_clk); | |
125 | tx_clkp_int=0; | |
126 | repeat(2) @(posedge `TOP.core_clk); | |
127 | skew = org_skew; | |
128 | end | |
129 | #tx_cycle tx_clkp_int = ~tx_clkp_int; | |
130 | end | |
131 | 1: | |
132 | begin | |
133 | if(tx_clkp_int!=0) | |
134 | begin | |
135 | repeat(2) @(posedge `TOP.core_clk); | |
136 | tx_clkp_int=0; | |
137 | end | |
138 | repeat(2) @(posedge `TOP.core_clk); | |
139 | #`TX_CLK_SKEW tx_clkp_int = ~tx_clkp_int; | |
140 | skew = 0; | |
141 | end | |
142 | ||
143 | 2: begin | |
144 | if(tx_clkp_int!=0) | |
145 | begin | |
146 | repeat(4) @(posedge `TOP.core_clk); | |
147 | tx_clkp_int=0; | |
148 | end | |
149 | repeat(4) @(posedge `TOP.core_clk); | |
150 | #(7.5/2) tx_clkp_int = ~tx_clkp_int; | |
151 | skew <= #1 0; | |
152 | end | |
153 | ||
154 | 3: begin | |
155 | if(tx_clkp!=0) | |
156 | begin | |
157 | repeat(4) @(posedge `TOP.core_clk); | |
158 | tx_clkp_int=0; | |
159 | end | |
160 | repeat(4) @(posedge `TOP.core_clk); | |
161 | #(7.5/4*3) tx_clkp_int = ~tx_clkp_int; | |
162 | skew <= #1 0; | |
163 | end | |
164 | ||
165 | 4: begin | |
166 | if(tx_clkp!=0) | |
167 | begin | |
168 | repeat(4) @(posedge `TOP.core_clk); | |
169 | tx_clkp_int=0; | |
170 | end | |
171 | repeat(4) @(posedge `TOP.core_clk); | |
172 | #(7.5/4) tx_clkp_int = ~tx_clkp_int; | |
173 | skew <= #1 0; | |
174 | end | |
175 | ||
176 | default: | |
177 | begin | |
178 | skew = 0; | |
179 | end | |
180 | endcase | |
181 | end | |
182 | ||
183 | always | |
184 | begin | |
185 | case(rx_config) | |
186 | 0: rx_cycle = rxdelay_0; | |
187 | 1: rx_cycle = rxdelay_1; | |
188 | 2: rx_cycle = rxdelay_2; | |
189 | 3: rx_cycle = rxdelay_3; | |
190 | 4: rx_cycle = rxdelay_4; | |
191 | default: | |
192 | begin | |
193 | rx_cycle=rxdelay_3; // -- Added the default value as this causes simulation hang | |
194 | if($time>2) | |
195 | //$display("ERROR: %m Invalid rx_config %0d",rx_config); | |
196 | rx_cycle=rxdelay_3; | |
197 | end | |
198 | endcase | |
199 | case(skew) | |
200 | 0: | |
201 | begin | |
202 | if(old_rx_config != rx_config) | |
203 | begin | |
204 | old_rx_config = rx_config; | |
205 | repeat(2) @(posedge `TOP.core_clk); | |
206 | rx_clkp=0; | |
207 | repeat(2) @(posedge `TOP.core_clk); | |
208 | skew = org_skew; | |
209 | end | |
210 | #rx_cycle rx_clkp = ~rx_clkp; | |
211 | end | |
212 | 1: | |
213 | begin | |
214 | if(rx_clkp!=0) | |
215 | begin | |
216 | repeat(2) @(posedge `TOP.core_clk); | |
217 | rx_clkp=0; | |
218 | end | |
219 | repeat(2) @(posedge `TOP.core_clk); | |
220 | #`RX_CLK_SKEW rx_clkp = ~rx_clkp; | |
221 | skew = 0; | |
222 | end | |
223 | default: | |
224 | begin | |
225 | skew = 0; | |
226 | end | |
227 | endcase | |
228 | end | |
229 | ||
230 | ||
231 | ||
232 | endmodule |