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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [usbhostslave/] [slaveSendPacket.v] - Blame information for rev 534

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

Line No. Rev Author Line
1 408 julius
 
2
// File        : ../RTL/slaveController/slaveSendpacket.v
3
// Generated   : 11/10/06 05:37:26
4
// From        : ../RTL/slaveController/slaveSendpacket.asf
5
// By          : FSM2VHDL ver. 5.0.0.9
6
 
7
//////////////////////////////////////////////////////////////////////
8
////                                                              ////
9
//// slaveSendPacket
10
////                                                              ////
11
//// This file is part of the usbhostslave opencores effort.
12
//// http://www.opencores.org/cores/usbhostslave/                 ////
13
////                                                              ////
14
//// Module Description:                                          ////
15
//// 
16
////                                                              ////
17
//// To Do:                                                       ////
18
//// 
19
////                                                              ////
20
//// Author(s):                                                   ////
21
//// - Steve Fielding, sfielding@base2designs.com                 ////
22
////                                                              ////
23
//////////////////////////////////////////////////////////////////////
24
////                                                              ////
25
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG          ////
26
////                                                              ////
27
//// This source file may be used and distributed without         ////
28
//// restriction provided that this copyright statement is not    ////
29
//// removed from the file and that any derivative work contains  ////
30
//// the original copyright notice and the associated disclaimer. ////
31
////                                                              ////
32
//// This source file is free software; you can redistribute it   ////
33
//// and/or modify it under the terms of the GNU Lesser General   ////
34
//// Public License as published by the Free Software Foundation; ////
35
//// either version 2.1 of the License, or (at your option) any   ////
36
//// later version.                                               ////
37
////                                                              ////
38
//// This source is distributed in the hope that it will be       ////
39
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
40
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
41
//// PURPOSE. See the GNU Lesser General Public License for more  ////
42
//// details.                                                     ////
43
////                                                              ////
44
//// You should have received a copy of the GNU Lesser General    ////
45
//// Public License along with this source; if not, download it   ////
46
//// from http://www.opencores.org/lgpl.shtml                     ////
47
////                                                              ////
48
//////////////////////////////////////////////////////////////////////
49
//
50
//
51
`include "timescale.v"
52
`include "usbhostslave_serialinterfaceengine_h.v"
53
`include "usbhostslave_constants_h.v"
54
 
55
module slaveSendPacket (PID, SCTxPortCntl, SCTxPortData, SCTxPortGnt, SCTxPortRdy, SCTxPortReq, SCTxPortWEn, clk, fifoData, fifoEmpty, fifoReadEn, rst, sendPacketRdy, sendPacketWEn);
56
input   [3:0] PID;
57
input   SCTxPortGnt;
58
input   SCTxPortRdy;
59
input   clk;
60
input   [7:0] fifoData;
61
input   fifoEmpty;
62
input   rst;
63
input   sendPacketWEn;
64
output  [7:0] SCTxPortCntl;
65
output  [7:0] SCTxPortData;
66
output  SCTxPortReq;
67
output  SCTxPortWEn;
68
output  fifoReadEn;
69
output  sendPacketRdy;
70
 
71
wire    [3:0] PID;
72
reg     [7:0] SCTxPortCntl, next_SCTxPortCntl;
73
reg     [7:0] SCTxPortData, next_SCTxPortData;
74
wire    SCTxPortGnt;
75
wire    SCTxPortRdy;
76
reg     SCTxPortReq, next_SCTxPortReq;
77
reg     SCTxPortWEn, next_SCTxPortWEn;
78
wire    clk;
79
wire    [7:0] fifoData;
80
wire    fifoEmpty;
81
reg     fifoReadEn, next_fifoReadEn;
82
wire    rst;
83
reg     sendPacketRdy, next_sendPacketRdy;
84
wire    sendPacketWEn;
85
 
86
// diagram signals declarations
87
reg  [7:0]PIDNotPID;
88
 
89
// BINARY ENCODED state machine: slvSndPkt
90
// State codes definitions:
91
`define START_SP1 4'b0000
92
`define SP_WAIT_ENABLE 4'b0001
93
`define SP1_WAIT_GNT 4'b0010
94
`define SP_SEND_PID_WAIT_RDY 4'b0011
95
`define SP_SEND_PID_FIN 4'b0100
96
`define FIN_SP1 4'b0101
97
`define SP_D0_D1_READ_FIFO 4'b0110
98
`define SP_D0_D1_WAIT_READ_FIFO 4'b0111
99
`define SP_D0_D1_FIFO_EMPTY 4'b1000
100
`define SP_D0_D1_FIN 4'b1001
101
`define SP_D0_D1_TERM_BYTE 4'b1010
102
`define SP_NOT_DATA 4'b1011
103
`define SP_D0_D1_CLR_WEN 4'b1100
104
`define SP_D0_D1_CLR_REN 4'b1101
105
 
106
reg [3:0] CurrState_slvSndPkt;
107
reg [3:0] NextState_slvSndPkt;
108
 
109
// Diagram actions (continuous assignments allowed only: assign ...)
110
 
111
always @(PID)
112
begin
113
    PIDNotPID <=  { (PID ^ 4'hf), PID };
114
end
115
 
116
//--------------------------------------------------------------------
117
// Machine: slvSndPkt
118
//--------------------------------------------------------------------
119
//----------------------------------
120
// Next State Logic (combinatorial)
121
//----------------------------------
122
always @ (PIDNotPID or fifoData or sendPacketWEn or SCTxPortGnt or SCTxPortRdy or PID or fifoEmpty or sendPacketRdy or SCTxPortReq or SCTxPortWEn or SCTxPortData or SCTxPortCntl or fifoReadEn or CurrState_slvSndPkt)
123
begin : slvSndPkt_NextState
124
  NextState_slvSndPkt <= CurrState_slvSndPkt;
125
  // Set default values for outputs and signals
126
  next_sendPacketRdy <= sendPacketRdy;
127
  next_SCTxPortReq <= SCTxPortReq;
128
  next_SCTxPortWEn <= SCTxPortWEn;
129
  next_SCTxPortData <= SCTxPortData;
130
  next_SCTxPortCntl <= SCTxPortCntl;
131
  next_fifoReadEn <= fifoReadEn;
132
  case (CurrState_slvSndPkt)
133
    `START_SP1:
