Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: serializer.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 100ps / 10ps | |
36 | `ifdef LINK_1 | |
37 | `define LINK_WIDTH 1 | |
38 | `else | |
39 | `ifdef LINK_2 | |
40 | `define LINK_WIDTH 2 | |
41 | `else | |
42 | `ifdef LINK_4 | |
43 | `define LINK_WIDTH 4 | |
44 | `else | |
45 | `ifdef LINK_12 | |
46 | `define LINK_WIDTH 12 | |
47 | `else | |
48 | `ifdef LINK_16 | |
49 | `define LINK_WIDTH 16 | |
50 | `else | |
51 | `ifdef LINK_24 | |
52 | `define LINK_WIDTH 24 | |
53 | `else | |
54 | `ifdef LINK_32 | |
55 | `define LINK_WIDTH 32 | |
56 | `else | |
57 | `define LINK_WIDTH 8 | |
58 | `endif | |
59 | `endif | |
60 | `endif | |
61 | `endif | |
62 | `endif | |
63 | `endif | |
64 | `endif | |
65 | ||
66 | /// Module to serialize the data before putting it on the bus | |
67 | module serializer( lane_in0, | |
68 | lane_in1, | |
69 | lane_in2, | |
70 | lane_in3, | |
71 | lane_in4, | |
72 | lane_in5, | |
73 | lane_in6, | |
74 | lane_in7, | |
75 | lane_in8, | |
76 | lane_in9, | |
77 | link_clk, | |
78 | out, | |
79 | out_bar, | |
80 | frame_boundary | |
81 | ); | |
82 | ||
83 | ||
84 | input [`LINK_WIDTH-1:0] lane_in0; | |
85 | input [`LINK_WIDTH-1:0] lane_in1; | |
86 | input [`LINK_WIDTH-1:0] lane_in2; | |
87 | input [`LINK_WIDTH-1:0] lane_in3; | |
88 | input [`LINK_WIDTH-1:0] lane_in4; | |
89 | input [`LINK_WIDTH-1:0] lane_in5; | |
90 | input [`LINK_WIDTH-1:0] lane_in6; | |
91 | input [`LINK_WIDTH-1:0] lane_in7; | |
92 | input [`LINK_WIDTH-1:0] lane_in8; | |
93 | input [`LINK_WIDTH-1:0] lane_in9; | |
94 | input link_clk; // SymbolClk/10 | |
95 | input frame_boundary; | |
96 | output [`LINK_WIDTH-1:0] out, out_bar; | |
97 | ||
98 | reg [3:0] counter, prev_counter, lock_counter; | |
99 | reg [3:0] curr_state; | |
100 | reg [5:0] tx_lane0_deskew,tx_lane1_deskew,tx_lane2_deskew,tx_lane3_deskew; | |
101 | reg [5:0] tx_lane4_deskew,tx_lane5_deskew,tx_lane6_deskew,tx_lane7_deskew; | |
102 | integer i; | |
103 | reg val; | |
104 | ||
105 | ||
106 | ||
107 | ||
108 | ||
109 | reg [`LINK_WIDTH-1:0] out_reg,out_bar_reg; | |
110 | ||
111 | ||
112 | ||
113 | reg comma_detected; | |
114 | reg sequence_start; | |
115 | wire all_lanes_detected; | |
116 | wire sym_boundary; | |
117 | ||
118 | // Inputs to this module do not have any skew, since they come from the TL,DLL | |
119 | // Only outputs to the bus will have necessary skew | |
120 | // Max skew = 20ns or 50 UI | |
121 | ||
122 | ||
123 | assign out = out_reg[`LINK_WIDTH-1:0]; | |
124 | assign out_bar = out_bar_reg[`LINK_WIDTH-1:0]; | |
125 | ||
126 | ||
127 | initial begin | |
128 | comma_detected = 1'b0; | |
129 | sequence_start = 1'b0; | |
130 | counter = 4'ha; | |
131 | lock_counter = 4'h0; | |
132 | prev_counter = 4'h0; | |
133 | curr_state = 4'h0; | |
134 | ||
135 | //$fsdbDumpvars; | |
136 | end | |
137 | ||
138 | ||
139 | // Above codes for getting symbol boundary lock... | |
140 | ||
141 | // Now the main code for reading in incoming data and do the work of serial-parallel | |
142 | // Always block takes care of the serialization. | |
143 | // If only some of the 32 lanes are active, the inactive ones will have all zeroes(or encoded version of zeroes, which have no meaning) | |
144 | ||
145 | always @(posedge link_clk) | |
146 | begin | |
147 | case(curr_state) | |
148 | 4'h0 : begin | |
149 | for(i=0;i<`LINK_WIDTH;i=i+1) | |
150 | begin | |
151 | out_reg[i] <= lane_in0[i] ; out_bar_reg[i] <= ~lane_in0[i] ; | |
152 | end | |
153 | end | |
154 | 4'h1 : begin | |
155 | for(i=0;i<`LINK_WIDTH;i=i+1) | |
156 | begin | |
157 | out_reg[i] <= lane_in1[i] ; out_bar_reg[i] <= ~lane_in1[i] ; | |
158 | end | |
159 | end | |
160 | 4'h2 : begin | |
161 | for(i=0;i<`LINK_WIDTH;i=i+1) | |
162 | begin | |
163 | out_reg[i] <= lane_in2[i] ; out_bar_reg[i] <= ~lane_in2[i] ; | |
164 | end | |
165 | end | |
166 | 4'h3 : begin | |
167 | for(i=0;i<`LINK_WIDTH;i=i+1) | |
168 | begin | |
169 | out_reg[i] <= lane_in3[i] ; out_bar_reg[i] <= ~lane_in3[i] ; | |
170 | end | |
171 | end | |
172 | 4'h4 : begin | |
173 | for(i=0;i<`LINK_WIDTH;i=i+1) | |
174 | begin | |
175 | out_reg[i] <= lane_in4[i] ; out_bar_reg[i] <= ~lane_in4[i] ; | |
176 | end | |
177 | end | |
178 | 4'h5 : begin | |
179 | for(i=0;i<`LINK_WIDTH;i=i+1) | |
180 | begin | |
181 | out_reg[i] <= lane_in5[i] ; out_bar_reg[i] <= ~lane_in5[i] ; | |
182 | end | |
183 | end | |
184 | 4'h6 : begin | |
185 | for(i=0;i<`LINK_WIDTH;i=i+1) | |
186 | begin | |
187 | out_reg[i] <= lane_in6[i] ; out_bar_reg[i] <= ~lane_in6[i] ; | |
188 | end | |
189 | end | |
190 | 4'h7 : begin | |
191 | for(i=0;i<`LINK_WIDTH;i=i+1) | |
192 | begin | |
193 | out_reg[i] <= lane_in7[i] ; out_bar_reg[i] <= ~lane_in7[i] ; | |
194 | end | |
195 | end | |
196 | 4'h8 : begin | |
197 | for(i=0;i<`LINK_WIDTH;i=i+1) | |
198 | begin | |
199 | out_reg[i] <= lane_in8[i] ; out_bar_reg[i] <= ~lane_in8[i] ; | |
200 | end | |
201 | end | |
202 | 4'h9 : begin | |
203 | for(i=0;i<`LINK_WIDTH;i=i+1) | |
204 | begin | |
205 | out_reg[i] <= lane_in9[i] ; out_bar_reg[i] <= ~lane_in9[i] ; | |
206 | end | |
207 | end | |
208 | endcase | |
209 | end | |
210 | ||
211 | /// State counter block | |
212 | always @(negedge link_clk) | |
213 | begin | |
214 | case(curr_state) | |
215 | 4'h0 : begin curr_state <= 4'h1 ; end | |
216 | 4'h1 : begin curr_state <= 4'h2 ; end | |
217 | 4'h2 : begin curr_state <= 4'h3 ; end | |
218 | 4'h3 : begin curr_state <= 4'h4 ; end | |
219 | 4'h4 : begin curr_state <= 4'h5 ; end | |
220 | 4'h5 : begin curr_state <= 4'h6 ; end | |
221 | 4'h6 : begin curr_state <= 4'h7 ; end | |
222 | 4'h7 : begin curr_state <= 4'h8 ; end | |
223 | 4'h8 : begin curr_state <= 4'h9 ; end | |
224 | 4'h9 : begin if(frame_boundary) curr_state <= 4'h0 ; end | |
225 | endcase | |
226 | end | |
227 | ||
228 | ||
229 | ||
230 | ||
231 | endmodule |