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

Subversion Repositories spacewiresystemc

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

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
                output reg tx_dout,
54
                output reg tx_sout,
55
                //
56 8 redbear
                output  reg ready_tx_data,
57 13 redbear
                output  reg ready_tx_timecode
58 5 redbear
 
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 25 redbear
 
74
localparam [7:0] null_s = 8'b01110100;
75
localparam [2:0] fct_s  = 3'b100;
76
localparam [3:0] eop_s  = 4'b0101;
77
localparam [3:0] eep_s  = 4'b0110;
78
localparam [13:0] timecode_ss    = 14'b01110000000000;
79
 
80
 
81
 
82 5 redbear
        reg [2:0] state_tx;
83
        reg [2:0] next_state_tx;
84
 
85 25 redbear
        //reg [7:0]  null_s;
86
        //reg [2:0]  fct_s;
87
        //reg [3:0]  eop_s;
88
        //reg [3:0]  eep_s;
89 5 redbear
        reg [13:0] timecode_s;
90
 
91
        reg [5:0]  last_type;
92
        reg [8:0]  txdata_flagctrl_tx_last;
93
        reg [7:0]  last_timein_control_flag_tx;
94
 
95
        reg first_time;
96
 
97 8 redbear
        reg hold_null;
98
        reg hold_fct;
99
        reg hold_data;
100
        reg hold_time_code;
101
 
102 5 redbear
        reg enable_null;
103
        reg enable_fct;
104
        reg enable_n_char;
105
        reg enable_time_code;
106
 
107
        reg [2:0] fct_send;
108
        reg [2:0] fct_flag;
109 6 redbear
 
110 5 redbear
        reg [5:0] fct_counter;
111 6 redbear
        reg [5:0] fct_counter_receive;
112
 
113 5 redbear
        reg last_tx_dout;
114
        reg last_tx_sout;
115
 
116 17 redbear
        reg block_sum;
117 19 redbear
        reg block_sum_fct_send;
118 17 redbear
 
119 5 redbear
        reg [3:0] global_counter_transfer;
120
 
121
 
122 13 redbear
 
123 5 redbear
always@(*)
124
begin
125
        tx_dout = 1'b0;
126
 
127
         if(!enable_tx)
128
         begin
129
                tx_dout = 1'b0;
130
         end
