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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [serialInterfaceEngine/] [SIETransmitter.v] - Blame information for rev 5

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

Line No. Rev Author Line
1 5 sfielding
 
2
//////////////////////////////////////////////////////////////////////
3
////                                                              ////
4
//// SIETransmitter
5
////                                                              ////
6
//// This file is part of the usbhostslave opencores effort.
7
//// http://www.opencores.org/cores/usbhostslave/                 ////
8
////                                                              ////
9
//// Module Description:                                          ////
10
//// 
11
////                                                              ////
12
//// To Do:                                                       ////
13
//// 
14
////                                                              ////
15
//// Author(s):                                                   ////
16
//// - Steve Fielding, sfielding@base2designs.com                 ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG          ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE. See the GNU Lesser General Public License for more  ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
//
45
// $Id: SIETransmitter.v,v 1.2 2004-12-18 14:36:14 sfielding Exp $
46
//
47
// CVS Revision History
48
//
49
// $Log: not supported by cvs2svn $
50
//
51
`timescale 1ns / 1ps
52
`include "usbSerialInterfaceEngine_h.v"
53
`include "usbConstants_h.v"
54
 
55
 
56
module SIETransmitter (clk, CRC16En, CRC16Result, CRC16UpdateRdy, CRC5_8Bit, CRC5En, CRC5Result, CRC5UpdateRdy, CRCData, JBit, KBit, processTxByteRdy, processTxByteWEn, rst, rstCRC, SIEPortCtrlIn, SIEPortDataIn, SIEPortTxRdy, SIEPortWEn, TxByteOut, TxByteOutCtrl, USBWireCtrl, USBWireData, USBWireGnt, USBWireRdy, USBWireReq, USBWireWEn);
57
input   clk;
58
input   [15:0]CRC16Result;
59
input   CRC16UpdateRdy;
60
input   [4:0]CRC5Result;
61
input   CRC5UpdateRdy;
62
input   [1:0]JBit;
63
input   [1:0]KBit;
64
input   processTxByteRdy;
65
input   rst;
66
input   [7:0]SIEPortCtrlIn;
67
input   [7:0]SIEPortDataIn;
68
input   SIEPortWEn;
69
input   USBWireGnt;
70
input   USBWireRdy;
71
output  CRC16En;
72
output  CRC5_8Bit;
73
output  CRC5En;
74
output  [7:0]CRCData;
75
output  processTxByteWEn;
76
output  rstCRC;
77
output  SIEPortTxRdy;
78
output  [7:0]TxByteOut;
79
output  [7:0]TxByteOutCtrl;
80
output  USBWireCtrl;
81
output  [1:0]USBWireData;
82
output  USBWireReq;
83
output  USBWireWEn;
84
 
85
wire    clk;
86
reg     CRC16En, next_CRC16En;
87
wire    [15:0]CRC16Result;
88
wire    CRC16UpdateRdy;
89
reg     CRC5_8Bit, next_CRC5_8Bit;
90
reg     CRC5En, next_CRC5En;
91
wire    [4:0]CRC5Result;
92
wire    CRC5UpdateRdy;
93
reg     [7:0]CRCData, next_CRCData;
94
wire    [1:0]JBit;
95
wire    [1:0]KBit;
96
wire    processTxByteRdy;
97
reg     processTxByteWEn, next_processTxByteWEn;
98
wire    rst;
99
reg     rstCRC, next_rstCRC;
100
wire    [7:0]SIEPortCtrlIn;
101
wire    [7:0]SIEPortDataIn;
102
reg     SIEPortTxRdy, next_SIEPortTxRdy;
103
wire    SIEPortWEn;
104
reg     [7:0]TxByteOut, next_TxByteOut;
105
reg     [7:0]TxByteOutCtrl, next_TxByteOutCtrl;
106
reg     USBWireCtrl, next_USBWireCtrl;
107
reg     [1:0]USBWireData, next_USBWireData;
108
wire    USBWireGnt;
109
wire    USBWireRdy;
110
reg     USBWireReq, next_USBWireReq;
111
reg     USBWireWEn, next_USBWireWEn;
112
 
113
// diagram signals declarations
114
reg  [4:0]i, next_i;
115
reg  [7:0]SIEPortCtrl, next_SIEPortCtrl;
116
reg  [7:0]SIEPortData, next_SIEPortData;
117
 
118
// BINARY ENCODED state machine: SIETx
119
// State codes definitions:
120
`define DIR_CTL_CHK_FIN 6'b000000
121
`define IDLE_CHK_FIN 6'b000001
122
`define RES_ST_CHK_FIN 6'b000010
123
`define PKT_ST_CHK_PID 6'b000011
124
`define PKT_ST_DATA_DATA_CHK_STOP 6'b000100
125
`define PKT_ST_HS_PKT_SENT 6'b000101
126
`define PKT_ST_TKN_CRC_PKT_SENT 6'b000110
127
`define PKT_ST_DATA_DATA_PKT_SENT 6'b000111
128
`define PKT_ST_DATA_PID_PKT_SENT 6'b001000
129
`define PKT_ST_SPCL_PKT_SENT 6'b001001
130
`define PKT_ST_TKN_PID_PKT_SENT 6'b001010
131
`define PKT_ST_DATA_CRC_PKT_SENT1 6'b001011
132
`define PKT_ST_TKN_BYTE1_PKT_SENT1 6'b001100
133
`define PKT_ST_DATA_CRC_PKT_SENT2 6'b001101
134
`define RES_ST_S1 6'b001110
135
`define RES_ST_S3 6'b001111
136
`define RES_ST_S4 6'b010000
137
`define RES_ST_S5 6'b010001
138
`define RES_ST_S6 6'b010010
139
`define PKT_ST_SPCL_SEND_IDLE1 6'b010011
140
`define PKT_ST_SPCL_SEND_IDLE2 6'b010100
141
`define PKT_ST_SPCL_SEND_IDLE3 6'b010101
142
`define START_SIETX 6'b010110
143
`define STX_CHK_ST 6'b010111
144
`define STX_WAIT_BYTE 6'b011000
145
`define IDLE_STX_WAIT_GNT 6'b011001
146
`define IDLE_STX_WAIT_RDY 6'b011010
147
`define PKT_ST_TKN_CRC_UPD_CRC 6'b011011
148
`define PKT_ST_TKN_BYTE1_UPD_CRC 6'b011100
149
`define PKT_ST_DATA_DATA_UPD_CRC 6'b011101
150
`define PKT_ST_TKN_CRC_WAIT_BYTE 6'b011110
151
`define PKT_ST_TKN_BYTE1_WAIT_BYTE 6'b011111
152
`define PKT_ST_DATA_DATA_WAIT_BYTE 6'b100000
153
`define RES_ST_WAIT_GNT 6'b100001
154
`define DIR_CTL_WAIT_GNT 6'b100010
155
`define PKT_ST_TKN_BYTE1_WAIT_RDY 6'b100011
156
`define PKT_ST_DATA_DATA_WAIT_RDY 6'b100100
157
`define PKT_ST_TKN_CRC_WAIT_RDY 6'b100101
158
`define PKT_ST_HS_WAIT_RDY 6'b100110
159
`define RES_ST_WAIT_RDY 6'b100111
160
`define PKT_ST_TKN_PID_WAIT_RDY 6'b101000
161
`define PKT_ST_DATA_PID_WAIT_RDY 6'b101001
162
`define PKT_ST_SPCL_WAIT_RDY 6'b101010
163
`define DIR_CTL_WAIT_RDY 6'b101011
164
`define PKT_ST_DATA_CRC_WAIT_RDY1 6'b101100
165
`define PKT_ST_DATA_CRC_WAIT_RDY2 6'b101101
166
`define PKT_ST_WAIT_RDY_PKT 6'b101110
167
`define PKT_ST_SPCL_WAIT_WIRE 6'b101111
168
`define PKT_ST_WAIT_RDY_WIRE 6'b110000
169
`define PKT_ST_WAIT_GNT 6'b110001
170
`define PKT_ST_TKN_CRC_WAIT_CRC_RDY 6'b110010
171
`define PKT_ST_DATA_DATA_WAIT_CRC_RDY 6'b110011
172
`define PKT_ST_TKN_BYTE1_WAIT_CRC_RDY 6'b110100
173
 
