OpenCores
URL https://opencores.org/ocsvn/spacewiresystemc/spacewiresystemc/trunk

Subversion Repositories spacewiresystemc

[/] [spacewiresystemc/] [trunk/] [rtl/] [RTL_VB/] [tx_spw.v] - Blame information for rev 38

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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 33 redbear
                output reg tx_dout_e,
54
                output reg tx_sout_e,
55 5 redbear
                //
56 8 redbear
                output  reg ready_tx_data,
57 13 redbear
                output  reg ready_tx_timecode
58 5 redbear
 
59
                );
60
 
61 37 redbear
localparam [6:0] tx_spw_start              = 7'b0000000,
62
                 tx_spw_null               = 7'b0000001,
63
                 tx_spw_fct                = 7'b0000010,
64
                 tx_spw_null_c             = 7'b0000100,
65
                 tx_spw_fct_c              = 7'b0001000,
66
                 tx_spw_data_c             = 7'b0010000,
67
                 tx_spw_time_code_c        = 7'b0100000;
68 5 redbear
 
69
localparam [5:0] NULL     = 6'b000001,
70
                 FCT      = 6'b000010,
71
                 EOP      = 6'b000100,
72
                 EEP      = 6'b001000,
73
                 DATA     = 6'b010000,
74
                 TIMEC    = 6'b100000;
75
 
76 25 redbear
 
77
localparam [7:0] null_s = 8'b01110100;
78
localparam [2:0] fct_s  = 3'b100;
79
localparam [3:0] eop_s  = 4'b0101;
80
localparam [3:0] eep_s  = 4'b0110;
81
localparam [13:0] timecode_ss    = 14'b01110000000000;
82
 
83
 
84
 
85 37 redbear
        reg [6:0] state_tx;
86
        reg [6:0] next_state_tx;
87 5 redbear
 
88 37 redbear
        reg  [2:0] state_fct_send;
89
        reg  [2:0] next_state_fct_send;
90
 
91
        reg  [2:0] state_fct_receive;
92
        reg  [2:0] next_state_fct_receive;
93
 
94 38 redbear
        reg  [2:0] state_data_fifo;
95
        reg  [2:0] next_state_data_fifo;
96
 
97 5 redbear
        reg [13:0] timecode_s;
98
 
99
        reg [5:0]  last_type;
100
        reg [8:0]  txdata_flagctrl_tx_last;
101 36 redbear
        reg [8:0]  tx_data_in;
102 38 redbear
        reg [8:0]  tx_data_took;
103
 
104
 
105 5 redbear
        reg [7:0]  last_timein_control_flag_tx;
106 36 redbear
        reg [7:0]  tx_tcode_in;
107
        reg tcode_rdy_trnsp;
108 5 redbear
 
109
        reg [2:0] fct_send;
110
        reg [2:0] fct_flag;
111 6 redbear
 
112
        reg [5:0] fct_counter_receive;
113
 
114 38 redbear
        reg data_ready_took;
115 37 redbear
        reg block_decrement;
116
        reg char_sent;
117
 
118
        reg fct_sent;
119
 
120 5 redbear
        reg last_tx_dout;
121
        reg last_tx_sout;
122
 
123 33 redbear
        reg tx_dout;
124
        reg tx_sout;
125
 
126
        reg tx_dout_null;
127
        reg tx_dout_fct;
128
        reg tx_dout_timecode;
129
        reg tx_dout_data;
130
 
131 5 redbear
        reg [3:0] global_counter_transfer;
132
 
133
 
134 13 redbear
 
135 5 redbear
always@(*)
136
begin
137 37 redbear
                tx_dout = last_tx_dout;
138 5 redbear
 
139 37 redbear
                case(state_tx)
140
                tx_spw_start:
141
                begin
142
                end
143
                tx_spw_null,tx_spw_null_c:
144
                begin