131
         else if( enable_null & first_time  & global_counter_transfer == 4'd0)
132
         begin
133
                tx_dout = null_s[7];
134
         end
135
         else if( enable_null & !first_time & last_type == NULL  & global_counter_transfer == 4'd0)
136
         begin
137
                tx_dout = !(null_s[6]^null_s[0]^null_s[1]);
138
         end
139
         else if( enable_null & !first_time & last_type == FCT   & global_counter_transfer == 4'd0)
140
         begin
141
                tx_dout = !(null_s[6]^fct_s[0]^fct_s[1]);
142
         end
143
         else if( enable_null & !first_time & last_type == EOP   & global_counter_transfer == 4'd0)
144
         begin
145
                tx_dout = !(null_s[6]^eop_s[0]^eop_s[1]);
146
         end
147
         else if( enable_null & !first_time & last_type == EEP   & global_counter_transfer == 4'd0)
148
         begin
149
                tx_dout = !(null_s[6]^eep_s[0]^eep_s[1]);
150
         end
151
         else if( enable_null & !first_time & last_type == DATA  & global_counter_transfer == 4'd0)
152
         begin
153
                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]);
154
         end
155
         else if( enable_null & !first_time & last_type == TIMEC & global_counter_transfer == 4'd0)
156
         begin
157
                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]);
158
         end
159
         else if( enable_null & !first_time & global_counter_transfer == 4'd1)
160
         begin
161
                tx_dout = null_s[6];
162
         end
163
         else if( enable_null & !first_time & global_counter_transfer == 4'd2)
164
         begin
165
                tx_dout = null_s[5];
166
         end
167
         else if( enable_null & !first_time & global_counter_transfer == 4'd3)
168
         begin
169
                tx_dout = null_s[4];
170
         end
171
         else if( enable_null & !first_time & global_counter_transfer == 4'd4)
172
         begin
173
                tx_dout = null_s[3];
174
         end
175
         else if( enable_null & !first_time & global_counter_transfer == 4'd5)
176
         begin
177
                tx_dout = null_s[2];
178
         end
179
         else if( enable_null & !first_time & global_counter_transfer == 4'd6)
180
         begin
181
                tx_dout = null_s[1];
182
         end
183
         else if( enable_null & !first_time & global_counter_transfer == 4'd7)
184
         begin
185
                tx_dout = null_s[0];
186
         end
187
         else if( enable_fct  & !first_time & last_type == NULL  & global_counter_transfer == 4'd0)
188
         begin
189
                tx_dout = !(fct_s[2]^null_s[0]^null_s[1]);
190
         end
191
         else if( enable_fct  & !first_time & last_type == FCT   & global_counter_transfer == 4'd0)
192
         begin
193
                tx_dout = !(fct_s[2]^fct_s[0]^fct_s[1]);
194
         end
195
         else if( enable_fct  & !first_time & last_type == EOP   & global_counter_transfer == 4'd0)
196
         begin
197
                tx_dout = !(fct_s[2]^eop_s[0]^eop_s[1]);
198
         end
199
         else if( enable_fct  & !first_time & last_type == EEP   & global_counter_transfer == 4'd0)
200
         begin
201
                tx_dout = !(fct_s[2]^eep_s[0]^eep_s[1]);
202
         end
203
         else if ( enable_fct  & !first_time & last_type == DATA  & global_counter_transfer == 4'd0)
204
         begin
205
                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]);
206
         end
207
         else if( enable_fct  & !first_time & last_type == TIMEC & global_counter_transfer == 4'd0)
208
         begin
209
                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]);
210
         end
211
         else if( enable_fct  & !first_time & global_counter_transfer == 4'd1)
212
         begin
213
                tx_dout = fct_s[2];
214
         end
215
         else if( enable_fct  & !first_time & global_counter_transfer == 4'd2)
216
         begin
217
                tx_dout = fct_s[1];
218
         end
219
         else if( enable_fct  & !first_time & global_counter_transfer == 4'd3)
220
         begin
221
                tx_dout = fct_s[0];
222
         end
223
         else if( enable_time_code & !first_time & last_type == NULL  & global_counter_transfer == 4'd0)
224
         begin
225
                tx_dout = !(timecode_s[12]^null_s[0]^null_s[1]);
226
         end
227
         else if( enable_time_code & !first_time & last_type == FCT   & global_counter_transfer == 4'd0)
228
         begin
229
                tx_dout = !(timecode_s[12]^fct_s[0]^fct_s[1]);
230
         end
231
         else if ( enable_time_code & !first_time & last_type == EOP   & global_counter_transfer == 4'd0)
232
         begin
233
                tx_dout = !(timecode_s[12]^eop_s[0]^eop_s[1]);
234
         end
235
         else if( enable_time_code & !first_time & last_type == EEP   & global_counter_transfer == 4'd0)
236
         begin
237
                tx_dout = !(timecode_s[12]^eep_s[0]^eep_s[1]);
238
         end
239
         else if( enable_time_code & !first_time & last_type == DATA  & global_counter_transfer == 4'd0)
240
         begin
241
                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]);
242
         end
243
         else if( enable_time_code & !first_time & last_type == TIMEC & global_counter_transfer == 4'd0)
244
         begin
245
                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]);
246
         end
247
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd1)
248
         begin
249
                tx_dout = timecode_s[12];
250
         end
251
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd2)
252
         begin
253
                tx_dout = timecode_s[11];
254
         end
255
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd3)
256
         begin
257
                tx_dout = timecode_s[10];
258
         end
259
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd4)
260
         begin
261
                tx_dout = timecode_s[9];
262
         end
263
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd5)
264
         begin
265
                tx_dout = timecode_s[8];
266
         end
267
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd6)
268
         begin
269 13 redbear
                tx_dout = timecode_s[0];
270 5 redbear
         end
271
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd7)
272
         begin
273 13 redbear
                tx_dout = timecode_s[1];
274 5 redbear
         end
275
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd8)
276
         begin
277 13 redbear
                tx_dout = timecode_s[2];
278 5 redbear
         end
279
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd9)
280
         begin
281 13 redbear
                tx_dout = timecode_s[3];
282 5 redbear
         end
283
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd10)
284
         begin
285 13 redbear
                tx_dout = timecode_s[4];
286 5 redbear
         end
287
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd11)
288
         begin
289 13 redbear
                tx_dout = timecode_s[5];
290 5 redbear
         end
291
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd12)
292
         begin
293 13 redbear
                tx_dout = timecode_s[6];
294 5 redbear
         end
295
         else if( enable_time_code & !first_time & global_counter_transfer == 4'd13)
296
         begin
297 13 redbear
                tx_dout = timecode_s[7];
298 5 redbear
         end
299 8 redbear
         else if( enable_n_char   & !data_tx_i[8] & !first_time & last_type == NULL  & global_counter_transfer == 4'd0)
300 5 redbear
         begin
301
                tx_dout = !(data_tx_i[8]^null_s[0]^null_s[1]);
302
         end
303 8 redbear
         else if( enable_n_char   & !data_tx_i[8] & !first_time & last_type == FCT   & global_counter_transfer == 4'd0)
304 5 redbear
         begin
305
                tx_dout = !(data_tx_i[8]^fct_s[0]^fct_s[1]);
306
         end
307 8 redbear
         else if( enable_n_char   & !data_tx_i[8] & !first_time & last_type == EOP   & global_counter_transfer == 4'd0)
308 5 redbear
         begin
309
                tx_dout = !(data_tx_i[8]^eop_s[0]^eop_s[1]);
310
         end
311 8 redbear
         else if( enable_n_char   & !data_tx_i[8] & !first_time & last_type == EEP   & global_counter_transfer == 4'd0)
312 5 redbear
         begin
313
                tx_dout = !(data_tx_i[8]^eep_s[0]^eep_s[1]);
314
         end
315 8 redbear
         else if( enable_n_char   & !data_tx_i[8] & !first_time & last_type == DATA  & global_counter_transfer == 4'd0)
316 5 redbear
         begin
317
                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]);
318
         end
319 8 redbear
         else if( enable_n_char   & !data_tx_i[8] & !first_time & last_type == TIMEC & global_counter_transfer == 4'd0)
320 5 redbear
         begin
321
                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]);
322
         end
323 8 redbear
         else if( enable_n_char   & data_tx_i[8]  & data_tx_i[1:0] == 2'b00 &  !first_time & last_type == NULL  & global_counter_transfer == 4'd0)
324 5 redbear
         begin
325 8 redbear
                tx_dout = !(eop_s[3]^null_s[0]^null_s[1]);
326
         end
327
         else if( enable_n_char   & !data_tx_i[8] & data_tx_i[1:0] == 2'b00 & !first_time & last_type == FCT   & global_counter_transfer == 4'd0)
328
         begin
329
                tx_dout = !(eop_s[3]^fct_s[0]^fct_s[1]);
330
         end
331
         else if( enable_n_char   & !data_tx_i[8] & data_tx_i[1:0] == 2'b00 & !first_time & last_type == EOP   & global_counter_transfer == 4'd0)
332
         begin
333
                tx_dout = !(eop_s[3]^eop_s[0]^eop_s[1]);
334
         end
335
         else if( enable_n_char   & !data_tx_i[8] & data_tx_i[1:0] == 2'b00 & !first_time & last_type == EEP   & global_counter_transfer == 4'd0)
336
         begin
337
                tx_dout = !(eop_s[3]^eep_s[0]^eep_s[1]);
338
         end
339
         else if( enable_n_char   & !data_tx_i[8]  & data_tx_i[1:0] == 2'b00 & !first_time & last_type == DATA  & global_counter_transfer == 4'd0)
340
         begin
341
                tx_dout = !(eop_s[3]^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]);
342
         end
343
         else if( enable_n_char   & !data_tx_i[8]  & data_tx_i[1:0] == 2'b00 & !first_time & last_type == TIMEC & global_counter_transfer == 4'd0)
344
         begin
345
                tx_dout = !(eop_s[3]^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]);
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'd1)
348
         begin
349
                tx_dout = eop_s[2];
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'd2)
352
         begin
353
                tx_dout = eop_s[1];
354
         end
355
         else if( enable_n_char    &  data_tx_i[8] & data_tx_i[1:0] == 2'b00 & !first_time & global_counter_transfer == 4'd3)
356
         begin
357
                tx_dout = eop_s[0];
358
         end
359
         else if( enable_n_char   & data_tx_i[8]  & data_tx_i[1:0] == 2'b01 &  !first_time & last_type == NULL  & global_counter_transfer == 4'd0)
360
         begin
361
                tx_dout = !(eep_s[3]^null_s[0]^null_s[1]);
362
         end
363
         else if( enable_n_char   & !data_tx_i[8] & data_tx_i[1:0] == 2'b01 & !first_time & last_type == FCT   & global_counter_transfer == 4'd0)
364
         begin
365
                tx_dout = !(eep_s[3]^fct_s[0]^fct_s[1]);
366
         end
367
         else if( enable_n_char   & !data_tx_i[8] & data_tx_i[1:0] == 2'b01 & !first_time & last_type == EOP   & global_counter_transfer == 4'd0)
368
         begin
369
                tx_dout = !(eep_s[3]^eop_s[0]^eop_s[1]);
370
         end
371
         else if( enable_n_char   & !data_tx_i[8] & data_tx_i[1:0] == 2'b01 & !first_time & last_type == EEP   & global_counter_transfer == 4'd0)
372
         begin
373
                tx_dout = !(eep_s[3]^eep_s[0]^eep_s[1]);
374
         end
375
         else if( enable_n_char   & !data_tx_i[8]  & data_tx_i[1:0] == 2'b01 & !first_time & last_type == DATA  & global_counter_transfer == 4'd0)
376
         begin
377
                tx_dout = !(eep_s[3]^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]);
378
         end
379
         else if( enable_n_char   & !data_tx_i[8]  & data_tx_i[1:0] == 2'b01 & !first_time & last_type == TIMEC & global_counter_transfer == 4'd0)
380
         begin
381
                tx_dout = !(eep_s[3]^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]);
382
         end
383
         else if( enable_n_char   & !data_tx_i[8] & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd1)
384
         begin
385 5 redbear
                tx_dout = data_tx_i[8];
386
         end
387
         else if( enable_n_char    & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd2)
388
         begin
389
                tx_dout = data_tx_i[0];
390
         end
391
         else if( enable_n_char    & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd3)
392
         begin
393
                tx_dout = data_tx_i[1];
394
         end
395
         else if( enable_n_char    & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd4)
396
         begin
397
                tx_dout = data_tx_i[2];
398
         end
399
         else if( enable_n_char    & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd5)
400
         begin
401
                tx_dout = data_tx_i[3];
402
         end
403
         else if( enable_n_char    & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd6)
404
         begin
405
                tx_dout = data_tx_i[4];
406
         end
407
         else if( enable_n_char    & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd7)
408
         begin
409
                tx_dout = data_tx_i[5];
410
         end
411
         else if( enable_n_char    & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd8)
412
         begin
413
                tx_dout = data_tx_i[6];
414
         end
415
         else if( enable_n_char    & !data_tx_i[8] & !first_time & global_counter_transfer == 4'd9)
416
         begin
417
                tx_dout = data_tx_i[7];
418
         end
419
         else if( enable_n_char    &  data_tx_i[8] & data_tx_i[1:0] == 2'b01 & !first_time & global_counter_transfer == 4'd1)
420
         begin
421
                tx_dout = eep_s[2];
422
         end
423
         else if( enable_n_char    &  data_tx_i[8] & data_tx_i[1:0] == 2'b01 & !first_time & global_counter_transfer == 4'd2)
424
         begin
425
                tx_dout = eep_s[1];
426
         end
427
         else if( enable_n_char    &  data_tx_i[8] & data_tx_i[1:0] == 2'b01 & !first_time & global_counter_transfer == 4'd3)
428
         begin
429
                tx_dout = eep_s[0];
430
         end
431
end
432
 
433
//strobe
434
always@(*)
435
begin
436
        tx_sout = 1'b0;
437
 
438
        if(!enable_tx)
439
        begin
440
                tx_sout = 1'b0;
441
        end
442 13 redbear
        else if((enable_null | enable_fct | enable_n_char | enable_time_code) && tx_dout == last_tx_dout)
443 5 redbear
        begin
444
                tx_sout = !last_tx_sout;
445
        end
446 13 redbear
        else if((enable_null | enable_fct | enable_n_char | enable_time_code) && tx_dout != last_tx_dout)
447 5 redbear
        begin
448
                tx_sout = last_tx_sout;
449 12 redbear
        end
450
 
451 5 redbear
end
452
 
453 17 redbear
always@(*)
454 5 redbear
begin
455 17 redbear
        fct_counter = 6'd0;
456
 
457
        if(gotfct_tx)
458 5 redbear
        begin
459 17 redbear
                if(block_sum)
460 15 redbear
                begin
461 17 redbear
 
462
                end
463
                else
464
                begin
465
                        if(fct_counter_receive < 6'd48)
466 15 redbear
                        begin
467 17 redbear
                                fct_counter = fct_counter_receive + 6'd8;
468 15 redbear
                        end
469
                        else
470
                        begin
471 17 redbear
                                fct_counter = fct_counter_receive + 6'd7;
472
 
473 15 redbear
                        end
474
                end
475 5 redbear
        end
476
end
477
 
478
//slots open in our side
479 19 redbear
always@(*)
480 5 redbear
begin
481
 
482 19 redbear
        fct_send = {3{1'b0}};
483
 
484
        if(send_fct_now)
485 5 redbear
        begin
486 19 redbear
                if(block_sum_fct_send)
487
                begin
488 6 redbear
 
489
                end
490
                else
491
                begin
492 19 redbear
                        if(fct_flag == 3'd7)
493
                        begin
494
                                fct_send = 3'd0;
495
                        end
496
                        else
497
                        begin
498
                                fct_send = fct_flag + 3'd1;
499
 
500
                        end
501 6 redbear
                end
502 5 redbear
        end
503
end
504
 
505
 
506
always@(*)
507
begin
508
 
509
 
510
        enable_null      = 1'b0;
511
        enable_fct       = 1'b0;
512
        enable_n_char    = 1'b0;
513
        enable_time_code = 1'b0;
514
 
515 17 redbear
        next_state_tx = state_tx;
516
 
517 5 redbear
        case(state_tx)
518
        tx_spw_start:
519
        begin
520
                if(send_null_tx && enable_tx)
521
                begin
522 12 redbear
                        //if(!hold_null)
523 5 redbear
                                next_state_tx = tx_spw_null;
524
 
525 12 redbear
                        //enable_null = 1'b1;
526 5 redbear
                end
527
                else
528
                begin
529
                        next_state_tx = tx_spw_start;
530
                end
531
        end
532
        tx_spw_null:
533
        begin
534
                enable_null = 1'b1;
535
 
536 8 redbear
                if(!hold_null)
537 5 redbear
                begin
538
                        if(send_null_tx && send_fct_tx && enable_tx)
539
                                next_state_tx = tx_spw_null_fct;
540
                        else
541
                                next_state_tx = tx_spw_null;
542
                end
543
 
544
        end
545
        tx_spw_null_fct:
546
        begin
547
 
548
                enable_null   = 1'b1;
549
 
550 8 redbear
                if(send_fct_tx && fct_flag > 0  && !hold_null)
551 5 redbear
                begin
552 8 redbear
                        next_state_tx = tx_spw_null_fct;
553 5 redbear
                        enable_null = 1'b0;
554 8 redbear
                        enable_fct  = 1'b1;
555 5 redbear
                end
556
                else
557
                begin
558
                        enable_fct = 1'b0;
559 17 redbear
                        if(send_fct_tx && fct_counter_receive > 6'd0)
560 5 redbear
                        begin
561 12 redbear
                                //if(global_counter_transfer == 4'd7)
562
                                        next_state_tx =  tx_spw_full;
563 5 redbear
                        end
564
 
565
                end
566
        end
567
        tx_spw_full:
568
        begin
569 8 redbear
                if(tickin_tx && !hold_null && !hold_fct && !hold_data)
570 5 redbear
                begin
571 6 redbear
                        enable_time_code = 1'b1;
572 5 redbear
                end
573 8 redbear
                else if(fct_flag > 3'd0 && !hold_null && !hold_time_code && !hold_data)
574 5 redbear
                begin
575 6 redbear
                        enable_fct  = 1'b1;
576 5 redbear
                end
577 17 redbear
                else if((txwrite_tx && fct_counter_receive > 6'd0 && !hold_null && !hold_time_code && !hold_fct) == 1'b1 )
578 5 redbear
                begin
579 8 redbear
                        enable_n_char = 1'b1;
580 5 redbear
                end
581 17 redbear
                else
582 8 redbear
                begin
583
                        enable_null = 1'b1;
584
                end
585 5 redbear
        end
586
        endcase
587
 
588
end
589
 
590 25 redbear
always@(posedge pclk_tx or negedge enable_tx)
591 5 redbear
begin
592
        if(!enable_tx)
593
        begin
594 25 redbear
 
595
                timecode_s    <= 14'b01110000000000;
596 19 redbear
                fct_flag      <= 3'd7;
597 6 redbear
 
598 13 redbear
                first_time        <= 1'b1;
599
                ready_tx_data     <= 1'b0;
600
                ready_tx_timecode <= 1'b0;
601 8 redbear
 
602
                hold_null       <= 1'b0;
603
                hold_fct        <= 1'b0;
604
                hold_data       <= 1'b0;
605
                hold_time_code  <= 1'b0;
606
 
607 5 redbear
                last_type  <= NULL;
608
 
609
                global_counter_transfer <= 4'd0;
610
                txdata_flagctrl_tx_last <= 9'd0;
611
                last_timein_control_flag_tx <= 8'd0;
612 6 redbear
 
613
                fct_counter_receive <= 6'd0;
614 17 redbear
 
615
                block_sum  <= 1'b0;
616 19 redbear
                block_sum_fct_send <= 1'b0;
617 6 redbear
 
618 5 redbear
                last_tx_dout      <= 1'b0;
619
                last_tx_sout      <= 1'b0;
620
                state_tx <= tx_spw_start;
621 17 redbear
 
622 5 redbear
        end
623
        else
624
        begin
625
 
626 25 redbear
                //null_s        <= null_s;
627
                //fct_s         <= fct_s;
628
                //eop_s         <= eop_s;
629
                //eep_s         <= eep_s;
630
                //timecode_s    <= timecode_s;  
631
                //fct_flag      <= fct_flag;
632
 
633 5 redbear
                state_tx <= next_state_tx;
634
                last_tx_dout <= tx_dout;
635
                last_tx_sout <= tx_sout;
636
 
637
                if(enable_null)
638
                begin
639 6 redbear
 
640 8 redbear
                        ready_tx_data <= 1'b0;
641 13 redbear
                        ready_tx_timecode <= 1'b0;
642 25 redbear
                        //hold_null     <= 1'b0;
643
                        hold_fct        <= 1'b0;
644
                        hold_data       <= 1'b0;
645
                        hold_time_code  <= 1'b0;
646
 
647 19 redbear
                        //
648 17 redbear
                        if(gotfct_tx && !block_sum)
649
                        begin
650 15 redbear
                                fct_counter_receive <= fct_counter;
651 17 redbear
                                block_sum<= 1'b1;
652
                        end
653
                        else if(!gotfct_tx)
654
                        begin
655
                                block_sum<= 1'b0;
656
                        end
657
                        else
658
                                block_sum <= block_sum;
659 6 redbear
                        //
660 19 redbear
                        if(send_fct_now && !block_sum_fct_send)
661 6 redbear
                        begin
662 19 redbear
                                fct_flag <= fct_send;
663
                                block_sum_fct_send<= 1'b1;
664 6 redbear
                        end
665 19 redbear
                        else if(!send_fct_now)
666
                        begin
667
                                block_sum_fct_send<= 1'b0;
668
                        end
669
                        else
670
                                block_sum_fct_send <= block_sum_fct_send;
671 6 redbear
 
672 5 redbear
                        if(first_time)
673
                        begin
674
                                first_time <= 1'b0;
675 23 redbear
                                hold_null  <= 1'b1;
676 5 redbear
                                global_counter_transfer <= global_counter_transfer + 4'd1;
677
                        end
678
                        else if(global_counter_transfer != 4'd7)
679
                        begin
680 8 redbear
                                hold_null <= 1'b1;
681 5 redbear
                                global_counter_transfer <= global_counter_transfer + 4'd1;
682
                        end
683
                        else
684
                        begin
685 8 redbear
                                hold_null <= 1'b0;
686 25 redbear
                                last_type  <= NULL;
687 5 redbear
                                global_counter_transfer <= 4'd0;
688
                        end
689
                end
690
                else if(enable_fct)
691
                begin
692 8 redbear
 
693
                        ready_tx_data <= 1'b0;
694 13 redbear
                        ready_tx_timecode <= 1'b0;
695 8 redbear
 
696 25 redbear
                        hold_null       <= 1'b0;
697
                        //hold_fct      <= 1'b0;
698
                        hold_data       <= 1'b0;
699
                        hold_time_code  <= 1'b0;
700
 
701
 
702 17 redbear
                        if(gotfct_tx && !block_sum)
703
                        begin
704 15 redbear
                                fct_counter_receive <= fct_counter;
705 17 redbear
                                block_sum<= 1'b1;
706
                        end
707
                        else if(!gotfct_tx)
708
                        begin
709
                                block_sum<= 1'b0;
710
                        end
711
                        else
712
                                block_sum <= block_sum;
713 6 redbear
 
714
 
715 5 redbear
                        if(global_counter_transfer != 4'd3)
716
                        begin
717 8 redbear
                                hold_fct <= 1'b1;
718 5 redbear
                                global_counter_transfer <= global_counter_transfer + 4'd1;
719 19 redbear
                                //
720
                                if(send_fct_now && !block_sum_fct_send)
721
                                begin
722
                                        fct_flag <= fct_send;
723
                                        block_sum_fct_send<= 1'b1;
724
                                end
725
                                else if(!send_fct_now)
726
                                begin
727
                                        block_sum_fct_send<= 1'b0;
728
                                end
729
                                else
730
                                        block_sum_fct_send <= block_sum_fct_send;
731 5 redbear
                        end
732
                        else
733
                        begin
734 8 redbear
                                hold_fct <= 1'b0;
735 5 redbear
                                global_counter_transfer <= 4'd0;
736 6 redbear
                                fct_flag <= fct_flag - 3'd1;
737 25 redbear
                                last_type  <=FCT;
738 5 redbear
                        end
739
                end
740
                else if(enable_time_code)
741
                begin
742 25 redbear
                        hold_null       <= 1'b0;
743
                        hold_fct        <= 1'b0;
744
                        hold_data       <= 1'b0;
745
                        //hold_time_code        <= 1'b0;
746
 
747 8 redbear
                        ready_tx_data <= 1'b0;
748
 
749 17 redbear
                        if(gotfct_tx && !block_sum)
750
                        begin
751 15 redbear
                                fct_counter_receive <= fct_counter;
752 17 redbear
                                block_sum<= 1'b1;
753
                        end
754
                        else if(!gotfct_tx)
755
                        begin
756
                                block_sum<= 1'b0;
757
                        end
758
                        else
759
                                block_sum <= block_sum;
760 15 redbear
 
761 13 redbear
                        if(global_counter_transfer == 4'd13)
762
                        begin
763
                                ready_tx_timecode <= 1'b1;
764
                        end
765 19 redbear
 
766 6 redbear
                        //
767 19 redbear
                        if(send_fct_now && !block_sum_fct_send)
768 6 redbear
                        begin
769 19 redbear
                                fct_flag <= fct_send;
770
                                block_sum_fct_send<= 1'b1;
771 6 redbear
                        end
772 19 redbear
                        else if(!send_fct_now)
773
                        begin
774
                                block_sum_fct_send<= 1'b0;
775
                        end
776
                        else
777
                                block_sum_fct_send <= block_sum_fct_send;
778 6 redbear
 
779 5 redbear
                        if(global_counter_transfer < 4'd13)
780
                        begin
781
                                global_counter_transfer <= global_counter_transfer + 4'd1;
782 25 redbear
                                timecode_s <= {timecode_ss[13:10],2'd2,timecode_tx_i[7:0]};
783 5 redbear
                        end
784
                        else
785
                        begin
786 13 redbear
                                last_timein_control_flag_tx <= timecode_tx_i;
787 5 redbear
                                global_counter_transfer <= 4'd0;
788 25 redbear
                                last_type  <= TIMEC;
789 5 redbear
                        end
790
                end
791
                else if(enable_n_char)
792
                begin
793 8 redbear
 
794 13 redbear
                        ready_tx_timecode <= 1'b0;
795 25 redbear
                        hold_null       <= 1'b0;
796
                        hold_fct        <= 1'b0;
797
                        //hold_data     <= 1'b0;
798
                        hold_time_code  <= 1'b0;
799
 
800 6 redbear
                        //
801 19 redbear
                        if(send_fct_now && !block_sum_fct_send)
802 6 redbear
                        begin
803 19 redbear
                                fct_flag <= fct_send;
804
                                block_sum_fct_send<= 1'b1;
805 6 redbear
                        end
806 19 redbear
                        else if(!send_fct_now)
807
                        begin
808
                                block_sum_fct_send<= 1'b0;
809
                        end
810
                        else
811
                                block_sum_fct_send <= block_sum_fct_send;
812 6 redbear
 
813 8 redbear
                        if(!data_tx_i[8])
814 5 redbear
                        begin
815 8 redbear
 
816
                                if(global_counter_transfer == 4'd9)
817
                                begin
818
                                        ready_tx_data <= 1'b1;
819
                                end
820 17 redbear
                                else
821
                                begin
822
                                        ready_tx_data <= 1'b0;
823
                                end
824 8 redbear
 
825
                                if(global_counter_transfer != 4'd9)
826
                                begin
827
                                        hold_data <= 1'b1;
828
                                        global_counter_transfer <= global_counter_transfer + 4'd1;
829
                                        txdata_flagctrl_tx_last <= data_tx_i;
830 17 redbear
 
831
                                        if(gotfct_tx && !block_sum)
832
                                        begin
833
                                                fct_counter_receive <= fct_counter;
834
                                                block_sum<= 1'b1;
835
                                        end
836
                                        else if(!gotfct_tx)
837
                                        begin
838
                                                block_sum<= 1'b0;
839
                                        end
840
                                        else
841
                                                block_sum <= block_sum;
842 8 redbear
                                end
843
                                else
844
                                begin
845
                                        hold_data <= 1'b0;
846
                                        global_counter_transfer <= 4'd0;
847 15 redbear
                                        fct_counter_receive <= fct_counter_receive - 6'd1;
848 25 redbear
                                        last_type  <= DATA;
849 8 redbear
                                end
850
 
851 5 redbear
                        end
852 8 redbear
                        else if(data_tx_i[8])
853 5 redbear
                        begin
854 8 redbear
 
855
                                if(global_counter_transfer == 4'd3)
856
                                begin
857
                                        ready_tx_data <= 1'b1;
858
                                end
859 17 redbear
                                else
860
                                begin
861
                                        ready_tx_data <= 1'b0;
862
                                end
863 8 redbear
 
864
                                if(global_counter_transfer != 4'd3)
865
                                begin
866
                                        hold_data <= 1'b1;
867
                                        global_counter_transfer <= global_counter_transfer + 4'd1;
868
                                        txdata_flagctrl_tx_last <= data_tx_i;
869 17 redbear
 
870
                                        if(gotfct_tx && !block_sum)
871
                                        begin
872
                                                fct_counter_receive <= fct_counter;
873
                                                block_sum<= 1'b1;
874
                                        end
875
                                        else if(!gotfct_tx)
876
                                        begin
877
                                                block_sum<= 1'b0;
878
                                        end
879
                                        else
880
                                                block_sum <= block_sum;
881 8 redbear
                                end
882
                                else
883
                                begin
884 15 redbear
 
885 8 redbear
                                        hold_data <= 1'b0;
886
                                        global_counter_transfer <= 4'd0;
887 15 redbear
                                        fct_counter_receive <= fct_counter_receive - 6'd1;
888 25 redbear
                                        last_type  <=EOP;
889 8 redbear
                                end
890 5 redbear
                        end
891 8 redbear
 
892 5 redbear
                end
893
 
894
        end
895
end
896
 
897
endmodule

powered by: WebSVN 2.1.0

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