174
reg [5:0]CurrState_SIETx, NextState_SIETx;
175
 
176
 
177
// Machine: SIETx
178
 
179
// NextState logic (combinatorial)
180
always @ (i or SIEPortData or SIEPortCtrl or USBWireRdy or JBit or SIEPortWEn or SIEPortDataIn or SIEPortCtrlIn or USBWireGnt or processTxByteRdy or CRC5Result or KBit or CRC16Result or CRC5UpdateRdy or CRC16UpdateRdy or USBWireWEn or USBWireReq or processTxByteWEn or rstCRC or USBWireData or USBWireCtrl or TxByteOut or TxByteOutCtrl or CRCData or CRC5En or CRC5_8Bit or CRC16En or SIEPortTxRdy or CurrState_SIETx)
181
begin
182
  NextState_SIETx <= CurrState_SIETx;
183
  // Set default values for outputs and signals
184
  next_USBWireWEn <= USBWireWEn;
185
  next_i <= i;
186
  next_USBWireReq <= USBWireReq;
187
  next_processTxByteWEn <= processTxByteWEn;
188
  next_rstCRC <= rstCRC;
189
  next_USBWireData <= USBWireData;
190
  next_USBWireCtrl <= USBWireCtrl;
191
  next_TxByteOut <= TxByteOut;
