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

Subversion Repositories usb2uart

[/] [usb2uart/] [trunk/] [rtl/] [usb1_phy/] [usb_phy.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  USB 1.1 PHY                                                ////
4
////                                                             ////
5
////                                                             ////
6
////  Author: Rudolf Usselmann                                   ////
7
////          rudi@asics.ws                                      ////
8
////                                                             ////
9
////                                                             ////
10
////  Downloaded from: http://www.opencores.org/cores/usb_phy/   ////
11
////                                                             ////
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
15
////                         www.asics.ws                        ////
16
////                         rudi@asics.ws                       ////
17
////                                                             ////
18
//// This source file may be used and distributed without        ////
19
//// restriction provided that this copyright statement is not   ////
20
//// removed from the file and that any derivative work contains ////
21
//// the original copyright notice and the associated disclaimer.////
22
////                                                             ////
23
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
24
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
25
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
26
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
27
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
28
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
29
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
30
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
31
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
32
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
33
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
34
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
35
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
36
////                                                             ////
37
/////////////////////////////////////////////////////////////////////
38
 
39
//  CVS Log
40
//
41
//  $Id: usb_phy.v,v 1.4 2003-10-21 05:58:40 rudi Exp $
42
//
43
//  $Date: 2003-10-21 05:58:40 $
44
//  $Revision: 1.4 $
45
//  $Author: rudi $
46
//  $Locker:  $
47
//  $State: Exp $
48
//
49
// Change History:
50
//               $Log: not supported by cvs2svn $
51
//               Revision 1.3  2003/10/19 17:40:13  rudi
52
//               - Made core more robust against line noise
53
//               - Added Error Checking and Reporting
54
//               (See README.txt for more info)
55
//
56
//               Revision 1.2  2002/09/16 16:06:37  rudi
57
//               Changed top level name to be consistent ...
58
//
59
//               Revision 1.1.1.1  2002/09/16 14:26:59  rudi
60
//               Created Directory Structure
61
//
62
//
63
//
64
//
65
//
66
//
67
//
68
//
69
 
70
`include "timescale.v"
71
 
72
module usb_phy(clk, rst, phy_tx_mode, usb_rst,
73
 
74
                // Transciever Interface
75
                txdp, txdn, txoe,
76
                rxd, rxdp, rxdn,
77
 
78
                // UTMI Interface
79
                DataOut_i, TxValid_i, TxReady_o, RxValid_o,
80
                RxActive_o, RxError_o, DataIn_o, LineState_o
81
                );
82
 
83
 
84
/***************************************
85
*  Comman Signal
86
*  *************************************/
87
input           clk              ; // 48Mhz clock
88
input           rst              ; // Active low async reset
89
 
90
input           phy_tx_mode      ; // Used in Tx Path,
91
                                   // The PHY supports single ended and differential output to the
92
                                   // transceiver Depending on which device you are using, you have
93
                                   // to tie the phy_tx_mode high or low. 
94
output          usb_rst          ; // usb_rst is asserted whenever the host signals reset on the USB bus.
95
                                   // The USB core will internally reset itself automatically.
96
                                   // This output is provided for external logic that needs to be
97
                                   // reset when the USB bus is reset.
98
 
99
output          txdp, txdn, txoe;
100
input           rxd, rxdp, rxdn;
101
input   [7:0]    DataOut_i;
102
input           TxValid_i;
103
output          TxReady_o;
104
output  [7:0]    DataIn_o;
105
output          RxValid_o;
106
output          RxActive_o;
107
output          RxError_o;
108
output  [1:0]    LineState_o;
109
 
110
///////////////////////////////////////////////////////////////////
111
//
112
// Local Wires and Registers
113
//
114
 
115
reg     [4:0]    rst_cnt;
116
reg             usb_rst;
117
wire            fs_ce;
118
wire            rst;
119
 
120
///////////////////////////////////////////////////////////////////
121
//
122
// Misc Logic
123
//
124
 
125
///////////////////////////////////////////////////////////////////
126
//
127
// TX Phy
128
//
129
 
130
usb_tx_phy i_tx_phy(
131
        .clk(           clk             ),
132
        .rst(           rst             ),
133
        .fs_ce(         fs_ce           ),
134
        .phy_mode(      phy_tx_mode     ),
135
 
136
        // Transciever Interface
137
        .txdp(          txdp            ),
138
        .txdn(          txdn            ),
139
        .txoe(          txoe            ),
140
 
141
        // UTMI Interface
142
        .DataOut_i(     DataOut_i       ),
143
        .TxValid_i(     TxValid_i       ),
144
        .TxReady_o(     TxReady_o       )
145
        );
146
 
147
///////////////////////////////////////////////////////////////////
148
//
149
// RX Phy and DPLL
150
//
151
 
152
usb_rx_phy i_rx_phy(
153
        .clk(           clk             ),
154
        .rst(           rst             ),
155
        .fs_ce(         fs_ce           ),
156
 
157
        // Transciever Interface
158
        .rxd(           rxd             ),
159
        .rxdp(          rxdp            ),
160
        .rxdn(          rxdn            ),
161
 
162
        // UTMI Interface
163
        .DataIn_o(      DataIn_o        ),
164
        .RxValid_o(     RxValid_o       ),
165
        .RxActive_o(    RxActive_o      ),
166
        .RxError_o(     RxError_o       ),
167
        .RxEn_i(        txoe            ),
168
        .LineState(     LineState_o     )
169
        );
170
 
171
///////////////////////////////////////////////////////////////////
172
//
173
// Generate an USB Reset is we see SE0 for at least 2.5uS
174
//
175
 
176
`ifdef USB_ASYNC_REST
177
always @(posedge clk or negedge rst)
178
`else
179
always @(posedge clk)
180
`endif
181
        if(!rst)                        rst_cnt <= 5'h0;
182
        else
183
        if(LineState_o != 2'h0)         rst_cnt <= 5'h0;
184
        else
185
        if(!usb_rst && fs_ce)           rst_cnt <= rst_cnt + 5'h1;
186
 
187
always @(posedge clk)
188
        usb_rst <= (rst_cnt == 5'h1f);
189
 
190
endmodule
191
 

powered by: WebSVN 2.1.0

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