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

Subversion Repositories usb_phy

[/] [usb_phy/] [trunk/] [rtl/] [verilog/] [usb_phy.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rudi
/////////////////////////////////////////////////////////////////////
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 9 rudi
//  $Id: usb_phy.v,v 1.4 2003-10-21 05:58:40 rudi Exp $
42 2 rudi
//
43 9 rudi
//  $Date: 2003-10-21 05:58:40 $
44
//  $Revision: 1.4 $
45 2 rudi
//  $Author: rudi $
46
//  $Locker:  $
47
//  $State: Exp $
48
//
49
// Change History:
50
//               $Log: not supported by cvs2svn $
51 9 rudi
//               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 7 rudi
//               Revision 1.2  2002/09/16 16:06:37  rudi
57
//               Changed top level name to be consistent ...
58
//
59 4 rudi
//               Revision 1.1.1.1  2002/09/16 14:26:59  rudi
60
//               Created Directory Structure
61 2 rudi
//
62
//
63
//
64
//
65
//
66
//
67
//
68 4 rudi
//
69 2 rudi
 
70
`include "timescale.v"
71
 
72 4 rudi
module usb_phy(clk, rst, phy_tx_mode, usb_rst,
73 2 rudi
 
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
input           clk;
84
input           rst;
85
input           phy_tx_mode;
86
output          usb_rst;
87
output          txdp, txdn, txoe;
88
input           rxd, rxdp, rxdn;
89
input   [7:0]    DataOut_i;
90
input           TxValid_i;
91
output          TxReady_o;
92
output  [7:0]    DataIn_o;
93
output          RxValid_o;
94
output          RxActive_o;
95
output          RxError_o;
96
output  [1:0]    LineState_o;
97
 
98
///////////////////////////////////////////////////////////////////
99
//
100
// Local Wires and Registers
101
//
102
 
103 7 rudi
reg     [4:0]    rst_cnt;
104 2 rudi
reg             usb_rst;
105 9 rudi
wire            fs_ce;
106
wire            rst;
107 2 rudi
 
108
///////////////////////////////////////////////////////////////////
109
//
110
// Misc Logic
111
//
112
 
113
///////////////////////////////////////////////////////////////////
114
//
115
// TX Phy
116
//
117
 
118
usb_tx_phy i_tx_phy(
119
        .clk(           clk             ),
120 9 rudi
        .rst(           rst             ),
121 2 rudi
        .fs_ce(         fs_ce           ),
122
        .phy_mode(      phy_tx_mode     ),
123
 
124
        // Transciever Interface
125
        .txdp(          txdp            ),
126
        .txdn(          txdn            ),
127
        .txoe(          txoe            ),
128
 
129
        // UTMI Interface
130
        .DataOut_i(     DataOut_i       ),
131
        .TxValid_i(     TxValid_i       ),
132
        .TxReady_o(     TxReady_o       )
133
        );
134
 
135
///////////////////////////////////////////////////////////////////
136
//
137
// RX Phy and DPLL
138
//
139
 
140
usb_rx_phy i_rx_phy(
141
        .clk(           clk             ),
142 9 rudi
        .rst(           rst             ),
143 2 rudi
        .fs_ce(         fs_ce           ),
144
 
145
        // Transciever Interface
146
        .rxd(           rxd             ),
147
        .rxdp(          rxdp            ),
148
        .rxdn(          rxdn            ),
149
 
150
        // UTMI Interface
151
        .DataIn_o(      DataIn_o        ),
152
        .RxValid_o(     RxValid_o       ),
153
        .RxActive_o(    RxActive_o      ),
154
        .RxError_o(     RxError_o       ),
155
        .RxEn_i(        txoe            ),
156
        .LineState(     LineState_o     )
157
        );
158
 
159
///////////////////////////////////////////////////////////////////
160
//
161
// Generate an USB Reset is we see SE0 for at least 2.5uS
162
//
163
 
164 9 rudi
`ifdef USB_ASYNC_REST
165
always @(posedge clk or negedge rst)
166
`else
167 2 rudi
always @(posedge clk)
168 9 rudi
`endif
169 7 rudi
        if(!rst)                        rst_cnt <= 5'h0;
170 2 rudi
        else
171 7 rudi
        if(LineState_o != 2'h0)         rst_cnt <= 5'h0;
172 2 rudi
        else
173 7 rudi
        if(!usb_rst && fs_ce)           rst_cnt <= rst_cnt + 5'h1;
174 2 rudi
 
175
always @(posedge clk)
176 7 rudi
        usb_rst <= (rst_cnt == 5'h1f);
177 2 rudi
 
178
endmodule
179
 

powered by: WebSVN 2.1.0

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