1 |
5 |
redbear |
//+FHDR------------------------------------------------------------------------
|
2 |
|
|
//Copyright (c) 2013 Latin Group American Integhrated Circuit, Inc. All rights reserved
|
3 |
|
|
//GLADIC Open Source RTL
|
4 |
|
|
//-----------------------------------------------------------------------------
|
5 |
|
|
//FILE NAME :
|
6 |
|
|
//DEPARTMENT : IC Design / Verification
|
7 |
|
|
//AUTHOR : Felipe Fernandes da Costa
|
8 |
|
|
//AUTHOR’S EMAIL :
|
9 |
|
|
//-----------------------------------------------------------------------------
|
10 |
|
|
//RELEASE HISTORY
|
11 |
|
|
//VERSION DATE AUTHOR DESCRIPTION
|
12 |
|
|
//1.0 YYYY-MM-DD name
|
13 |
|
|
//-----------------------------------------------------------------------------
|
14 |
|
|
//KEYWORDS : General file searching keywords, leave blank if none.
|
15 |
|
|
//-----------------------------------------------------------------------------
|
16 |
|
|
//PURPOSE : ECSS_E_ST_50_12C_31_july_2008
|
17 |
|
|
//-----------------------------------------------------------------------------
|
18 |
|
|
//PARAMETERS
|
19 |
|
|
//PARAM NAME RANGE : DESCRIPTION : DEFAULT : UNITS
|
20 |
|
|
//e.g.DATA_WIDTH [32,16] : width of the DATA : 32:
|
21 |
|
|
//-----------------------------------------------------------------------------
|
22 |
|
|
//REUSE ISSUES
|
23 |
|
|
//Reset Strategy :
|
24 |
|
|
//Clock Domains :
|
25 |
|
|
//Critical Timing :
|
26 |
|
|
//Test Features :
|
27 |
|
|
//Asynchronous I/F :
|
28 |
|
|
//Scan Methodology :
|
29 |
|
|
//Instantiations :
|
30 |
|
|
//Synthesizable (y/n) :
|
31 |
|
|
//Other :
|
32 |
|
|
//-FHDR------------------------------------------------------------------------
|
33 |
|
|
|
34 |
|
|
`timescale 1ns/1ns
|
35 |
|
|
|
36 |
|
|
module TX_SPW (
|
37 |
|
|
input pclk_tx,
|
38 |
|
|
//
|
39 |
|
|
input [8:0] data_tx_i,
|
40 |
|
|
input txwrite_tx,
|
41 |
|
|
//
|
42 |
|
|
input [7:0] timecode_tx_i,
|
43 |
|
|
input tickin_tx,
|
44 |
|
|
//
|
45 |
|
|
input enable_tx,
|
46 |
|
|
input send_null_tx,
|
47 |
|
|
input send_fct_tx,
|
48 |
|
|
|
49 |
|
|
//
|
50 |
|
|
input gotfct_tx,
|
51 |
|
|
input send_fct_now,
|
52 |
|
|
//
|
53 |
|
|
output reg tx_dout,
|
54 |
|
|
output reg tx_sout,
|
55 |
|
|
//
|
56 |
|
|
output ready_tx_data,
|
57 |
|
|
output ready_tx_timecode
|
58 |
|
|
|
59 |
|
|
);
|
60 |
|
|
|
61 |
|
|
localparam [2:0] tx_spw_start = 3'b000,
|
62 |
|
|
tx_spw_null = 3'b001,
|
63 |
|
|
tx_spw_null_fct = 3'b010,
|
64 |
|
|
tx_spw_full = 3'b100;
|
65 |
|
|
|
66 |
|
|
localparam [5:0] NULL = 6'b000001,
|
67 |
|
|
FCT = 6'b000010,
|
68 |
|
|
EOP = 6'b000100,
|
69 |
|
|
EEP = 6'b001000,
|
70 |
|
|
DATA = 6'b010000,
|
71 |
|
|
TIMEC = 6'b100000;
|
72 |
|
|
|
73 |
|
|
reg [2:0] state_tx;
|
74 |
|
|
reg [2:0] next_state_tx;
|
75 |
|
|
|
76 |
|
|
reg [7:0] null_s;
|
77 |
|
|
reg [3:0] fct_s;
|
78 |
|
|
reg [3:0] eop_s;
|
79 |
|
|
reg [3:0] eep_s;
|
80 |
|
|
reg [13:0] timecode_s;
|
81 |
|
|
|
82 |
|
|
reg [5:0] last_type;
|
83 |
|
|
reg [8:0] txdata_flagctrl_tx_last;
|
84 |
|
|
reg [7:0] last_timein_control_flag_tx;
|
85 |
|
|
|
86 |
|
|
reg first_time;
|
87 |
|
|
|
88 |
|
|
reg enable_null;
|
89 |
|
|
reg enable_fct;
|
90 |
|
|
reg enable_n_char;
|
91 |
|
|
reg enable_time_code;
|
92 |
|
|
|
93 |
|
|
reg [2:0] fct_send;
|
94 |
|
|
reg [2:0] fct_flag;
|
95 |
|
|
reg [5:0] fct_counter;
|
96 |
|
|
reg last_tx_dout;
|
97 |
|
|
reg last_tx_sout;
|
98 |
|
|
//reg first_counter_ctr;
|
99 |
|
|
|
100 |
|
|
reg [3:0] global_counter_transfer;
|
101 |
|
|
|
102 |
|
|
assign ready_tx_timecode = (enable_time_code & global_counter_transfer == 14)?1'b1:1'b0;
|
103 |
|
|
|
104 |
|
|
assign ready_tx_data = (enable_n_char & global_counter_transfer == 4'd10 & !data_tx_i[8])?1'b1:
|
105 |
|
|
(enable_n_char & global_counter_transfer == 4'd4 & data_tx_i[8])?1'b1:1'b0;
|
106 |
|
|
|
107 |
|
|
always@(*)
|
108 |
|
|
begin
|
109 |
|
|
tx_dout = 1'b0;
|
110 |
|
|
|
111 |
|
|
if(!enable_tx)
|
112 |
|
|
begin
|
113 |
|
|
tx_dout = 1'b0;
|
114 |
|
|
end
|
115 |
|
|
else if( enable_null & first_time & global_counter_transfer == 4'd0)
|
116 |
|
|
begin
|
117 |
|
|
tx_dout = null_s[7];
|
118 |
|
|
end
|
119 |
|
|
else if( enable_null & !first_time & last_type == NULL & global_counter_transfer == 4'd0)
|
120 |
|
|
begin
|
121 |
|
|
tx_dout = !(null_s[6]^null_s[0]^null_s[1]);
|
122 |
|
|
end
|
123 |
|
|
else if( enable_null & !first_time & last_type == FCT & global_counter_transfer == 4'd0)
|
124 |
|
|
begin
|
125 |
|
|
tx_dout = !(null_s[6]^fct_s[0]^fct_s[1]);
|
126 |
|
|
end
|
127 |
|
|
else if( enable_null & !first_time & last_type == EOP & global_counter_transfer == 4'd0)
|
128 |
|
|
begin
|
129 |
|
|
tx_dout = !(null_s[6]^eop_s[0]^eop_s[1]);
|
130 |
|
|
end
|
131 |
|
|
else if( enable_null & !first_time & last_type == EEP & global_counter_transfer == 4'd0)
|
132 |
|
|
begin
|
133 |
|
|
tx_dout = !(null_s[6]^eep_s[0]^eep_s[1]);
|
134 |
|
|
end
|
135 |
|
|
else if( enable_null & !first_time & last_type == DATA & global_counter_transfer == 4'd0)
|
136 |
|
|
begin
|
137 |
|
|
tx_dout = !(null_s[6]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
138 |
|
|
end
|
139 |
|
|
else if( enable_null & !first_time & last_type == TIMEC & global_counter_transfer == 4'd0)
|
140 |
|
|
begin
|
141 |
|
|
tx_dout = !(null_s[6]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
142 |
|
|
end
|
143 |
|
|
else if( enable_null & !first_time & global_counter_transfer == 4'd1)
|
144 |
|
|
begin
|
145 |
|
|
tx_dout = null_s[6];
|
146 |
|
|
end
|
147 |
|
|
else if( enable_null & !first_time & global_counter_transfer == 4'd2)
|
148 |
|
|
begin
|
149 |
|
|
tx_dout = null_s[5];
|
150 |
|
|
end
|
151 |
|
|
else if( enable_null & !first_time & global_counter_transfer == 4'd3)
|
152 |
|
|
begin
|
153 |
|
|
tx_dout = null_s[4];
|
154 |
|
|
end
|
155 |
|
|
else if( enable_null & !first_time & global_counter_transfer == 4'd4)
|
156 |
|
|
begin
|
157 |
|
|
tx_dout = null_s[3];
|
158 |
|
|
end
|
159 |
|
|
else if( enable_null & !first_time & global_counter_transfer == 4'd5)
|
160 |
|
|
begin
|
161 |
|
|
tx_dout = null_s[2];
|
162 |
|
|
end
|
163 |
|
|
else if( enable_null & !first_time & global_counter_transfer == 4'd6)
|
164 |
|
|
begin
|
165 |
|
|
tx_dout = null_s[1];
|
166 |
|
|
end
|
167 |
|
|
else if( enable_null & !first_time & global_counter_transfer == 4'd7)
|
168 |
|
|
begin
|
169 |
|
|
tx_dout = null_s[0];
|
170 |
|
|
end
|
171 |
|
|
else if( enable_fct & !first_time & last_type == NULL & global_counter_transfer == 4'd0)
|
172 |
|
|
begin
|
173 |
|
|
tx_dout = !(fct_s[2]^null_s[0]^null_s[1]);
|
174 |
|
|
end
|
175 |
|
|
else if( enable_fct & !first_time & last_type == FCT & global_counter_transfer == 4'd0)
|
176 |
|
|
begin
|
177 |
|
|
tx_dout = !(fct_s[2]^fct_s[0]^fct_s[1]);
|
178 |
|
|
end
|
179 |
|
|
else if( enable_fct & !first_time & last_type == EOP & global_counter_transfer == 4'd0)
|
180 |
|
|
begin
|
181 |
|
|
tx_dout = !(fct_s[2]^eop_s[0]^eop_s[1]);
|
182 |
|
|
end
|
183 |
|
|
else if( enable_fct & !first_time & last_type == EEP & global_counter_transfer == 4'd0)
|
184 |
|
|
begin
|
185 |
|
|
tx_dout = !(fct_s[2]^eep_s[0]^eep_s[1]);
|
186 |
|
|
end
|
187 |
|
|
else if ( enable_fct & !first_time & last_type == DATA & global_counter_transfer == 4'd0)
|
188 |
|
|
begin
|
189 |
|
|
tx_dout = !(fct_s[2]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
190 |
|
|
end
|
191 |
|
|
else if( enable_fct & !first_time & last_type == TIMEC & global_counter_transfer == 4'd0)
|
192 |
|
|
begin
|
193 |
|
|
tx_dout = !(fct_s[2]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
194 |
|
|
end
|
195 |
|
|
else if( enable_fct & !first_time & global_counter_transfer == 4'd1)
|
196 |
|
|
begin
|
197 |
|
|
tx_dout = fct_s[2];
|
198 |
|
|
end
|
199 |
|
|
else if( enable_fct & !first_time & global_counter_transfer == 4'd2)
|
200 |
|
|
begin
|
201 |
|
|
tx_dout = fct_s[1];
|
202 |
|
|
end
|
203 |
|
|
else if( enable_fct & !first_time & global_counter_transfer == 4'd3)
|
204 |
|
|
begin
|
205 |
|
|
tx_dout = fct_s[0];
|
206 |
|
|
end
|
207 |
|
|
else if( enable_time_code & !first_time & last_type == NULL & global_counter_transfer == 4'd0)
|
208 |
|
|
begin
|
209 |
|
|
tx_dout = !(timecode_s[12]^null_s[0]^null_s[1]);
|
210 |
|
|
end
|
211 |
|
|
else if( enable_time_code & !first_time & last_type == FCT & global_counter_transfer == 4'd0)
|
212 |
|
|
begin
|
213 |
|
|
tx_dout = !(timecode_s[12]^fct_s[0]^fct_s[1]);
|
214 |
|
|
end
|
215 |
|
|
else if ( enable_time_code & !first_time & last_type == EOP & global_counter_transfer == 4'd0)
|
216 |
|
|
begin
|
217 |
|
|
tx_dout = !(timecode_s[12]^eop_s[0]^eop_s[1]);
|
218 |
|
|
end
|
219 |
|
|
else if( enable_time_code & !first_time & last_type == EEP & global_counter_transfer == 4'd0)
|
220 |
|
|
begin
|
221 |
|
|
tx_dout = !(timecode_s[12]^eep_s[0]^eep_s[1]);
|
222 |
|
|
end
|
223 |
|
|
else if( enable_time_code & !first_time & last_type == DATA & global_counter_transfer == 4'd0)
|
224 |
|
|
begin
|
225 |
|
|
tx_dout = !(timecode_s[12]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
226 |
|
|
end
|
227 |
|
|
else if( enable_time_code & !first_time & last_type == TIMEC & global_counter_transfer == 4'd0)
|
228 |
|
|
begin
|
229 |
|
|
tx_dout = !(timecode_s[12]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
230 |
|
|
end
|
231 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd1)
|
232 |
|
|
begin
|
233 |
|
|
tx_dout = timecode_s[12];
|
234 |
|
|
end
|
235 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd2)
|
236 |
|
|
begin
|
237 |
|
|
tx_dout = timecode_s[11];
|
238 |
|
|
end
|
239 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd3)
|
240 |
|
|
begin
|
241 |
|
|
tx_dout = timecode_s[10];
|
242 |
|
|
end
|
243 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd4)
|
244 |
|
|
begin
|
245 |
|
|
tx_dout = timecode_s[9];
|
246 |
|
|
end
|
247 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd5)
|
248 |
|
|
begin
|
249 |
|
|
tx_dout = timecode_s[8];
|
250 |
|
|
end
|
251 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd6)
|
252 |
|
|
begin
|
253 |
|
|
tx_dout = timecode_s[7];
|
254 |
|
|
end
|
255 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd7)
|
256 |
|
|
begin
|
257 |
|
|
tx_dout = timecode_s[6];
|
258 |
|
|
end
|
259 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd8)
|
260 |
|
|
begin
|
261 |
|
|
tx_dout = timecode_s[5];
|
262 |
|
|
end
|
263 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd9)
|
264 |
|
|
begin
|
265 |
|
|
tx_dout = timecode_s[4];
|
266 |
|
|
end
|
267 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd10)
|
268 |
|
|
begin
|
269 |
|
|
tx_dout = timecode_s[3];
|
270 |
|
|
end
|
271 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd11)
|
272 |
|
|
begin
|
273 |
|
|
tx_dout = timecode_s[2];
|
274 |
|
|
end
|
275 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd12)
|
276 |
|
|
begin
|
277 |
|
|
tx_dout = timecode_s[1];
|
278 |
|
|
end
|
279 |
|
|
else if( enable_time_code & !first_time & global_counter_transfer == 4'd13)
|
280 |
|
|
begin
|
281 |
|
|
tx_dout = timecode_s[0];
|
282 |
|
|
end
|
283 |
|
|
else if( enable_n_char & !first_time & last_type == NULL & global_counter_transfer == 4'd0)
|
284 |
|
|
begin
|
285 |
|
|
tx_dout = !(data_tx_i[8]^null_s[0]^null_s[1]);
|
286 |
|
|
end
|
287 |
|
|
else if( enable_n_char & !first_time & last_type == FCT & global_counter_transfer == 4'd0)
|
288 |
|
|
begin
|
289 |
|
|
tx_dout = !(data_tx_i[8]^fct_s[0]^fct_s[1]);
|
290 |
|
|
end
|
291 |
|
|
else if( enable_n_char & !first_time & last_type == EOP & global_counter_transfer == 4'd0)
|
292 |
|
|
begin
|
293 |
|
|
tx_dout = !(data_tx_i[8]^eop_s[0]^eop_s[1]);
|
294 |
|
|
end
|
295 |
|
|
else if( enable_n_char & !first_time & last_type == EEP & global_counter_transfer == 4'd0)
|
296 |
|
|
begin
|
297 |
|
|
tx_dout = !(data_tx_i[8]^eep_s[0]^eep_s[1]);
|
298 |
|
|
end
|
299 |
|
|
else if( enable_n_char & !first_time & last_type == DATA & global_counter_transfer == 4'd0)
|
300 |
|
|
begin
|
301 |
|
|
tx_dout = !(data_tx_i[8]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
302 |
|
|
end
|
303 |
|
|
else if( enable_n_char & !first_time & last_type == TIMEC & global_counter_transfer == 4'd0)
|
304 |
|
|
begin
|
305 |
|
|
tx_dout = !(data_tx_i[8]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
306 |
|
|
end
|
307 |
|
|
else if( enable_n_char & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd1)
|
308 |
|
|
begin
|
309 |
|
|
tx_dout = data_tx_i[8];
|
310 |
|
|
end
|
311 |
|
|
else if( enable_n_char & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd2)
|
312 |
|
|
begin
|
313 |
|
|
tx_dout = data_tx_i[0];
|
314 |
|
|
end
|
315 |
|
|
else if( enable_n_char & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd3)
|
316 |
|
|
begin
|
317 |
|
|
tx_dout = data_tx_i[1];
|
318 |
|
|
end
|
319 |
|
|
else if( enable_n_char & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd4)
|
320 |
|
|
begin
|
321 |
|
|
tx_dout = data_tx_i[2];
|
322 |
|
|
end
|
323 |
|
|
else if( enable_n_char & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd5)
|
324 |
|
|
begin
|
325 |
|
|
tx_dout = data_tx_i[3];
|
326 |
|
|
end
|
327 |
|
|
else if( enable_n_char & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd6)
|
328 |
|
|
begin
|
329 |
|
|
tx_dout = data_tx_i[4];
|
330 |
|
|
end
|
331 |
|
|
else if( enable_n_char & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd7)
|
332 |
|
|
begin
|
333 |
|
|
tx_dout = data_tx_i[5];
|
334 |
|
|
end
|
335 |
|
|
else if( enable_n_char & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd8)
|
336 |
|
|
begin
|
337 |
|
|
tx_dout = data_tx_i[6];
|
338 |
|
|
end
|
339 |
|
|
else if( enable_n_char & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd9)
|
340 |
|
|
begin
|
341 |
|
|
tx_dout = data_tx_i[7];
|
342 |
|
|
end
|
343 |
|
|
else if( enable_n_char & data_tx_i[8] & data_tx_i[1:0] == 2'b00 & !first_time & global_counter_transfer == 4'd1)
|
344 |
|
|
begin
|
345 |
|
|
tx_dout = eop_s[2];
|
346 |
|
|
end
|
347 |
|
|
else if( enable_n_char & data_tx_i[8] & data_tx_i[1:0] == 2'b00 & !first_time & global_counter_transfer == 4'd2)
|
348 |
|
|
begin
|
349 |
|
|
tx_dout = eop_s[1];
|
350 |
|
|
end
|
351 |
|
|
else if( enable_n_char & data_tx_i[8] & data_tx_i[1:0] == 2'b00 & !first_time & global_counter_transfer == 4'd3)
|
352 |
|
|
begin
|
353 |
|
|
tx_dout = eop_s[0];
|
354 |
|
|
end
|
355 |
|
|
else if( enable_n_char & data_tx_i[8] & data_tx_i[1:0] == 2'b01 & !first_time & global_counter_transfer == 4'd1)
|
356 |
|
|
begin
|
357 |
|
|
tx_dout = eep_s[2];
|
358 |
|
|
end
|
359 |
|
|
else if( enable_n_char & data_tx_i[8] & data_tx_i[1:0] == 2'b01 & !first_time & global_counter_transfer == 4'd2)
|
360 |
|
|
begin
|
361 |
|
|
tx_dout = eep_s[1];
|
362 |
|
|
end
|
363 |
|
|
else if( enable_n_char & data_tx_i[8] & data_tx_i[1:0] == 2'b01 & !first_time & global_counter_transfer == 4'd3)
|
364 |
|
|
begin
|
365 |
|
|
tx_dout = eep_s[0];
|
366 |
|
|
end
|
367 |
|
|
end
|
368 |
|
|
|
369 |
|
|
//strobe
|
370 |
|
|
always@(*)
|
371 |
|
|
begin
|
372 |
|
|
tx_sout = 1'b0;
|
373 |
|
|
|
374 |
|
|
if(!enable_tx)
|
375 |
|
|
begin
|
376 |
|
|
tx_sout = 1'b0;
|
377 |
|
|
end
|
378 |
|
|
else if((enable_null | enable_fct) && tx_dout == last_tx_dout)
|
379 |
|
|
begin
|
380 |
|
|
tx_sout = !last_tx_sout;
|
381 |
|
|
end
|
382 |
|
|
else if((enable_null | enable_fct) && tx_dout != last_tx_dout)
|
383 |
|
|
begin
|
384 |
|
|
tx_sout = last_tx_sout;
|
385 |
|
|
end
|
386 |
|
|
end
|
387 |
|
|
|
388 |
|
|
//slots open in another side
|
389 |
|
|
always@(posedge send_fct_tx or negedge enable_tx)
|
390 |
|
|
begin
|
391 |
|
|
|
392 |
|
|
if(!enable_tx)
|
393 |
|
|
begin
|
394 |
|
|
fct_counter <= {6{1'b0}};
|
395 |
|
|
end
|
396 |
|
|
else if(gotfct_tx)
|
397 |
|
|
begin
|
398 |
|
|
fct_counter <= fct_counter + 6'd8;
|
399 |
|
|
end
|
400 |
|
|
else if(enable_n_char)
|
401 |
|
|
begin
|
402 |
|
|
fct_counter <= fct_counter - 6'd1;
|
403 |
|
|
end
|
404 |
|
|
|
405 |
|
|
end
|
406 |
|
|
|
407 |
|
|
|
408 |
|
|
//slots open in our side
|
409 |
|
|
always@(posedge send_fct_now or negedge enable_tx)
|
410 |
|
|
begin
|
411 |
|
|
|
412 |
|
|
if(!enable_tx)
|
413 |
|
|
begin
|
414 |
|
|
fct_send <= {3{1'b1}};
|
415 |
|
|
end
|
416 |
|
|
else
|
417 |
|
|
begin
|
418 |
|
|
fct_send <= fct_send + 6'd1;
|
419 |
|
|
end
|
420 |
|
|
|
421 |
|
|
end
|
422 |
|
|
|
423 |
|
|
|
424 |
|
|
always@(*)
|
425 |
|
|
begin
|
426 |
|
|
|
427 |
|
|
next_state_tx = state_tx;
|
428 |
|
|
|
429 |
|
|
enable_null = 1'b0;
|
430 |
|
|
enable_fct = 1'b0;
|
431 |
|
|
enable_n_char = 1'b0;
|
432 |
|
|
enable_time_code = 1'b0;
|
433 |
|
|
|
434 |
|
|
case(state_tx)
|
435 |
|
|
tx_spw_start:
|
436 |
|
|
begin
|
437 |
|
|
if(send_null_tx && enable_tx)
|
438 |
|
|
begin
|
439 |
|
|
if(global_counter_transfer == 4'd7)
|
440 |
|
|
next_state_tx = tx_spw_null;
|
441 |
|
|
|
442 |
|
|
enable_null = 1'b1;
|
443 |
|
|
end
|
444 |
|
|
else
|
445 |
|
|
begin
|
446 |
|
|
next_state_tx = tx_spw_start;
|
447 |
|
|
end
|
448 |
|
|
end
|
449 |
|
|
tx_spw_null:
|
450 |
|
|
begin
|
451 |
|
|
enable_null = 1'b1;
|
452 |
|
|
|
453 |
|
|
if(global_counter_transfer == 4'd7)
|
454 |
|
|
begin
|
455 |
|
|
if(send_null_tx && send_fct_tx && enable_tx)
|
456 |
|
|
next_state_tx = tx_spw_null_fct;
|
457 |
|
|
else
|
458 |
|
|
next_state_tx = tx_spw_null;
|
459 |
|
|
end
|
460 |
|
|
|
461 |
|
|
end
|
462 |
|
|
tx_spw_null_fct:
|
463 |
|
|
begin
|
464 |
|
|
|
465 |
|
|
enable_null = 1'b1;
|
466 |
|
|
next_state_tx = tx_spw_null_fct;
|
467 |
|
|
|
468 |
|
|
if(send_fct_tx && fct_flag != 3'd7)
|
469 |
|
|
begin
|
470 |
|
|
enable_null = 1'b0;
|
471 |
|
|
enable_fct = 1'b1;
|
472 |
|
|
end
|
473 |
|
|
else
|
474 |
|
|
begin
|
475 |
|
|
enable_fct = 1'b0;
|
476 |
|
|
|
477 |
|
|
if(send_fct_tx && gotfct_tx)
|
478 |
|
|
begin
|
479 |
|
|
if(global_counter_transfer == 4'd7)
|
480 |
|
|
next_state_tx = tx_spw_full;
|
481 |
|
|
end
|
482 |
|
|
|
483 |
|
|
end
|
484 |
|
|
end
|
485 |
|
|
tx_spw_full:
|
486 |
|
|
begin
|
487 |
|
|
|
488 |
|
|
enable_null = 1'b1;
|
489 |
|
|
|
490 |
|
|
if(tickin_tx)
|
491 |
|
|
begin
|
492 |
|
|
if(global_counter_transfer == 4'd7 || global_counter_transfer == 4'd9 || global_counter_transfer == 4'd13 || global_counter_transfer == 4'd3)
|
493 |
|
|
enable_time_code = 1'b1;
|
494 |
|
|
|
495 |
|
|
enable_null = 1'b0;
|
496 |
|
|
end
|
497 |
|
|
else if(fct_send > 3'd0)
|
498 |
|
|
begin
|
499 |
|
|
if(global_counter_transfer == 4'd7 || global_counter_transfer == 4'd9 || global_counter_transfer == 4'd13 || global_counter_transfer == 4'd3)
|
500 |
|
|
enable_fct = 1'b1;
|
501 |
|
|
|
502 |
|
|
enable_null = 1'b0;
|
503 |
|
|
end
|
504 |
|
|
else if(txwrite_tx && fct_counter > 6'd0)
|
505 |
|
|
begin
|
506 |
|
|
if(global_counter_transfer == 4'd7 || global_counter_transfer == 4'd9 || global_counter_transfer == 4'd13 || global_counter_transfer == 4'd3)
|
507 |
|
|
enable_n_char = 1'b1;
|
508 |
|
|
|
509 |
|
|
enable_null = 1'b0;
|
510 |
|
|
end
|
511 |
|
|
|
512 |
|
|
end
|
513 |
|
|
endcase
|
514 |
|
|
|
515 |
|
|
end
|
516 |
|
|
|
517 |
|
|
always@(posedge pclk_tx)
|
518 |
|
|
begin
|
519 |
|
|
if(!enable_tx)
|
520 |
|
|
begin
|
521 |
|
|
null_s <= 8'h74;
|
522 |
|
|
fct_s <= 4'h4;
|
523 |
|
|
eop_s <= 4'h5;
|
524 |
|
|
eep_s <= 4'h6;
|
525 |
|
|
timecode_s <= 14'h1e00;
|
526 |
|
|
|
527 |
|
|
fct_flag <= 3'd0;
|
528 |
|
|
first_time <= 1'b1;
|
529 |
|
|
last_type <= NULL;
|
530 |
|
|
|
531 |
|
|
global_counter_transfer <= 4'd0;
|
532 |
|
|
txdata_flagctrl_tx_last <= 9'd0;
|
533 |
|
|
last_timein_control_flag_tx <= 8'd0;
|
534 |
|
|
last_tx_dout <= 1'b0;
|
535 |
|
|
last_tx_sout <= 1'b0;
|
536 |
|
|
state_tx <= tx_spw_start;
|
537 |
|
|
end
|
538 |
|
|
else
|
539 |
|
|
begin
|
540 |
|
|
|
541 |
|
|
state_tx <= next_state_tx;
|
542 |
|
|
last_tx_dout <= tx_dout;
|
543 |
|
|
last_tx_sout <= tx_sout;
|
544 |
|
|
|
545 |
|
|
if(enable_null)
|
546 |
|
|
begin
|
547 |
|
|
fct_flag<= fct_flag;
|
548 |
|
|
if(first_time)
|
549 |
|
|
begin
|
550 |
|
|
first_time <= 1'b0;
|
551 |
|
|
|
552 |
|
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
553 |
|
|
end
|
554 |
|
|
else if(global_counter_transfer != 4'd7)
|
555 |
|
|
begin
|
556 |
|
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
557 |
|
|
end
|
558 |
|
|
else
|
559 |
|
|
begin
|
560 |
|
|
global_counter_transfer <= 4'd0;
|
561 |
|
|
end
|
562 |
|
|
end
|
563 |
|
|
else if(enable_fct)
|
564 |
|
|
begin
|
565 |
|
|
if(global_counter_transfer != 4'd3)
|
566 |
|
|
begin
|
567 |
|
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
568 |
|
|
end
|
569 |
|
|
else
|
570 |
|
|
begin
|
571 |
|
|
global_counter_transfer <= 4'd0;
|
572 |
|
|
fct_flag <= fct_flag + 3'd1;
|
573 |
|
|
end
|
574 |
|
|
end
|
575 |
|
|
else if(enable_time_code)
|
576 |
|
|
begin
|
577 |
|
|
fct_flag<= fct_flag;
|
578 |
|
|
if(global_counter_transfer < 4'd13)
|
579 |
|
|
begin
|
580 |
|
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
581 |
|
|
last_timein_control_flag_tx <= timecode_tx_i;
|
582 |
|
|
end
|
583 |
|
|
else
|
584 |
|
|
begin
|
585 |
|
|
global_counter_transfer <= 4'd0;
|
586 |
|
|
end
|
587 |
|
|
end
|
588 |
|
|
else if(enable_n_char)
|
589 |
|
|
begin
|
590 |
|
|
fct_flag<= fct_flag;
|
591 |
|
|
if(global_counter_transfer < 4'd9 && !data_tx_i[8])
|
592 |
|
|
begin
|
593 |
|
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
594 |
|
|
txdata_flagctrl_tx_last <= data_tx_i;
|
595 |
|
|
end
|
596 |
|
|
else if(global_counter_transfer < 4'd3 && data_tx_i[8])
|
597 |
|
|
begin
|
598 |
|
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
599 |
|
|
txdata_flagctrl_tx_last <= data_tx_i;
|
600 |
|
|
end
|
601 |
|
|
else
|
602 |
|
|
begin
|
603 |
|
|
global_counter_transfer <= 4'd0;
|
604 |
|
|
end
|
605 |
|
|
end
|
606 |
|
|
|
607 |
|
|
end
|
608 |
|
|
end
|
609 |
|
|
|
610 |
|
|
endmodule
|