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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [hostController/] [sendpacketcheckpreamble.v] - Blame information for rev 9

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

Line No. Rev Author Line
1 5 sfielding
 
2
//////////////////////////////////////////////////////////////////////
3
////                                                              ////
4
//// sendpacketcheckpreamble
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
`timescale 1ns / 1ps
46
`include "usbConstants_h.v"
47
 
48
module sendPacketCheckPreamble (clk, fullSpeedBitRate, fullSpeedPolarity, grabLineControl, preAmbleEnable, rst, sendPacketCPPID, sendPacketCPReady, sendPacketCPWEn, sendPacketPID, sendPacketRdy, sendPacketWEn);
49
input   clk;
50
input   preAmbleEnable;
51
input   rst;
52
input   [3:0]sendPacketCPPID;
53
input   sendPacketCPWEn;
54
input   sendPacketRdy;
55
output  fullSpeedBitRate;
56
output  fullSpeedPolarity;
57
output  grabLineControl;    // mux select
58
output  sendPacketCPReady;
59
output  [3:0]sendPacketPID;
60
output  sendPacketWEn;
61
 
62
wire    clk;
63
reg     fullSpeedBitRate, next_fullSpeedBitRate;
64
reg     fullSpeedPolarity, next_fullSpeedPolarity;
65
reg     grabLineControl, next_grabLineControl;
66
wire    preAmbleEnable;
67
wire    rst;
68
wire    [3:0]sendPacketCPPID;
69
reg     sendPacketCPReady, next_sendPacketCPReady;
70
wire    sendPacketCPWEn;
71
reg     [3:0]sendPacketPID, next_sendPacketPID;
72
wire    sendPacketRdy;
73
reg     sendPacketWEn, next_sendPacketWEn;
74
 
75
// BINARY ENCODED state machine: sendPktCP
76
// State codes definitions:
77
`define SPC_WAIT_EN 4'b0000
78
`define START_SPC 4'b0001
79
`define CHK_PREAM 4'b0010
80
`define PREAM_PKT_SND_PREAM 4'b0011
81
`define PREAM_PKT_WAIT_RDY1 4'b0100
82
`define PREAM_PKT_WAIT_RDY2 4'b0101
83
`define PREAM_PKT_SND_PID 4'b0110
84
`define PREAM_PKT_WAIT_RDY3 4'b0111
85
`define REG_PKT_SEND_PID 4'b1000
86
`define REG_PKT_WAIT_RDY1 4'b1001
87
`define REG_PKT_WAIT_RDY 4'b1010
88
`define READY 4'b1011
89
 
90
reg [3:0]CurrState_sendPktCP, NextState_sendPktCP;
91
 
92
 
93
// Machine: sendPktCP
94
 
95
// NextState logic (combinatorial)
96
always @ (sendPacketCPWEn or preAmbleEnable or sendPacketRdy or sendPacketCPPID or sendPacketCPReady or sendPacketWEn or sendPacketPID or fullSpeedBitRate or fullSpeedPolarity or grabLineControl or CurrState_sendPktCP)
97
begin
98
  NextState_sendPktCP <= CurrState_sendPktCP;
99
  // Set default values for outputs and signals
100
  next_sendPacketCPReady <= sendPacketCPReady;
101
  next_sendPacketWEn <= sendPacketWEn;
102
  next_sendPacketPID <= sendPacketPID;
103
  next_fullSpeedBitRate <= fullSpeedBitRate;
104
  next_fullSpeedPolarity <= fullSpeedPolarity;
105
  next_grabLineControl <= grabLineControl;
106
  case (CurrState_sendPktCP)  // synopsys parallel_case full_case
107
    `SPC_WAIT_EN:
108
    begin
109
      if (sendPacketCPWEn == 1'b1)
110
      begin
111
        NextState_sendPktCP <= `CHK_PREAM;
112
        next_sendPacketCPReady <= 1'b0;
113
      end
114
    end
115
    `START_SPC:
116
    begin
117
      NextState_sendPktCP <= `SPC_WAIT_EN;
118
    end