192
  next_TxByteOutCtrl <= TxByteOutCtrl;
193
  next_CRCData <= CRCData;
194
  next_CRC5En <= CRC5En;
195
  next_CRC5_8Bit <= CRC5_8Bit;
196
  next_CRC16En <= CRC16En;
197
  next_SIEPortTxRdy <= SIEPortTxRdy;
198
  next_SIEPortData <= SIEPortData;
199
  next_SIEPortCtrl <= SIEPortCtrl;
200
  case (CurrState_SIETx)  // synopsys parallel_case full_case
201
    `START_SIETX:
202
    begin
203
      next_processTxByteWEn <= 1'b0;
204
      next_TxByteOut <= 8'h00;
205
      next_TxByteOutCtrl <= 8'h00;
206
      next_USBWireData <= 2'b00;
207
      next_USBWireCtrl <= `TRI_STATE;
208
      next_USBWireReq <= 1'b0;
209
      next_USBWireWEn <= 1'b0;
210
      next_rstCRC <= 1'b0;
211
      next_CRCData <= 8'h00;
212
      next_CRC5En <= 1'b0;
213
      next_CRC5_8Bit <= 1'b0;
214
      next_CRC16En <= 1'b0;
215
      next_SIEPortTxRdy <= 1'b0;
216
      next_SIEPortData <= 8'h00;
217
      next_SIEPortCtrl <= 8'h00;
218
      next_i <= 5'h0;
219
      NextState_SIETx <= `STX_WAIT_BYTE;
220
    end
221
    `STX_CHK_ST:
222
    begin
