Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: xaui.cpp | |
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 | // ========== Copyright Header Begin ========================================== | |
36 | // | |
37 | // OpenSPARC T2 Processor File: xaui.cpp | |
38 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
39 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
40 | // | |
41 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
42 | // | |
43 | // This program is free software; you can redistribute it and/or modify | |
44 | // it under the terms of the GNU General Public License as published by | |
45 | // the Free Software Foundation; version 2 of the License. | |
46 | // | |
47 | // This program is distributed in the hope that it will be useful, | |
48 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
49 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
50 | // GNU General Public License for more details. | |
51 | // | |
52 | // You should have received a copy of the GNU General Public License | |
53 | // along with this program; if not, write to the Free Software | |
54 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
55 | // | |
56 | // For the avoidance of doubt, and except that if any non-GPL license | |
57 | // choice is available it will apply instead, Sun elects to use only | |
58 | // the General Public License version 2 (GPLv2) at this time for any | |
59 | // software where a choice of GPL license versions is made | |
60 | // available with the language indicating that GPLv2 or any later version | |
61 | // may be used, or where a choice of which version of the GPL is applied is | |
62 | // otherwise unspecified. | |
63 | // | |
64 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
65 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
66 | // have any questions. | |
67 | // | |
68 | // ========== Copyright Header End ============================================ | |
69 | #include <systemc.h> | |
70 | ||
71 | #include "xaui.h" | |
72 | #include "sharedmem.h" | |
73 | ||
74 | ||
75 | xaui::xaui(sc_module_name) { | |
76 | SC_METHOD(mac_tx); | |
77 | sensitive << mac_clk.pos(); | |
78 | SC_METHOD(mac_rx); | |
79 | sensitive << mac_clk.pos(); | |
80 | ||
81 | SC_METHOD(xaui_tx); | |
82 | sensitive << xaui_clk.pos(); | |
83 | SC_METHOD(xaui_rx); | |
84 | sensitive << xaui_clk.neg(); | |
85 | ||
86 | for(int i=0;i<4;i++) xaui_1count[i] = xaui_comma[i] = xaui_1count[i] = xaui_count[i] = 0; | |
87 | for(int i=0;i<4;i++) mac_esr_tx[i] = esr_mac_rx_l[i] = 0; | |
88 | xaui_serdes_count = 0; | |
89 | reset_sync = 1; | |
90 | ||
91 | ||
92 | ||
93 | } | |
94 | ||
95 | void xaui::mac_tx() { | |
96 | //capture mac tx interface signals every mac cycle 325MHz | |
97 | mac_esr_tx[0] = mac_esr_txd0.read(); | |
98 | mac_esr_tx[1] = mac_esr_txd1.read(); | |
99 | mac_esr_tx[2] = mac_esr_txd2.read(); | |
100 | mac_esr_tx[3] = mac_esr_txd3.read(); | |
101 | ||
102 | ||
103 | //synchronize reset to mac clock | |
104 | reset_sync = reset.read(); | |
105 | } | |
106 | ||
107 | void xaui::mac_rx() { | |
108 | esr_mac_rxd0.write(esr_mac_rx_l[0]); | |
109 | esr_mac_rxd1.write(esr_mac_rx_l[1]); | |
110 | esr_mac_rxd2.write(esr_mac_rx_l[2]); | |
111 | esr_mac_rxd3.write(esr_mac_rx_l[3]); | |
112 | } | |
113 | ||
114 | void xaui::xaui_tx() { | |
115 | //serialize mac tx interface signals 3.25GHz | |
116 | XAUI_AMUX.write(0); | |
117 | if(!reset_sync) { | |
118 | sc_lv<4> tx; | |
119 | for(int i=0;i<4;i++) { | |
120 | tx[i] = mac_esr_tx[i][9 - xaui_serdes_count]; | |
121 | } | |
122 | XAUI_TX_P.write(tx); | |
123 | XAUI_TX_N.write(~tx); | |
124 | xaui_serdes_count = (xaui_serdes_count + 1) % 10; | |
125 | } else { | |
126 | xaui_serdes_count = 0; | |
127 | XAUI_TX_P.write("0000"); | |
128 | XAUI_TX_N.write("1111"); | |
129 | } | |
130 | } | |
131 | ||
132 | ||
133 | void xaui::xaui_rx() { | |
134 | //need to detect comma patterns, find 10b boundaries and | |
135 | //send them back to mac | |
136 | sc_lv<4> xaui = XAUI_RX_P.read(); | |
137 | ||
138 | if(!reset_sync) { | |
139 | for(int i=0;i<4;i++) { | |
140 | if(xaui_comma[i] > 0) xaui_comma[i]--; | |
141 | //identify comma, 0011111, pattern | |
142 | if(xaui[i] == "1") { | |
143 | if(xaui_1count[i] >= 2) xaui_1count[i]++; //2 0s alread received and may have been followed by 1s | |
144 | else xaui_1count[i] = 0; // reset the number 0s already received | |
145 | } else { | |
146 | if(xaui_1count[i] > 2) xaui_1count[i] = 1; //1s received, reset 0 count to 1 | |
147 | else if(xaui_1count[i] < 2) xaui_1count[i]++; //keep 2 0s if more are received | |
148 | } | |
149 | ||
150 | if(xaui_1count[i] == 7) { xaui_comma[i] = 5; xaui_1count[i] = 0; } | |
151 | if(xaui_comma[i] == 1) xaui_count[i] = 0; | |
152 | esr_mac_rx[i][9 - xaui_count[i]] = xaui[i]; | |
153 | xaui_count[i]++; | |
154 | if(xaui_count[i] == 10) { | |
155 | esr_mac_rx_l[i] = esr_mac_rx[i]; | |
156 | xaui_count[i] = 0; | |
157 | } | |
158 | } | |
159 | /* | |
160 | int debug_comma_val = 0; | |
161 | int debug_boundry_val = 0; | |
162 | for(int i=0;i<4;i++) debug_comma_val += (xaui_comma[i] == 5) ? (1<<i) : 0; | |
163 | for(int i=0;i<4;i++) debug_boundry_val += (xaui_count[i] == 0) ? (1<<i) : 0; | |
164 | debug_comma.write(debug_comma_val); | |
165 | debug_boundry.write(debug_boundry_val); | |
166 | debug_1count_0.write(xaui_1count[0]); | |
167 | debug_1count_1.write(xaui_1count[1]); | |
168 | debug_1count_2.write(xaui_1count[2]); | |
169 | debug_1count_3.write(xaui_1count[3]); | |
170 | */ | |
171 | } else { | |
172 | for(int i=0;i<4;i++) xaui_1count[i] = xaui_comma[i] = 0; | |
173 | for(int i=0;i<4;i++) xaui_count[i] = 0; | |
174 | for(int i=0;i<4;i++) esr_mac_rx[i] = "0000000000"; | |
175 | } | |
176 | } | |
177 | ||
178 |