119
    `CHK_PREAM:
120
    begin
121
      if (preAmbleEnable == 1'b1)
122
      begin
123
        NextState_sendPktCP <= `PREAM_PKT_WAIT_RDY1;
124
      end
125
      else
126
      begin
127
        NextState_sendPktCP <= `REG_PKT_WAIT_RDY1;
128
      end
129
    end
130
    `READY:
131
    begin
132
      next_sendPacketCPReady <= 1'b1;
133
      NextState_sendPktCP <= `SPC_WAIT_EN;
134
    end
135
    `PREAM_PKT_SND_PREAM:
136
    begin
137
      next_sendPacketWEn <= 1'b1;
138
      next_sendPacketPID <= `PREAMBLE;
139
      NextState_sendPktCP <= `PREAM_PKT_WAIT_RDY2;
140
      next_sendPacketWEn <= 1'b0;
141
    end
142
    `PREAM_PKT_WAIT_RDY1:
143
    begin
144
      if (sendPacketRdy == 1'b1)
145
      begin
146
        NextState_sendPktCP <= `PREAM_PKT_SND_PREAM;
147
        next_fullSpeedBitRate <= 1'b1;
148
        next_fullSpeedPolarity <= 1'b1;
149
        next_grabLineControl <= 1'b1;
150
      end
151
    end
152
    `PREAM_PKT_WAIT_RDY2:
153
    begin
154
      if (sendPacketRdy == 1'b1)
155
      begin
156
        NextState_sendPktCP <= `PREAM_PKT_SND_PID;
157
        next_fullSpeedBitRate <= 1'b1;
158
      end
159
    end
160
    `PREAM_PKT_SND_PID:
161
    begin
162
      next_sendPacketWEn <= 1'b1;
163
      next_sendPacketPID <= sendPacketCPPID;
164
      NextState_sendPktCP <= `PREAM_PKT_WAIT_RDY3;
165
      next_sendPacketWEn <= 1'b0;
166
    end
167
    `PREAM_PKT_WAIT_RDY3:
168
    begin
169
      if (sendPacketRdy == 1'b1)
170
      begin
171
        NextState_sendPktCP <= `READY;
172
        next_grabLineControl <= 1'b0;
173
      end
174
    end
175
    `REG_PKT_SEND_PID:
176
    begin
177
      next_sendPacketWEn <= 1'b1;
178
      next_sendPacketPID <= sendPacketCPPID;
179
      NextState_sendPktCP <= `REG_PKT_WAIT_RDY;
180
    end
181
    `REG_PKT_WAIT_RDY1:
182
    begin
183
      if (sendPacketRdy == 1'b1)
184
      begin
185
        NextState_sendPktCP <= `REG_PKT_SEND_PID;
186
      end
187
    end
188
    `REG_PKT_WAIT_RDY:
189
    begin
190
      next_sendPacketWEn <= 1'b0;
191
      NextState_sendPktCP <= `READY;
192
    end
193
  endcase
194
end
195
 
196
// Current State Logic (sequential)
197
always @ (posedge clk)
198
begin
199
  if (rst)
200
    CurrState_sendPktCP <= `START_SPC;
201
  else
202
    CurrState_sendPktCP <= NextState_sendPktCP;
203
end
204
 
205
// Registered outputs logic
206
always @ (posedge clk)
207
begin
208
  if (rst)
209
  begin
210
    sendPacketCPReady <= 1'b1;
211
    sendPacketWEn <= 1'b0;
212
    sendPacketPID <= 4'b0;
213
    fullSpeedBitRate <= 1'b0;
214
    fullSpeedPolarity <= 1'b0;
215
    grabLineControl <= 1'b0;
216
  end
217
  else
218
  begin
219
    sendPacketCPReady <= next_sendPacketCPReady;
220
    sendPacketWEn <= next_sendPacketWEn;
221
    sendPacketPID <= next_sendPacketPID;
222
    fullSpeedBitRate <= next_fullSpeedBitRate;
223
    fullSpeedPolarity <= next_fullSpeedPolarity;
224
    grabLineControl <= next_grabLineControl;
225
  end
226
end
227
 
228 2 sfielding
endmodule

powered by: WebSVN 2.1.0

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