223
      if (SIEPortCtrl == `TX_PACKET_START)
224
      begin
225
        NextState_SIETx <= `PKT_ST_WAIT_GNT;
226
        next_USBWireReq <= 1'b1;
227
      end
228
      else if (SIEPortCtrl == `TX_DIRECT_CONTROL)
229
      begin
230
        NextState_SIETx <= `DIR_CTL_WAIT_GNT;
231
        next_USBWireReq <= 1'b1;
232
      end
233
      else if (SIEPortCtrl == `TX_IDLE)
234
      begin
235
        NextState_SIETx <= `IDLE_STX_WAIT_GNT;
236
        next_USBWireReq <= 1'b1;
237
      end
238
      else if (SIEPortCtrl == `TX_RESUME_START)
239
      begin
240
        NextState_SIETx <= `RES_ST_WAIT_GNT;
241
        next_USBWireReq <= 1'b1;
242
        next_i <= 5'h0;
243
      end
244
    end
245
    `STX_WAIT_BYTE:
246
    begin
247
      next_SIEPortTxRdy <= 1'b1;
248
      if (SIEPortWEn == 1'b1)
249
      begin
250
        NextState_SIETx <= `STX_CHK_ST;
251
        next_SIEPortData <= SIEPortDataIn;
252
        next_SIEPortCtrl <= SIEPortCtrlIn;
253
        next_SIEPortTxRdy <= 1'b0;
254
      end
255
    end
256
    `DIR_CTL_CHK_FIN:
257
    begin
258
      next_USBWireWEn <= 1'b0;
259
      next_i <= i + 1'b1;
260
      if (i == 5'h7)
261
      begin
262
        NextState_SIETx <= `STX_WAIT_BYTE;
263
        next_USBWireReq <= 1'b0;
264
      end
265
      else
266
      begin
267
        NextState_SIETx <= `DIR_CTL_WAIT_RDY;
268
      end
269
    end
270
    `DIR_CTL_WAIT_GNT:
271
    begin
272
      next_i <= 5'h0;
273
      if (USBWireGnt == 1'b1)
274
      begin
275
        NextState_SIETx <= `DIR_CTL_WAIT_RDY;
276
      end
277
    end
278
    `DIR_CTL_WAIT_RDY:
279
    begin
280
      if (USBWireRdy == 1'b1)
281
      begin
282
        NextState_SIETx <= `DIR_CTL_CHK_FIN;
283
        next_USBWireData <= SIEPortData[1:0];
284
        next_USBWireCtrl <= `DRIVE;
285
        next_USBWireWEn <= 1'b1;
286
      end
287
    end
288
    `IDLE_CHK_FIN:
289
    begin
290
      next_USBWireWEn <= 1'b0;
291
      next_i <= i + 1'b1;
292
      if (i == 5'h7)
293
      begin
294
        NextState_SIETx <= `STX_WAIT_BYTE;
295
        next_USBWireReq <= 1'b0;
296
      end
297
      else
298
      begin
299
        NextState_SIETx <= `IDLE_STX_WAIT_RDY;
300
      end
301
    end
302
    `IDLE_STX_WAIT_GNT:
303
    begin
304
      next_i <= 5'h0;
305
      if (USBWireGnt == 1'b1)
306
      begin
307
        NextState_SIETx <= `IDLE_STX_WAIT_RDY;
308
      end
309
    end
310
    `IDLE_STX_WAIT_RDY:
311
    begin
312
      if (USBWireRdy == 1'b1)
313
      begin
314
        NextState_SIETx <= `IDLE_CHK_FIN;
315
        next_USBWireData <= 2'b00;
316
        next_USBWireCtrl <= `TRI_STATE;
317
        next_USBWireWEn <= 1'b1;
318
      end
319
    end
320
    `PKT_ST_CHK_PID:
321
    begin
322
      next_processTxByteWEn <= 1'b0;
323
      if (SIEPortData[1:0] == `TOKEN)
324
      begin
325
        NextState_SIETx <= `PKT_ST_TKN_PID_WAIT_RDY;
326
      end
327
      else if (SIEPortData[1:0] == `HANDSHAKE)
328
      begin
329
        NextState_SIETx <= `PKT_ST_HS_WAIT_RDY;
330
      end
331
      else if (SIEPortData[1:0] == `DATA)
332
      begin
333
        NextState_SIETx <= `PKT_ST_DATA_PID_WAIT_RDY;
334
      end
335
      else if (SIEPortData[1:0] == `SPECIAL)
336
      begin
337
        NextState_SIETx <= `PKT_ST_SPCL_WAIT_RDY;
338
      end
339
    end
340
    `PKT_ST_WAIT_RDY_PKT:
341
    begin
342
      next_USBWireWEn <= 1'b0;
343
      next_USBWireReq <= 1'b0;
344
      if (processTxByteRdy == 1'b1)
345
      begin
346
        NextState_SIETx <= `PKT_ST_CHK_PID;
347
        next_processTxByteWEn <= 1'b1;
348
        next_TxByteOut <= `SYNC_BYTE;
349
        next_TxByteOutCtrl <= `DATA_START;
350
      end
351
    end
352
    `PKT_ST_WAIT_RDY_WIRE:
353
    begin
354
      if (USBWireRdy == 1'b1)
355
      begin
356
        NextState_SIETx <= `PKT_ST_WAIT_RDY_PKT;
357
        //actively drive the first J bit
358
        next_USBWireData <= JBit;
359
        next_USBWireCtrl <= `DRIVE;
360
        next_USBWireWEn <= 1'b1;
361
      end
362
    end
363
    `PKT_ST_WAIT_GNT:
364
    begin
365
      if (USBWireGnt == 1'b1)
366
      begin
367
        NextState_SIETx <= `PKT_ST_WAIT_RDY_WIRE;
368
      end
369
    end
370
    `PKT_ST_DATA_CRC_PKT_SENT1:
371
    begin
372
      next_processTxByteWEn <= 1'b0;
373
      NextState_SIETx <= `PKT_ST_DATA_CRC_WAIT_RDY2;
374
    end
375
    `PKT_ST_DATA_CRC_PKT_SENT2:
376
    begin
377
      next_processTxByteWEn <= 1'b0;
378
      NextState_SIETx <= `STX_WAIT_BYTE;
379
    end
380
    `PKT_ST_DATA_CRC_WAIT_RDY1:
381
    begin
382
      if (processTxByteRdy == 1'b1)
383
      begin
384
        NextState_SIETx <= `PKT_ST_DATA_CRC_PKT_SENT1;
385
        next_processTxByteWEn <= 1'b1;
386
        next_TxByteOut <= ~CRC16Result[7:0];
387
        next_TxByteOutCtrl <= `DATA_STREAM;
388
      end
389
    end
390
    `PKT_ST_DATA_CRC_WAIT_RDY2:
391
    begin
392
      if (processTxByteRdy == 1'b1)
393
      begin
394
        NextState_SIETx <= `PKT_ST_DATA_CRC_PKT_SENT2;
395
        next_processTxByteWEn <= 1'b1;
396
        next_TxByteOut <= ~CRC16Result[15:8];
397
        next_TxByteOutCtrl <= `DATA_STOP;
398
      end
399
    end
400
    `PKT_ST_DATA_DATA_CHK_STOP:
401
    begin
402
      if (SIEPortCtrl == `TX_PACKET_STOP)
403
      begin
404
        NextState_SIETx <= `PKT_ST_DATA_CRC_WAIT_RDY1;
405
      end
406
      else
407
      begin
408
        NextState_SIETx <= `PKT_ST_DATA_DATA_WAIT_CRC_RDY;
409
      end
410
    end
411
    `PKT_ST_DATA_DATA_PKT_SENT:
412
    begin
413
      next_processTxByteWEn <= 1'b0;
414
      NextState_SIETx <= `PKT_ST_DATA_DATA_WAIT_BYTE;
415
    end
416
    `PKT_ST_DATA_DATA_UPD_CRC:
417
    begin
418
      next_CRCData <= SIEPortData;
419
      next_CRC16En <= 1'b1;
420
      NextState_SIETx <= `PKT_ST_DATA_DATA_WAIT_RDY;
421
    end
422
    `PKT_ST_DATA_DATA_WAIT_BYTE:
423
    begin
424
      next_SIEPortTxRdy <= 1'b1;
425
      if (SIEPortWEn == 1'b1)
426
      begin
427
        NextState_SIETx <= `PKT_ST_DATA_DATA_CHK_STOP;
428
        next_SIEPortData <= SIEPortDataIn;
429
        next_SIEPortCtrl <= SIEPortCtrlIn;
430
        next_SIEPortTxRdy <= 1'b0;
431
      end
432
    end
433
    `PKT_ST_DATA_DATA_WAIT_RDY:
434
    begin
435
      next_CRC16En <= 1'b0;
436
      if (processTxByteRdy == 1'b1)
437
      begin
438
        NextState_SIETx <= `PKT_ST_DATA_DATA_PKT_SENT;
439
        next_processTxByteWEn <= 1'b1;
440
        next_TxByteOut <= SIEPortData;
441
        next_TxByteOutCtrl <= `DATA_STREAM;
442
      end
443
    end
444
    `PKT_ST_DATA_DATA_WAIT_CRC_RDY:
445
    begin
446
      if (CRC16UpdateRdy == 1'b1)
447
      begin
448
        NextState_SIETx <= `PKT_ST_DATA_DATA_UPD_CRC;
449
      end
450
    end
451
    `PKT_ST_DATA_PID_PKT_SENT:
452
    begin
453
      next_processTxByteWEn <= 1'b0;
454
      next_rstCRC <= 1'b0;
455
      NextState_SIETx <= `PKT_ST_DATA_DATA_WAIT_BYTE;
456
    end
457
    `PKT_ST_DATA_PID_WAIT_RDY:
458
    begin
459
      if (processTxByteRdy == 1'b1)
460
      begin
461
        NextState_SIETx <= `PKT_ST_DATA_PID_PKT_SENT;
462
        next_processTxByteWEn <= 1'b1;
463
        next_TxByteOut <= SIEPortData;
464
        next_TxByteOutCtrl <= `DATA_STREAM;
465
        next_rstCRC <= 1'b1;
466
      end
467
    end
468
    `PKT_ST_HS_PKT_SENT:
469
    begin
470
      next_processTxByteWEn <= 1'b0;
471
      NextState_SIETx <= `STX_WAIT_BYTE;
472
    end
473
    `PKT_ST_HS_WAIT_RDY:
474
    begin
475
      if (processTxByteRdy == 1'b1)
476
      begin
477
        NextState_SIETx <= `PKT_ST_HS_PKT_SENT;
478
        next_processTxByteWEn <= 1'b1;
479
        next_TxByteOut <= SIEPortData;
480
        next_TxByteOutCtrl <= `DATA_STOP;
481
      end
482
    end
483
    `PKT_ST_SPCL_PKT_SENT:
484
    begin
485
      next_processTxByteWEn <= 1'b0;
486
      NextState_SIETx <= `PKT_ST_SPCL_WAIT_WIRE;
487
    end
488
    `PKT_ST_SPCL_SEND_IDLE1:
489
    begin
490
      next_USBWireWEn <= 1'b0;
491
      if (USBWireRdy == 1'b1)
492
      begin
493
        NextState_SIETx <= `PKT_ST_SPCL_SEND_IDLE2;
494
        next_USBWireData <= JBit;
495
        next_USBWireCtrl <= `TRI_STATE;
496
        next_USBWireWEn <= 1'b1;
497
      end
498
    end
499
    `PKT_ST_SPCL_SEND_IDLE2:
500
    begin
501
      next_USBWireWEn <= 1'b0;
502
      if (USBWireRdy == 1'b1)
503
      begin
504
        NextState_SIETx <= `PKT_ST_SPCL_SEND_IDLE3;
505
        next_USBWireData <= JBit;
506
        next_USBWireCtrl <= `TRI_STATE;
507
        next_USBWireWEn <= 1'b1;
508
      end
509
    end
510
    `PKT_ST_SPCL_SEND_IDLE3:
511
    begin
512
      next_USBWireWEn <= 1'b0;
513
      NextState_SIETx <= `STX_WAIT_BYTE;
514
    end
515
    `PKT_ST_SPCL_WAIT_RDY:
516
    begin
517
      if (processTxByteRdy == 1'b1)
518
      begin
519
        NextState_SIETx <= `PKT_ST_SPCL_PKT_SENT;
520
        next_processTxByteWEn <= 1'b1;
521
        next_TxByteOut <= SIEPortData;
522
        next_TxByteOutCtrl <= `DATA_STOP;
523
      end
524
    end
525
    `PKT_ST_SPCL_WAIT_WIRE:
526
    begin
527
      if (USBWireRdy == 1'b1)
528
      begin
529
        NextState_SIETx <= `PKT_ST_SPCL_SEND_IDLE1;
530
        next_USBWireData <= JBit;
531
        next_USBWireCtrl <= `TRI_STATE;
532
        next_USBWireWEn <= 1'b1;
533
      end
534
    end
535
    `PKT_ST_TKN_BYTE1_PKT_SENT1:
536
    begin
537
      next_processTxByteWEn <= 1'b0;
538
      NextState_SIETx <= `PKT_ST_TKN_CRC_WAIT_BYTE;
539
    end
540
    `PKT_ST_TKN_BYTE1_UPD_CRC:
541
    begin
542
      next_CRCData <= SIEPortData;
543
      next_CRC5_8Bit <= 1'b1;
544
      next_CRC5En <= 1'b1;
545
      NextState_SIETx <= `PKT_ST_TKN_BYTE1_WAIT_RDY;
546
    end
547
    `PKT_ST_TKN_BYTE1_WAIT_BYTE:
548
    begin
549
      next_SIEPortTxRdy <= 1'b1;
550
      if (SIEPortWEn == 1'b1)
551
      begin
552
        NextState_SIETx <= `PKT_ST_TKN_BYTE1_WAIT_CRC_RDY;
553
        next_SIEPortData <= SIEPortDataIn;
554
        next_SIEPortCtrl <= SIEPortCtrlIn;
555
        next_SIEPortTxRdy <= 1'b0;
556
      end
557
    end
558
    `PKT_ST_TKN_BYTE1_WAIT_RDY:
559
    begin
560
      next_CRC5En <= 1'b0;
561
      if (processTxByteRdy == 1'b1)
562
      begin
563
        NextState_SIETx <= `PKT_ST_TKN_BYTE1_PKT_SENT1;
564
        next_processTxByteWEn <= 1'b1;
565
        next_TxByteOut <= SIEPortData;
566
        next_TxByteOutCtrl <= `DATA_STREAM;
567
      end
568
    end
569
    `PKT_ST_TKN_BYTE1_WAIT_CRC_RDY:
570
    begin
571
      if (CRC5UpdateRdy == 1'b1)
572
      begin
573
        NextState_SIETx <= `PKT_ST_TKN_BYTE1_UPD_CRC;
574
      end
575
    end
576
    `PKT_ST_TKN_CRC_PKT_SENT:
577
    begin
578
      next_processTxByteWEn <= 1'b0;
579
      NextState_SIETx <= `STX_WAIT_BYTE;
580
    end
581
    `PKT_ST_TKN_CRC_UPD_CRC:
582
    begin
583
      next_CRCData <= SIEPortData;
584
      next_CRC5_8Bit <= 1'b0;
585
      next_CRC5En <= 1'b1;
586
      NextState_SIETx <= `PKT_ST_TKN_CRC_WAIT_RDY;
587
    end
588
    `PKT_ST_TKN_CRC_WAIT_BYTE:
589
    begin
590
      next_SIEPortTxRdy <= 1'b1;
591
      if (SIEPortWEn == 1'b1)
592
      begin
593
        NextState_SIETx <= `PKT_ST_TKN_CRC_WAIT_CRC_RDY;
594
        next_SIEPortData <= SIEPortDataIn;
595
        next_SIEPortCtrl <= SIEPortCtrlIn;
596
        next_SIEPortTxRdy <= 1'b0;
597
      end
598
    end
599
    `PKT_ST_TKN_CRC_WAIT_RDY:
600
    begin
601
      next_CRC5En <= 1'b0;
602
      if (processTxByteRdy == 1'b1)
603
      begin
604
        NextState_SIETx <= `PKT_ST_TKN_CRC_PKT_SENT;
605
        next_processTxByteWEn <= 1'b1;
606
        next_TxByteOut <= {~CRC5Result, SIEPortData[2:0] };
607
        next_TxByteOutCtrl <= `DATA_STOP;
608
      end
609
    end
610
    `PKT_ST_TKN_CRC_WAIT_CRC_RDY:
611
    begin
612
      if (CRC5UpdateRdy == 1'b1)
613
      begin
614
        NextState_SIETx <= `PKT_ST_TKN_CRC_UPD_CRC;
615
      end
616
    end
617
    `PKT_ST_TKN_PID_PKT_SENT:
618
    begin
619
      next_processTxByteWEn <= 1'b0;
620
      next_rstCRC <= 1'b0;
621
      NextState_SIETx <= `PKT_ST_TKN_BYTE1_WAIT_BYTE;
622
    end
623
    `PKT_ST_TKN_PID_WAIT_RDY:
624
    begin
625
      if (processTxByteRdy == 1'b1)
626
      begin
627
        NextState_SIETx <= `PKT_ST_TKN_PID_PKT_SENT;
628
        next_processTxByteWEn <= 1'b1;
629
        next_TxByteOut <= SIEPortData;
630
        next_TxByteOutCtrl <= `DATA_STREAM;
631
        next_rstCRC <= 1'b1;
632
      end
633
    end
634
    `RES_ST_CHK_FIN:
635
    begin
636
      next_USBWireWEn <= 1'b0;
637
      if (i == `RESUME_LEN)
638
      begin
639
        NextState_SIETx <= `RES_ST_S1;
640
      end
641
      else
642
      begin
643
        NextState_SIETx <= `RES_ST_WAIT_RDY;
644
      end
645
    end
646
    `RES_ST_S1:
647
    begin
648
      if (USBWireRdy == 1'b1)
649
      begin
650
        NextState_SIETx <= `RES_ST_S3;
651
        next_USBWireData <= `SE0;
652
        next_USBWireCtrl <= `DRIVE;
653
        next_USBWireWEn <= 1'b1;
654
      end
655
    end
656
    `RES_ST_S3:
657
    begin
658
      next_USBWireWEn <= 1'b0;
659
      if (USBWireRdy == 1'b1)
660
      begin
661
        NextState_SIETx <= `RES_ST_S4;
662
        next_USBWireData <= `SE0;
663
        next_USBWireCtrl <= `DRIVE;
664
        next_USBWireWEn <= 1'b1;
665
      end
666
    end
667
    `RES_ST_S4:
668
    begin
669
      next_USBWireWEn <= 1'b0;
670
      if (USBWireRdy == 1'b1)
671
      begin
672
        NextState_SIETx <= `RES_ST_S5;
673
        next_USBWireData <= JBit;
674
        next_USBWireCtrl <= `DRIVE;
675
        next_USBWireWEn <= 1'b1;
676
      end
677
    end
678
    `RES_ST_S5:
679
    begin
680
      next_USBWireWEn <= 1'b0;
681
      if (USBWireRdy == 1'b1)
682
      begin
683
        NextState_SIETx <= `RES_ST_S6;
684
        next_USBWireData <= JBit;
685
        next_USBWireCtrl <= `TRI_STATE;
686
        next_USBWireWEn <= 1'b1;
687
      end
688
    end
689
    `RES_ST_S6:
690
    begin
691
      next_USBWireWEn <= 1'b0;
692
      next_USBWireReq <= 1'b0;
693
      NextState_SIETx <= `STX_WAIT_BYTE;
694
    end
695
    `RES_ST_WAIT_GNT:
696
    begin
697
      if (USBWireGnt == 1'b1)
698
      begin
699
        NextState_SIETx <= `RES_ST_WAIT_RDY;
700
      end
701
    end
702
    `RES_ST_WAIT_RDY:
703
    begin
704
      if (USBWireRdy == 1'b1)
705
      begin
706
        NextState_SIETx <= `RES_ST_CHK_FIN;
707
        next_USBWireData <= KBit;
708
        next_USBWireCtrl <= `DRIVE;
709
        next_USBWireWEn <= 1'b1;
710
        next_i <= i + 1'b1;
711
      end
712
    end
713
  endcase
714
end
715
 
716
// Current State Logic (sequential)
717
always @ (posedge clk)
718
begin
719
  if (rst)
720
    CurrState_SIETx <= `START_SIETX;
721
  else
722
    CurrState_SIETx <= NextState_SIETx;
723
end
724
 
725
// Registered outputs logic
726
always @ (posedge clk)
727
begin
728
  if (rst)
729
  begin
730
    USBWireWEn <= 1'b0;
731
    USBWireReq <= 1'b0;
732
    processTxByteWEn <= 1'b0;
733
    rstCRC <= 1'b0;
734
    USBWireData <= 2'b00;
735
    USBWireCtrl <= `TRI_STATE;
736
    TxByteOut <= 8'h00;
737
    TxByteOutCtrl <= 8'h00;
738
    CRCData <= 8'h00;
739
    CRC5En <= 1'b0;
740
    CRC5_8Bit <= 1'b0;
741
    CRC16En <= 1'b0;
742
    SIEPortTxRdy <= 1'b0;
743
    i <= 5'h0;
744
    SIEPortData <= 8'h00;
745
    SIEPortCtrl <= 8'h00;
746
  end
747
  else
748
  begin
749
    USBWireWEn <= next_USBWireWEn;
750
    USBWireReq <= next_USBWireReq;
751
    processTxByteWEn <= next_processTxByteWEn;
752
    rstCRC <= next_rstCRC;
753
    USBWireData <= next_USBWireData;
754
    USBWireCtrl <= next_USBWireCtrl;
755
    TxByteOut <= next_TxByteOut;
756
    TxByteOutCtrl <= next_TxByteOutCtrl;
757
    CRCData <= next_CRCData;
758
    CRC5En <= next_CRC5En;
759
    CRC5_8Bit <= next_CRC5_8Bit;
760
    CRC16En <= next_CRC16En;
761
    SIEPortTxRdy <= next_SIEPortTxRdy;
762
    i <= next_i;
763
    SIEPortData <= next_SIEPortData;
764
    SIEPortCtrl <= next_SIEPortCtrl;
765
  end
766
end
767
 
768 2 sfielding
endmodule

powered by: WebSVN 2.1.0

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