145
                         if(last_type == NULL  && global_counter_transfer[3:0] == 4'd0)
146
                         begin
147
                                tx_dout = !(null_s[6]^null_s[0]^null_s[1]);
148
                         end
149
                         else if(last_type == FCT  && global_counter_transfer[3:0] == 4'd0)
150
                         begin
151
                                tx_dout = !(null_s[6]^fct_s[0]^fct_s[1]);
152
                         end
153
                         else if(last_type == EOP  && global_counter_transfer[3:0] == 4'd0)
154
                         begin
155
                                tx_dout = !(null_s[6]^eop_s[0]^eop_s[1]);
156
                         end
157
                         else if(last_type == EEP  && global_counter_transfer[3:0] == 4'd0)
158
                         begin
159
                                tx_dout = !(null_s[6]^eep_s[0]^eep_s[1]);
160
                         end
161
                         else if(last_type == DATA  && global_counter_transfer[3:0] == 4'd0)
162
                         begin
163
                                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]);
164
                         end
165
                         else if(last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
166
                         begin
167
                                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]);
168
                         end
169
                         else if(global_counter_transfer[3:0] == 4'd1)
170
                         begin
171
                                tx_dout = null_s[6];
172
                         end
173
                         else if(global_counter_transfer[3:0] == 4'd2)
174
                         begin
175
                                tx_dout = null_s[5];
176
                         end
177
                         else if(global_counter_transfer[3:0] == 4'd3)
178
                         begin
179
                                tx_dout = null_s[4];
180
                         end
181
                         else if(global_counter_transfer[3:0] == 4'd4)
182
                         begin
183
                                tx_dout = null_s[3];
184
                         end
185
                         else if(global_counter_transfer[3:0] == 4'd5)
186
                         begin
187
                                tx_dout = null_s[2];
188
                         end
189
                         else if(global_counter_transfer[3:0] == 4'd6)
190
                         begin
191
                                tx_dout = null_s[1];
192
                         end
193
                         else if(global_counter_transfer[3:0] == 4'd7)
194
                         begin
195
                                tx_dout = null_s[0];
196
                         end
197
                end
198
                tx_spw_fct,tx_spw_fct_c:
199
                begin
200
                         if(last_type == NULL  && global_counter_transfer[3:0] == 4'd0)
201
                         begin
202
                                tx_dout = !(fct_s[2]^null_s[0]^null_s[1]);
203
                         end
204
                         else if(last_type == FCT  && global_counter_transfer[3:0] == 4'd0)
205
                         begin
206
                                tx_dout = !(fct_s[2]^fct_s[0]^fct_s[1]);
207
                         end
208
                         else if(last_type == EOP  && global_counter_transfer[3:0] == 4'd0)
209
                         begin
210
                                tx_dout = !(fct_s[2]^eop_s[0]^eop_s[1]);
211
                         end
212
                         else if(last_type == EEP  && global_counter_transfer[3:0] == 4'd0)
213
                         begin
214
                                tx_dout = !(fct_s[2]^eep_s[0]^eep_s[1]);
215
                         end
216
                         else if (last_type == DATA && global_counter_transfer[3:0] == 4'd0)
217
                         begin
218
                                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]);
219
                         end
220
                         else if(last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
221
                         begin
222
                                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]);
223
                         end
224
                         else if(global_counter_transfer[3:0] == 4'd1)
225
                         begin
226
                                tx_dout = fct_s[2];
227
                         end
228
                         else if(global_counter_transfer[3:0] == 4'd2)
229
                         begin
230
                                tx_dout = fct_s[1];
231
                         end
232
                         else if(global_counter_transfer[3:0] == 4'd3)
233
                         begin
234
                                tx_dout = fct_s[0];
235
                         end
236
                end
237
                tx_spw_data_c:
238
                begin
239
                        if(!tx_data_in[8] && last_type == NULL  && global_counter_transfer[3:0] == 4'd0)
240
                         begin
241
                                tx_dout = !(tx_data_in[8]^null_s[0]^null_s[1]);
242
                         end
243
                         else if(!tx_data_in[8] && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
244
                         begin
245
                                tx_dout = !(tx_data_in[8]^fct_s[0]^fct_s[1]);
246
                         end
247
                         else if(!tx_data_in[8] && last_type == EOP  && global_counter_transfer[3:0] == 4'd0)
248
                         begin
249
                                tx_dout = !(tx_data_in[8]^eop_s[0]^eop_s[1]);
250
                         end
251
                         else if(!tx_data_in[8] && last_type == EEP  && global_counter_transfer[3:0] == 4'd0)
252
                         begin
253
                                tx_dout = !(tx_data_in[8]^eep_s[0]^eep_s[1]);
254
                         end
255
                         else if(!tx_data_in[8] && last_type == DATA  && global_counter_transfer[3:0] == 4'd0)
256
                         begin
257
                                tx_dout = !(tx_data_in[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]);
258
                         end
259
                         else if(!tx_data_in[8] && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
260
                         begin
261
                                tx_dout = !(tx_data_in[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]);
262
                         end
263
                         else if(tx_data_in[8]  && tx_data_in[1:0] == 2'b00 && last_type == NULL  && global_counter_transfer[3:0] == 4'd0)
264
                         begin
265
                                tx_dout = !(eop_s[2]^null_s[0]^null_s[1]);
266
                         end
267
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == FCT   && global_counter_transfer[3:0] == 4'd0)
268
                         begin
269
                                tx_dout = !(eop_s[2]^fct_s[0]^fct_s[1]);
270
                         end
271
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == EOP  && global_counter_transfer[3:0] == 4'd0)
272
                         begin
273
                                tx_dout = !(eop_s[2]^eop_s[0]^eop_s[1]);
274
                         end
275
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == EEP  && global_counter_transfer[3:0] == 4'd0)
276
                         begin
277
                                tx_dout = !(eop_s[2]^eep_s[0]^eep_s[1]);
278
                         end
279
                         else if(tx_data_in[8]  && tx_data_in[1:0] == 2'b00 && last_type == DATA  && global_counter_transfer[3:0] == 4'd0)
280
                         begin
281
                                tx_dout = !(eop_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]);
282
                         end
283
                         else if(tx_data_in[8]  && tx_data_in[1:0] == 2'b00 && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
284
                         begin
285
                                tx_dout = !(eop_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]);
286
                         end
287
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == NULL  && global_counter_transfer[3:0] == 4'd0)
288
                         begin
289
                                tx_dout = !(eep_s[2]^null_s[0]^null_s[1]);
290
                         end
291
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == FCT  && global_counter_transfer[3:0] == 4'd0)
292
                         begin
293
                                tx_dout = !(eep_s[2]^fct_s[0]^fct_s[1]);
294
                         end
295
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == EOP  && global_counter_transfer[3:0] == 4'd0)
296
                         begin
297
                                tx_dout = !(eep_s[2]^eop_s[0]^eop_s[1]);
298
                         end
299
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
300
                         begin
301
                                tx_dout = !(eep_s[2]^eep_s[0]^eep_s[1]);
302
                         end
303
                         else if(tx_data_in[8]  && tx_data_in[1:0] == 2'b01 && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
304
                         begin
305
                                tx_dout = !(eep_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]);
306
                         end
307
                         else if(tx_data_in[8]  &&  tx_data_in[1:0] == 2'b01 && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
308
                         begin
309
                                tx_dout = !(eep_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]);
310
                         end
311
                         else if(!tx_data_in[8] &&  global_counter_transfer[3:0] == 4'd1)
312
                         begin
313
                                tx_dout = tx_data_in[8];
314
                         end
315
                         else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd2)
316
                         begin
317
                                tx_dout = tx_data_in[0];
318
                         end
319
                         else if(!tx_data_in[8] &&  global_counter_transfer[3:0] == 4'd3)
320
                         begin
321
                                tx_dout = tx_data_in[1];
322
                         end
323
                         else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd4)
324
                         begin
325
                                tx_dout = tx_data_in[2];
326
                         end
327
                         else if(!tx_data_in[8]  && global_counter_transfer[3:0] == 4'd5)
328
                         begin
329
                                tx_dout = tx_data_in[3];
330
                         end
331
                         else if(!tx_data_in[8]  && global_counter_transfer[3:0] == 4'd6)
332
                         begin
333
                                tx_dout = tx_data_in[4];
334
                         end
335
                         else if(!tx_data_in[8]  && global_counter_transfer[3:0] == 4'd7)
336
                         begin
337
                                tx_dout = tx_data_in[5];
338
                         end
339
                         else if(!tx_data_in[8] &&  global_counter_transfer[3:0] == 4'd8)
340
                         begin
341
                                tx_dout = tx_data_in[6];
342
                         end
343
                         else if(!tx_data_in[8] &&  global_counter_transfer[3:0] == 4'd9)
344
                         begin
345
                                tx_dout = tx_data_in[7];
346
                         end
347
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd1)
348
                         begin
349
                                tx_dout = eep_s[2];
350
                         end
351
                         else if( tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd2)
352
                         begin
353
                                tx_dout = eep_s[1];
354
                         end
355
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd3)
356
                         begin
357
                                tx_dout = eep_s[0];
358
                         end
359
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd1)
360
                         begin
361
                                tx_dout = eop_s[2];
362
                         end
363
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd2)
364
                         begin
365
                                tx_dout = eop_s[1];
366
                         end
367
                         else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd3)
368
                         begin
369
                                tx_dout = eop_s[0];
370
                         end
371
                end
372
                tx_spw_time_code_c:
373
                begin
374
                         if(last_type == NULL  && global_counter_transfer[3:0] == 4'd0)
375
                         begin
376
                                tx_dout = !(timecode_s[12]^null_s[0]^null_s[1]);
377
                         end
378
                         else if(last_type == FCT   && global_counter_transfer[3:0] == 4'd0)
379
                         begin
380
                                tx_dout = !(timecode_s[12]^fct_s[0]^fct_s[1]);
381
                         end
382
                         else if (last_type == EOP   && global_counter_transfer[3:0] == 4'd0)
383
                         begin
384
                                tx_dout = !(timecode_s[12]^eop_s[0]^eop_s[1]);
385
                         end
386
                         else if( last_type == EEP   && global_counter_transfer[3:0] == 4'd0)
387
                         begin
388
                                tx_dout = !(timecode_s[12]^eep_s[0]^eep_s[1]);
389
                         end
390
                         else if( last_type == DATA  && global_counter_transfer[3:0] == 4'd0)
391
                         begin
392
                                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]);
393
                         end
394
                         else if( last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
395
                         begin
396
                                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]);
397
                         end
398
                         else if( global_counter_transfer[3:0] == 4'd1)
399
                         begin
400
                                tx_dout = timecode_s[12];
401
                         end
402
                         else if( global_counter_transfer[3:0] == 4'd2)
403
                         begin
404
                                tx_dout = timecode_s[11];
405
                         end
406
                         else if( global_counter_transfer[3:0] == 4'd3)
407
                         begin
408
                                tx_dout = timecode_s[10];
409
                         end
410
                         else if( global_counter_transfer[3:0] == 4'd4)
411
                         begin
412
                                tx_dout = timecode_s[9];
413
                         end
414
                         else if( global_counter_transfer[3:0] == 4'd5)
415
                         begin
416
                                tx_dout = timecode_s[8];
417
                         end
418
                         else if( global_counter_transfer[3:0] == 4'd6)
419
                         begin
420
                                tx_dout = timecode_s[0];
421
                         end
422
                         else if( global_counter_transfer[3:0] == 4'd7)
423
                         begin
424
                                tx_dout = timecode_s[1];
425
                         end
426
                         else if( global_counter_transfer[3:0] == 4'd8)
427
                         begin
428
                                tx_dout = timecode_s[2];
429
                         end
430
                         else if(global_counter_transfer[3:0] == 4'd9)
431
                         begin
432
                                tx_dout = timecode_s[3];
433
                         end
434
                         else if(global_counter_transfer[3:0] == 4'd10)
435
                         begin
436
                                tx_dout = timecode_s[4];
437
                         end
438
                         else if(global_counter_transfer[3:0] == 4'd11)
439
                         begin
440
                                tx_dout = timecode_s[5];
441
                         end
442
                         else if( global_counter_transfer[3:0] == 4'd12)
443
                         begin
444
                                tx_dout = timecode_s[6];
445
                         end
446
                         else if(global_counter_transfer[3:0] == 4'd13)
447
                         begin
448
                                tx_dout = timecode_s[7];
449
                         end
450
                end
451
                default:
452
                begin
453
                end
454
                endcase
455 5 redbear
end
456 33 redbear
 
457 5 redbear
//strobe
458
always@(*)
459
begin
460
 
461 36 redbear
        tx_sout = last_tx_sout;
462
 
463 37 redbear
        if(tx_dout == last_tx_dout)
464 5 redbear
        begin
465
                tx_sout = !last_tx_sout;
466
        end
467 37 redbear
        else if(tx_dout != last_tx_dout)
468 5 redbear
        begin
469
                tx_sout = last_tx_sout;
470 33 redbear
        end
471 5 redbear
end
472
 
473 17 redbear
always@(*)
474 5 redbear
begin
475 37 redbear
        next_state_fct_send = state_fct_send;
476 17 redbear
 
477 37 redbear
        case(state_fct_send)
478
        3'd0:
479 5 redbear
        begin
480 37 redbear
                if(send_fct_now)
481 15 redbear
                begin
482 37 redbear
                        next_state_fct_send = 3'd1;
483 17 redbear
                end
484 37 redbear
                else if(fct_sent)
485 17 redbear
                begin
486 37 redbear
                        next_state_fct_send = 3'd3;
487 15 redbear
                end
488 37 redbear
                else
489
                        next_state_fct_send = 3'd0;
490 5 redbear
        end
491 37 redbear
        3'd1:
492
        begin
493 38 redbear
                if(global_counter_transfer > 4'd0 &&  global_counter_transfer < 4'd12)
494 37 redbear
                begin
495
                        next_state_fct_send = 3'd2;
496
                end
497
                else
498
                begin
499
                        next_state_fct_send = 3'd1;
500
                end
501
        end
502
        3'd2:
503
        begin
504
                if(send_fct_now)
505
                begin
506
                        next_state_fct_send = 3'd2;
507
                end
508
                else
509
                begin
510
                        next_state_fct_send = 3'd0;
511
                end
512
        end
513
        3'd3:
514
        begin
515 38 redbear
                if(global_counter_transfer > 4'd0 &&  global_counter_transfer < 4'd12)
516 37 redbear
                begin
517
                        next_state_fct_send = 3'd4;
518
                end
519
                else
520
                begin
521
                        next_state_fct_send = 3'd3;
522
                end
523
        end
524
        3'd4:
525
        begin
526
                if(fct_sent)
527
                begin
528
                        next_state_fct_send = 3'd4;
529
                end
530
                else
531
                begin
532
                        next_state_fct_send = 3'd0;
533
                end
534
        end
535
        default:
536
        begin
537
                next_state_fct_send = 3'd0;
538
        end
539
        endcase
540 5 redbear
end
541
 
542 37 redbear
always@(posedge pclk_tx or negedge enable_tx)
543 5 redbear
begin
544 37 redbear
        if(!enable_tx)
545
        begin
546
                fct_flag <= 3'd7;
547
                state_fct_send<= 3'd0;
548
        end
549
        else
550
        begin
551
                state_fct_send <= next_state_fct_send;
552 5 redbear
 
553 37 redbear
                case(state_fct_send)
554
                3'd0:
555 19 redbear
                begin
556 37 redbear
                        fct_flag <= fct_flag;
557 6 redbear
                end
558 37 redbear
                3'd1:
559 6 redbear
                begin
560 38 redbear
                        if(global_counter_transfer > 4'd0 &&  global_counter_transfer < 4'd12)
561 37 redbear
                                fct_flag <= fct_flag + 3'd1;
562 19 redbear
                        else
563 37 redbear
                                fct_flag <= fct_flag;
564 6 redbear
                end
565 37 redbear
                3'd2:
566
                begin
567
                        fct_flag <= fct_flag;
568
                end
569
                3'd3:
570
                begin
571 38 redbear
                        if(global_counter_transfer > 4'd0 &&  global_counter_transfer < 4'd12)
572 37 redbear
                                fct_flag <= fct_flag - 3'd1;
573
                        else
574
                                fct_flag <= fct_flag;
575
                end
576
                3'd4:
577
                begin
578
                        fct_flag <= fct_flag;
579
                end
580
                default:
581
                begin
582
                        fct_flag <= fct_flag;
583
                end
584
                endcase
585 5 redbear
        end
586
end
587
 
588 37 redbear
 
589 36 redbear
always@(*)
590
begin
591 37 redbear
        next_state_fct_receive = state_fct_receive;
592 5 redbear
 
593 37 redbear
        case(state_fct_receive)
594
        3'd0:
595 36 redbear
        begin
596 37 redbear
                if(gotfct_tx)
597
                begin
598
                        next_state_fct_receive = 3'd1;
599
                end
600
                else if(char_sent)
601
                begin
602
                        next_state_fct_receive = 3'd3;
603
                end
604
                else
605
                        next_state_fct_receive = 3'd0;
606 36 redbear
        end
607 37 redbear
        3'd1:
608 36 redbear
        begin
609 38 redbear
                if(global_counter_transfer > 4'd0 &&  global_counter_transfer < 4'd12)
610 37 redbear
                begin
611
                        next_state_fct_receive = 3'd2;
612
                end
613
                else
614
                begin
615
                        next_state_fct_receive = 3'd1;
616
                end
617 36 redbear
        end
618 37 redbear
        3'd2:
619 36 redbear
        begin
620 37 redbear
                if(gotfct_tx)
621
                begin
622
                        next_state_fct_receive = 3'd2;
623
                end
624
                else
625
                begin
626
                        next_state_fct_receive = 3'd0;
627
                end
628 36 redbear
        end
629 37 redbear
        3'd3:
630 36 redbear
        begin
631 38 redbear
                if(global_counter_transfer > 4'd0 &&  global_counter_transfer < 4'd12)
632 37 redbear
                begin
633
                        next_state_fct_receive = 3'd4;
634
                end
635
                else
636
                begin
637
                        next_state_fct_receive = 3'd3;
638
                end
639 36 redbear
        end
640 37 redbear
        3'd4:
641
        begin
642
                if(char_sent)
643
                begin
644
                        next_state_fct_receive = 3'd4;
645
                end
646
                else
647
                begin
648
                        next_state_fct_receive = 3'd0;
649
                end
650
        end
651
        default:
652
        begin
653
                next_state_fct_receive = 3'd0;
654
        end
655
        endcase
656 36 redbear
end
657
 
658 37 redbear
 
659
always@(posedge pclk_tx or negedge enable_tx)
660 5 redbear
begin
661 37 redbear
        if(!enable_tx)
662
        begin
663
                fct_counter_receive<= 6'd0;
664
                state_fct_receive <= 3'd0;
665
        end
666
        else
667
        begin
668 5 redbear
 
669 37 redbear
                state_fct_receive <= next_state_fct_receive;
670 5 redbear
 
671 37 redbear
                case(state_fct_receive)
672
                3'd0:
673
                begin
674
                        fct_counter_receive <= fct_counter_receive;
675
                end
676
                3'd1:
677
                begin
678 38 redbear
                        if(global_counter_transfer > 4'd0 &&  global_counter_transfer < 4'd12)
679 37 redbear
                        begin
680
                                if(fct_counter_receive < 6'd48)
681
                                begin
682
                                        fct_counter_receive <= fct_counter_receive + 6'd8;
683
                                end
684
                                else
685
                                begin
686
                                        fct_counter_receive <= fct_counter_receive + 6'd7;
687
                                end
688
                        end
689
                        else
690
                                fct_counter_receive <= fct_counter_receive;
691
                end
692
                3'd2:
693
                begin
694
                        fct_counter_receive <= fct_counter_receive;
695
                end
696
                3'd3:
697
                begin
698 38 redbear
                        if(global_counter_transfer > 4'd0 &&  global_counter_transfer < 4'd12)
699
                        begin
700
                                if(fct_counter_receive == 6'd0)
701
                                        fct_counter_receive <= fct_counter_receive;
702
                                else
703
                                        fct_counter_receive <= fct_counter_receive - 6'd1;
704
                        end
705 37 redbear
                        else
706
                                fct_counter_receive <= fct_counter_receive;
707
                end
708
                3'd4:
709
                begin
710
                        fct_counter_receive <= fct_counter_receive;
711
                end
712
                default:
713
                begin
714
                        fct_counter_receive <= fct_counter_receive;
715
                end
716
                endcase
717
        end
718
end
719 5 redbear
 
720 38 redbear
 
721 37 redbear
always@(*)
722
begin
723 38 redbear
        next_state_data_fifo = state_data_fifo;
724
 
725
        case(state_data_fifo)
726
        3'd0:
727
        begin
728
                if(!ready_tx_data && txwrite_tx)
729
                begin
730
                        next_state_data_fifo = 3'd1;
731
                end
732
                else
733
                        next_state_data_fifo = 3'd0;
734
        end
735
        3'd1:
736
        begin
737
                next_state_data_fifo = 3'd2;
738
        end
739
        3'd2:
740
        begin
741
 
742
                if(state_tx == tx_spw_null_c && global_counter_transfer > 4'd1 && global_counter_transfer < 4'd7)
743
                        next_state_data_fifo = 3'd3;
744
                else if(state_tx == tx_spw_data_c && global_counter_transfer > 4'd1 && global_counter_transfer < 4'd9)
745
                        next_state_data_fifo = 3'd3;
746
                else
747
                        next_state_data_fifo = 3'd2;
748
        end
749
        3'd3:
750
        begin
751
                if(!ready_tx_data && txwrite_tx)
752
                begin
753
                        next_state_data_fifo = 3'd3;
754
                end
755
                else
756
                begin
757
                        next_state_data_fifo = 3'd0;
758
                end
759
        end
760
        default:
761
        begin
762
                next_state_data_fifo = 3'd0;
763
        end
764
        endcase
765
end
766
 
767
always@(posedge pclk_tx or negedge enable_tx)
768
begin
769
        if(!enable_tx)
770
        begin
771
                data_ready_took <= 1'b0;
772
                state_data_fifo <= 3'd0;
773
                tx_data_took <= 9'd0;
774
        end
775
        else
776
        begin
777
 
778
                state_data_fifo <= next_state_data_fifo;
779
 
780
                case(state_data_fifo)
781
                3'd0:
782
                begin
783
                        //tx_data_took <= tx_data_took;
784
                end
785
                3'd1:
786
                begin
787
                        tx_data_took <= data_tx_i;
788
                end
789
                3'd2:
790
                begin
791
                        tx_data_took <= data_tx_i;
792
 
793
                        if(state_tx == tx_spw_null_c && global_counter_transfer > 4'd0 && global_counter_transfer < 4'd7)
794
                                data_ready_took <= 1'b1;
795
                        else if(state_tx == tx_spw_data_c && global_counter_transfer > 4'd0 && global_counter_transfer < 4'd9)
796
                                data_ready_took <= 1'b1;
797
                        else
798
                                data_ready_took <= 1'b0;
799
                end
800
                3'd3:
801
                begin
802
                        if(!ready_tx_data && txwrite_tx)
803
                        begin
804
                                data_ready_took <= 1'b1;
805
                        end
806
                        else
807
                        begin
808
                                data_ready_took <= 1'b0;
809
                        end
810
                end
811
                default:
812
                begin
813
                end
814
                endcase
815
        end
816
end
817
 
818
always@(*)
819
begin
820 17 redbear
        next_state_tx = state_tx;
821
 
822 5 redbear
        case(state_tx)
823
        tx_spw_start:
824
        begin
825
                if(send_null_tx && enable_tx)
826
                begin
827 36 redbear
                        next_state_tx = tx_spw_null;
828 5 redbear
                end
829
                else
830
                begin
831
                        next_state_tx = tx_spw_start;
832
                end
833
        end
834
        tx_spw_null:
835
        begin
836 37 redbear
                if(send_null_tx && send_fct_tx && enable_tx)
837 5 redbear
                begin
838 37 redbear
                        if(global_counter_transfer == 4'd7)
839
                                next_state_tx = tx_spw_fct;
840 38 redbear
                        else
841
                                next_state_tx = tx_spw_null;
842 5 redbear
                end
843 37 redbear
                else
844
                        next_state_tx = tx_spw_null;
845 5 redbear
        end
846 37 redbear
        tx_spw_fct:
847 5 redbear
        begin
848 38 redbear
                if(send_fct_tx && global_counter_transfer == 4'd3)
849 5 redbear
                begin
850 38 redbear
                        if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
851 5 redbear
                        begin
852 38 redbear
                                next_state_tx = tx_spw_time_code_c;
853
                        end
854
                        else if(fct_flag > 3'd0 && !send_fct_now)
855
                        begin
856
                                next_state_tx = tx_spw_fct;
857 5 redbear
                        end
858 38 redbear
                        else
859
                        begin
860
                                next_state_tx = tx_spw_null_c;
861
                        end
862 5 redbear
                end
863 38 redbear
                else
864
                        next_state_tx = tx_spw_fct;
865 5 redbear
        end
866 37 redbear
        tx_spw_null_c:
867 5 redbear
        begin
868 37 redbear
                if(global_counter_transfer == 4'd7)
869 5 redbear
                begin
870 37 redbear
                        if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
871
                        begin
872
                                next_state_tx = tx_spw_time_code_c;
873
                        end
874
                        else if(fct_flag > 3'd0 && !send_fct_now)
875
                        begin
876
                                next_state_tx = tx_spw_fct_c;
877
                        end
878 38 redbear
                        else if(data_ready_took && !gotfct_tx && fct_counter_receive > 6'd0)
879 37 redbear
                        begin
880
                                next_state_tx = tx_spw_data_c;
881
                        end
882
                        else
883
                        begin
884
                                next_state_tx = tx_spw_null_c;
885
                        end
886
                end
887
                else
888 5 redbear
                begin
889 37 redbear
                        next_state_tx = tx_spw_null_c;
890 5 redbear
                end
891 37 redbear
        end
892
        tx_spw_fct_c:
893
        begin
894
                if(global_counter_transfer == 4'd3)
895 5 redbear
                begin
896 37 redbear
                        if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
897
                        begin
898
                                next_state_tx = tx_spw_time_code_c;
899
                        end
900
                        else
901
                        begin
902
                                next_state_tx = tx_spw_null_c;
903
                        end
904 5 redbear
                end
905 37 redbear
                else
906 8 redbear
                begin
907 37 redbear
                        next_state_tx = tx_spw_fct_c;
908 8 redbear
                end
909 5 redbear
        end
910 37 redbear
        tx_spw_data_c:
911
        begin
912
 
913
                if(!tx_data_in[8])
914
                begin
915
                        if(global_counter_transfer == 4'd9)
916
                        begin
917
                                if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
918
                                begin
919
                                        next_state_tx = tx_spw_time_code_c;
920
                                end
921
                                else if(fct_flag > 3'd0 && !send_fct_now)
922
                                begin
923
                                        next_state_tx = tx_spw_fct_c;
924
                                end
925 38 redbear
                                else if(data_ready_took && !gotfct_tx && fct_counter_receive > 6'd0)
926
                                begin
927
                                        next_state_tx = tx_spw_data_c;
928
                                end
929 37 redbear
                                else
930
                                begin
931
                                        next_state_tx = tx_spw_null_c;
932
                                end
933
                        end
934
                        else
935
                                next_state_tx = tx_spw_data_c;
936
                end
937
                else if(tx_data_in[8])
938
                begin
939
                        if(global_counter_transfer == 4'd3)
940
                        begin
941
                                if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
942
                                begin
943
                                        next_state_tx = tx_spw_time_code_c;
944
                                end
945
                                else if(fct_flag > 3'd0 && !send_fct_now)
946
                                begin
947
                                        next_state_tx = tx_spw_fct_c;
948
                                end
949
                                else
950
                                begin
951
                                        next_state_tx = tx_spw_null_c;
952
                                end
953
                        end
954
                        else
955
                                next_state_tx = tx_spw_data_c;
956
                end
957
 
958
 
959
        end
960
        tx_spw_time_code_c:
961
        begin
962
                if(global_counter_transfer == 4'd13)
963
                begin
964
                        if(fct_flag > 3'd0 && !send_fct_now)
965
                        begin
966
                                next_state_tx = tx_spw_fct_c;
967
                        end
968 38 redbear
                        else if(data_ready_took && !gotfct_tx && fct_counter_receive > 6'd0 )
969 37 redbear
                        begin
970
                                next_state_tx = tx_spw_data_c;
971
                        end
972
                        else
973
                        begin
974
                                next_state_tx = tx_spw_null_c;
975
                        end
976
                end
977
                else
978
                begin
979
                        next_state_tx = tx_spw_time_code_c;
980
                end
981
        end
982
        default:
983
        begin
984
                next_state_tx = tx_spw_start;
985
        end
986 5 redbear
        endcase
987
end
988
 
989 33 redbear
 
990 25 redbear
always@(posedge pclk_tx or negedge enable_tx)
991 5 redbear
begin
992
        if(!enable_tx)
993
        begin
994 25 redbear
 
995
                timecode_s    <= 14'b01110000000000;
996 6 redbear
 
997 13 redbear
                ready_tx_data     <= 1'b0;
998
                ready_tx_timecode <= 1'b0;
999 8 redbear
 
1000 5 redbear
                last_type  <= NULL;
1001
 
1002
                global_counter_transfer <= 4'd0;
1003 38 redbear
                txdata_flagctrl_tx_last <= 9'd0;
1004
                tx_data_in <= 9'd0;
1005 5 redbear
                last_timein_control_flag_tx <= 8'd0;
1006 6 redbear
 
1007 37 redbear
                char_sent<= 1'b0;
1008
                fct_sent <= 1'b0;
1009 6 redbear
 
1010 5 redbear
                last_tx_dout      <= 1'b0;
1011
                last_tx_sout      <= 1'b0;
1012 33 redbear
 
1013 5 redbear
                state_tx <= tx_spw_start;
1014 17 redbear
 
1015 36 redbear
                tx_dout_e <= 1'b0;
1016
                tx_sout_e <= 1'b0;
1017
 
1018
                tx_tcode_in     <= 8'd0;
1019
                tcode_rdy_trnsp <= 1'b0;
1020
 
1021 5 redbear
        end
1022
        else
1023
        begin
1024
                state_tx <= next_state_tx;
1025 36 redbear
 
1026 37 redbear
                case(state_tx)
1027
                tx_spw_start:
1028
                begin
1029 38 redbear
                        global_counter_transfer <= 4'd0;
1030 37 redbear
                end
1031
                tx_spw_null:
1032
                begin
1033 5 redbear
 
1034 37 redbear
                        last_tx_dout <= tx_dout;
1035
                        last_tx_sout <= tx_sout;
1036 36 redbear
 
1037 37 redbear
                        tx_dout_e <= last_tx_dout;
1038
                        tx_sout_e <= last_tx_sout;
1039 6 redbear
 
1040 37 redbear
 
1041 38 redbear
                        if(tickin_tx && global_counter_transfer == 4'd5)
1042 36 redbear
                        begin
1043
                                tx_tcode_in <= timecode_tx_i;
1044
                                tcode_rdy_trnsp <= 1'b1;
1045
                        end
1046
                        else
1047
                                tx_tcode_in <= tx_tcode_in;
1048
 
1049 34 redbear
 
1050 36 redbear
                        if(global_counter_transfer == 4'd7)
1051 5 redbear
                        begin
1052 36 redbear
                                last_type  <= NULL;
1053
                                global_counter_transfer <= 4'd0;
1054 5 redbear
                        end
1055 38 redbear
                        else
1056 5 redbear
                        begin
1057 36 redbear
                                last_type  <= last_type;
1058 5 redbear
                                global_counter_transfer <= global_counter_transfer + 4'd1;
1059
                        end
1060
                end
1061 37 redbear
                tx_spw_fct:
1062 5 redbear
                begin
1063 8 redbear
 
1064 37 redbear
                        last_tx_dout <= tx_dout;
1065
                        last_tx_sout <= tx_sout;
1066 25 redbear
 
1067 37 redbear
                        tx_dout_e <= last_tx_dout;
1068
                        tx_sout_e <= last_tx_sout;
1069 6 redbear
 
1070 34 redbear
                        if(global_counter_transfer == 4'd3)
1071
                        begin
1072 36 redbear
                                last_type  <=FCT;
1073
                                global_counter_transfer <= 4'd0;
1074 37 redbear
                                fct_sent <= 1'b0;
1075 34 redbear
                        end
1076
                        else
1077
                        begin
1078 37 redbear
                                if(fct_flag > 3'd0)
1079
                                        fct_sent <=  1'b1;
1080 19 redbear
                                else
1081 37 redbear
                                        fct_sent <= fct_sent;
1082 38 redbear
 
1083 36 redbear
                                global_counter_transfer <= global_counter_transfer + 4'd1;
1084 5 redbear
                        end
1085
                end
1086 37 redbear
                tx_spw_null_c:
1087 5 redbear
                begin
1088 33 redbear
 
1089 37 redbear
                        last_tx_dout <= tx_dout;
1090
                        last_tx_sout <= tx_sout;
1091
 
1092
                        tx_dout_e <= last_tx_dout;
1093
                        tx_sout_e <= last_tx_sout;
1094
 
1095 38 redbear
                        if(global_counter_transfer == 4'd7)
1096 36 redbear
                        begin
1097 38 redbear
                                last_type  <= NULL;
1098
                                global_counter_transfer <= 4'd0;
1099 36 redbear
 
1100 38 redbear
                                if(data_ready_took)
1101
                                        tx_data_in <= tx_data_took;
1102
                                else
1103
                                        tx_data_in <= tx_data_in;
1104 17 redbear
                        end
1105
                        else
1106 13 redbear
                        begin
1107 37 redbear
                                char_sent <= 1'b0;
1108
                                fct_sent <=  1'b0;
1109
                                ready_tx_timecode <= 1'b0;
1110
                                last_type  <= last_type;
1111
                                global_counter_transfer <= global_counter_transfer + 4'd1;
1112 19 redbear
                        end
1113 37 redbear
                end
1114
                tx_spw_fct_c:
1115
                begin
1116 6 redbear
 
1117 37 redbear
                        last_tx_dout <= tx_dout;
1118
                        last_tx_sout <= tx_sout;
1119
 
1120
                        tx_dout_e <= last_tx_dout;
1121
                        tx_sout_e <= last_tx_sout;
1122
 
1123
                        if(global_counter_transfer == 4'd3)
1124
                        begin
1125
                                char_sent <= 1'b0;
1126
                                last_type  <=FCT;
1127
                                fct_sent <=  1'b0;
1128
                                global_counter_transfer <= 4'd0;
1129 5 redbear
                        end
1130
                        else
1131
                        begin
1132 37 redbear
                                if(fct_flag > 3'd0)
1133
                                        fct_sent <=  1'b1;
1134
                                else
1135
                                        fct_sent <= fct_sent;
1136
 
1137
                                global_counter_transfer <= global_counter_transfer + 4'd1;
1138 5 redbear
                        end
1139
                end
1140 37 redbear
                tx_spw_data_c:
1141 5 redbear
                begin
1142 6 redbear
 
1143 37 redbear
                        last_tx_dout <= tx_dout;
1144
                        last_tx_sout <= tx_sout;
1145
 
1146
                        tx_dout_e <= last_tx_dout;
1147
                        tx_sout_e <= last_tx_sout;
1148
 
1149
                        fct_sent <=  1'b0;
1150
 
1151 36 redbear
                        if(!tx_data_in[8])
1152 5 redbear
                        begin
1153 8 redbear
 
1154
                                if(global_counter_transfer == 4'd9)
1155
                                begin
1156 37 redbear
                                        char_sent <= 1'b1;
1157 36 redbear
                                        last_type  <= DATA;
1158
                                        global_counter_transfer <= 4'd0;
1159 38 redbear
 
1160
                                        if(data_ready_took)
1161
                                                tx_data_in <= tx_data_took;
1162
                                        else
1163
                                                tx_data_in <= tx_data_in;
1164 8 redbear
                                end
1165 17 redbear
                                else
1166
                                begin
1167 38 redbear
 
1168
                                        if(global_counter_transfer == 4'd1)
1169
                                        begin
1170
                                                txdata_flagctrl_tx_last <= tx_data_in;
1171
                                        end
1172
                                        else
1173
                                                txdata_flagctrl_tx_last <= txdata_flagctrl_tx_last;
1174
 
1175
 
1176
                                        if(global_counter_transfer >= 4'd2 && global_counter_transfer < 4'd5)
1177
                                        begin
1178
                                                ready_tx_data <= 1'b1;
1179
                                        end
1180
                                        else
1181
                                                ready_tx_data <= 1'b0;
1182
 
1183
                                        char_sent <= 1'b0;
1184 36 redbear
                                        ready_tx_timecode <= 1'b0;
1185
                                        global_counter_transfer <= global_counter_transfer + 4'd1;
1186 8 redbear
 
1187 38 redbear
                                 end
1188 36 redbear
 
1189 5 redbear
                        end
1190 36 redbear
                        else if(tx_data_in[8])
1191 5 redbear
                        begin
1192 8 redbear
 
1193
                                if(global_counter_transfer == 4'd3)
1194
                                begin
1195 37 redbear
                                        char_sent <= 1'b1;
1196 36 redbear
 
1197
                                        if(tx_data_in[1:0] == 2'b00)
1198
                                        begin
1199
                                                last_type  <=EOP;
1200
                                        end
1201
                                        else if(tx_data_in[1:0] == 2'b01)
1202
                                        begin
1203
                                                last_type  <=EEP;
1204
                                        end
1205
 
1206 38 redbear
                                        ready_tx_data <= 1'b0;
1207 36 redbear
                                        global_counter_transfer <= 4'd0;
1208 8 redbear
                                end
1209 17 redbear
                                else
1210
                                begin
1211 34 redbear
                                        txdata_flagctrl_tx_last <= txdata_flagctrl_tx_last;
1212 38 redbear
                                        ready_tx_data <= 1'b1;
1213 36 redbear
                                        ready_tx_timecode <= 1'b0;
1214
                                        global_counter_transfer <= global_counter_transfer + 4'd1;
1215 8 redbear
                                end
1216 5 redbear
                        end
1217 8 redbear
 
1218 5 redbear
                end
1219 37 redbear
                tx_spw_time_code_c:
1220
                begin
1221
 
1222
                        fct_sent <=  1'b0;
1223
 
1224
                        last_tx_dout <= tx_dout;
1225
                        last_tx_sout <= tx_sout;
1226
 
1227
                        tx_dout_e <= last_tx_dout;
1228
                        tx_sout_e <= last_tx_sout;
1229
 
1230
                        if(global_counter_transfer == 4'd13)
1231
                        begin
1232
                                ready_tx_timecode <= 1'b1;
1233
                                global_counter_transfer <= 4'd0;
1234
                        end
1235
                        else
1236
                        begin
1237
                                ready_tx_timecode <= 1'b0;
1238
                                global_counter_transfer <= global_counter_transfer + 4'd1;
1239
                        end
1240
 
1241
 
1242
                        if(global_counter_transfer != 4'd13)
1243
                        begin
1244
 
1245
                                timecode_s <= {timecode_ss[13:10],2'd2,tx_tcode_in[7:0]};
1246
                        end
1247
                        else
1248
                        begin
1249
                                last_timein_control_flag_tx <= tx_tcode_in;
1250
                                last_type  <= TIMEC;
1251
                        end
1252
 
1253
                end
1254
                default:
1255
                begin
1256
                        last_type               <= last_type;
1257
                        global_counter_transfer <= global_counter_transfer;
1258
                        tx_dout_e               <= tx_dout_e;
1259
                        tx_sout_e               <= tx_sout_e;
1260
                end
1261
                endcase
1262 5 redbear
        end
1263
end
1264
 
1265
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.