134
      NextState_slvSndPkt <= `SP_WAIT_ENABLE;
135
    `SP_WAIT_ENABLE:
136
      if (sendPacketWEn == 1'b1)
137
      begin
138
        NextState_slvSndPkt <= `SP1_WAIT_GNT;
139
        next_sendPacketRdy <= 1'b0;
140
        next_SCTxPortReq <= 1'b1;
141
      end
142
    `SP1_WAIT_GNT:
143
      if (SCTxPortGnt == 1'b1)
144
        NextState_slvSndPkt <= `SP_SEND_PID_WAIT_RDY;
145
    `FIN_SP1:
146
    begin
147
      NextState_slvSndPkt <= `SP_WAIT_ENABLE;
148
      next_sendPacketRdy <= 1'b1;
149
      next_SCTxPortReq <= 1'b0;
150
    end
151
    `SP_NOT_DATA:
152
      NextState_slvSndPkt <= `FIN_SP1;
153
    `SP_SEND_PID_WAIT_RDY:
154
      if (SCTxPortRdy == 1'b1)
155
      begin
156
        NextState_slvSndPkt <= `SP_SEND_PID_FIN;
157
        next_SCTxPortWEn <= 1'b1;
158
        next_SCTxPortData <= PIDNotPID;
159
        next_SCTxPortCntl <= `TX_PACKET_START;
160
      end
161
    `SP_SEND_PID_FIN:
162
    begin
163
      next_SCTxPortWEn <= 1'b0;
164
      if (PID == `DATA0 || PID == `DATA1)
165
        NextState_slvSndPkt <= `SP_D0_D1_FIFO_EMPTY;
166
      else
167
        NextState_slvSndPkt <= `SP_NOT_DATA;
168
    end
169
    `SP_D0_D1_READ_FIFO:
170
    begin
171
      next_SCTxPortWEn <= 1'b1;
172
      next_SCTxPortData <= fifoData;
173
      next_SCTxPortCntl <= `TX_PACKET_STREAM;
174
      NextState_slvSndPkt <= `SP_D0_D1_CLR_WEN;
175
    end
176
    `SP_D0_D1_WAIT_READ_FIFO:
177
      if (SCTxPortRdy == 1'b1)
178
      begin
179
        NextState_slvSndPkt <= `SP_D0_D1_CLR_REN;
180
        next_fifoReadEn <= 1'b1;
181
      end
182
    `SP_D0_D1_FIFO_EMPTY:
183
      if (fifoEmpty == 1'b0)
184
        NextState_slvSndPkt <= `SP_D0_D1_WAIT_READ_FIFO;
185
      else
186
        NextState_slvSndPkt <= `SP_D0_D1_TERM_BYTE;
187
    `SP_D0_D1_FIN:
188
    begin
189
      next_SCTxPortWEn <= 1'b0;
190
      NextState_slvSndPkt <= `FIN_SP1;
191
    end
192
    `SP_D0_D1_TERM_BYTE:
193
      if (SCTxPortRdy == 1'b1)
194
      begin
195
        NextState_slvSndPkt <= `SP_D0_D1_FIN;
196
        //Last byte is not valid data,
197
        //but the 'TX_PACKET_STOP' flag is required
198
        //by the SIE state machine to detect end of data packet
199
        next_SCTxPortWEn <= 1'b1;
200
        next_SCTxPortData <= 8'h00;
201
        next_SCTxPortCntl <= `TX_PACKET_STOP;
202
      end
203
    `SP_D0_D1_CLR_WEN:
204
    begin
205
      next_SCTxPortWEn <= 1'b0;
206
      NextState_slvSndPkt <= `SP_D0_D1_FIFO_EMPTY;
207
    end
208
    `SP_D0_D1_CLR_REN:
209
    begin
210
      next_fifoReadEn <= 1'b0;
211
      NextState_slvSndPkt <= `SP_D0_D1_READ_FIFO;
212
    end
213
  endcase
214
end
215
 
216
//----------------------------------
217
// Current State Logic (sequential)
218
//----------------------------------
219
always @ (posedge clk)
220
begin : slvSndPkt_CurrentState
221
  if (rst)
222
    CurrState_slvSndPkt <= `START_SP1;
223
  else
224
    CurrState_slvSndPkt <= NextState_slvSndPkt;
225
end
226
 
227
//----------------------------------
228
// Registered outputs logic
229
//----------------------------------
230
always @ (posedge clk)
231
begin : slvSndPkt_RegOutput
232
  if (rst)
233
  begin
234
    sendPacketRdy <= 1'b1;
235
    SCTxPortReq <= 1'b0;
236
    SCTxPortWEn <= 1'b0;
237
    SCTxPortData <= 8'h00;
238
    SCTxPortCntl <= 8'h00;
239
    fifoReadEn <= 1'b0;
240
  end
241
  else
242
  begin
243
    sendPacketRdy <= next_sendPacketRdy;
244
    SCTxPortReq <= next_SCTxPortReq;
245
    SCTxPortWEn <= next_SCTxPortWEn;
246
    SCTxPortData <= next_SCTxPortData;
247
    SCTxPortCntl <= next_SCTxPortCntl;
248
    fifoReadEn <= next_fifoReadEn;
249
  end
250
end
251
 
252
endmodule

powered by: WebSVN 2.1.0

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