📄 usb1_core.v
字号:
/////////////////////////////////////////////////////////////////////
//// ////
//// USB 1.1 function IP core ////
//// ////
//// ////
//// Author: Rudolf Usselmann ////
//// rudi@asics.ws ////
//// ////
//// ////
//// Downloaded from: http://www.opencores.org/cores/usb1_funct/////
//// ////
/////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2000-2002 Rudolf Usselmann ////
//// www.asics.ws ////
//// rudi@asics.ws ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer.////
//// ////
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
//// POSSIBILITY OF SUCH DAMAGE. ////
//// ////
/////////////////////////////////////////////////////////////////////
// CVS Log
//
// $Id: usb1_core.v,v 1.2 2002/10/11 05:48:20 rudi Exp $
//
// $Date: 2002/10/11 05:48:20 $
// $Revision: 1.2 $
// $Author: rudi $
// $Locker: $
// $State: Exp $
//
// Change History:
// $Log: usb1_core.v,v $
// Revision 1.2 2002/10/11 05:48:20 rudi
//
// Fixed a typo in the top level.
//
// Revision 1.1 2002/09/25 06:06:49 rudi
// - Added New Top Level
// - Remove old top level and associated files
// - Moved FIFOs to "Generic FIFOs" project
//
//
//
//
//
//
//
`include "usb1_defines.v"
/*
// USB PHY Interface
tx_dp, tx_dn, tx_oe,
rx_d, rx_dp, rx_dn,
These pins are a semi-standard interface to USB 1.1 transceivers.
Just match up the signal names with the IOs of the transceiver.
// USB Misc
phy_tx_mode, usb_rst,
The PHY supports single ended and differential output to the
transceiver Depending on which device you are using, you have
to tie the phy_tx_mode high or low.
usb_rst is asserted whenever the host signals reset on the USB
bus. The USB core will internally reset itself automatically.
This output is provided for external logic that needs to be
reset when the USB bus is reset.
// Interrupts
dropped_frame, misaligned_frame,
crc16_err,
dropped_frame, misaligned_frame are interrupt to indicate error
conditions in Block Frame mode.
crc16_err, indicates when a crc 16 error was detected on the
payload of a USB packet.
// Vendor Features
v_set_int, v_set_feature, wValue,
wIndex, vendor_data,
This signals allow to control vendor specific registers and logic
that can be manipulated and monitored via the control endpoint
through vendor defined commands.
// USB Status
usb_busy, ep_sel,
usb_busy is asserted when the USB core is busy transferring
data ep_sel indicated the endpoint that is currently busy.
This information might be useful if one desires to reset/clear
the attached FIFOs and want to do this when the endpoint is idle.
// Endpoint Interface
This implementation supports 8 endpoints. Endpoint 0 is the
control endpoint and used internally. Endpoints 1-7 are available
to the user. replace 'N' with the endpoint number.
epN_cfg,
This is a constant input used to configure the endpoint by ORing
these defines together and adding the max packet size for this
endpoint:
`IN and `OUT select the transfer direction for this endpoint
`ISO, `BULK and `INT determine the endpoint type
Example: "`BULK | `IN | 14'd064" defines a BULK IN endpoint with
max packet size of 64 bytes
epN_din, epN_we, epN_full,
This is the OUT FIFO interface. If this is a IN endpoint, ground
all unused inputs and leave outputs unconnected.
epN_dout, epN_re, epN_empty,
this is the IN FIFO interface. If this is a OUT endpoint ground
all unused inputs and leave outputs unconnected.
epN_bf_en, epN_bf_size,
These two constant configure the Block Frame feature.
*/
module usb1_core(clk_i, rst_i,
// USB PHY Interface
tx_dp, tx_dn, tx_oe,
rx_d, rx_dp, rx_dn,
// USB Misc
phy_tx_mode, usb_rst,
// Interrupts
dropped_frame, misaligned_frame,
crc16_err,
// Vendor Features
v_set_int, v_set_feature, wValue,
wIndex, vendor_data,
// USB Status
usb_busy, ep_sel,
// Endpoint Interface
ep1_cfg,
ep1_din, ep1_we, ep1_full,
ep1_dout, ep1_re, ep1_empty,
ep1_bf_en, ep1_bf_size,
ep2_cfg,
ep2_din, ep2_we, ep2_full,
ep2_dout, ep2_re, ep2_empty,
ep2_bf_en, ep2_bf_size,
ep3_cfg,
ep3_din, ep3_we, ep3_full,
ep3_dout, ep3_re, ep3_empty,
ep3_bf_en, ep3_bf_size,
ep4_cfg,
ep4_din, ep4_we, ep4_full,
ep4_dout, ep4_re, ep4_empty,
ep4_bf_en, ep4_bf_size,
ep5_cfg,
ep5_din, ep5_we, ep5_full,
ep5_dout, ep5_re, ep5_empty,
ep5_bf_en, ep5_bf_size,
ep6_cfg,
ep6_din, ep6_we, ep6_full,
ep6_dout, ep6_re, ep6_empty,
ep6_bf_en, ep6_bf_size,
ep7_cfg,
ep7_din, ep7_we, ep7_full,
ep7_dout, ep7_re, ep7_empty,
ep7_bf_en, ep7_bf_size,
report_data
);
input clk_i;
input rst_i;
output tx_dp, tx_dn, tx_oe;
input rx_d, rx_dp, rx_dn;
input phy_tx_mode;
output usb_rst;
output dropped_frame, misaligned_frame;
output crc16_err;
output v_set_int;
output v_set_feature;
output [15:0] wValue;
output [15:0] wIndex;
input [15:0] vendor_data;
output usb_busy;
output [3:0] ep_sel;
// Endpoint Interfaces
input [13:0] ep1_cfg;
input [7:0] ep1_din;
output [7:0] ep1_dout;
output ep1_we, ep1_re;
input ep1_empty, ep1_full;
input ep1_bf_en;
input [6:0] ep1_bf_size;
input [13:0] ep2_cfg;
input [7:0] ep2_din;
output [7:0] ep2_dout;
output ep2_we, ep2_re;
input ep2_empty, ep2_full;
input ep2_bf_en;
input [6:0] ep2_bf_size;
input [13:0] ep3_cfg;
input [7:0] ep3_din;
output [7:0] ep3_dout;
output ep3_we, ep3_re;
input ep3_empty, ep3_full;
input ep3_bf_en;
input [6:0] ep3_bf_size;
input [13:0] ep4_cfg;
input [7:0] ep4_din;
output [7:0] ep4_dout;
output ep4_we, ep4_re;
input ep4_empty, ep4_full;
input ep4_bf_en;
input [6:0] ep4_bf_size;
input [13:0] ep5_cfg;
input [7:0] ep5_din;
output [7:0] ep5_dout;
output ep5_we, ep5_re;
input ep5_empty, ep5_full;
input ep5_bf_en;
input [6:0] ep5_bf_size;
input [13:0] ep6_cfg;
input [7:0] ep6_din;
output [7:0] ep6_dout;
output ep6_we, ep6_re;
input ep6_empty, ep6_full;
input ep6_bf_en;
input [6:0] ep6_bf_size;
input [13:0] ep7_cfg;
input [7:0] ep7_din;
output [7:0] ep7_dout;
output ep7_we, ep7_re;
input ep7_empty, ep7_full;
input ep7_bf_en;
input [6:0] ep7_bf_size;
output [7 : 0] report_data;
///////////////////////////////////////////////////////////////////
//
// Local Wires and Registers
//
// UTMI Interface
wire [7:0] DataOut;
wire TxValid;
wire TxReady;
wire [7:0] DataIn;
wire RxValid;
wire RxActive;
wire RxError;
wire [1:0] LineState;
wire [7:0] rx_data;
wire rx_valid, rx_active, rx_err;
wire [7:0] tx_data;
wire tx_valid;
wire tx_ready;
wire tx_first;
wire tx_valid_last;
// Internal Register File Interface
wire [6:0] funct_adr; // This functions address (set by controller)
wire [3:0] ep_sel; // Endpoint Number Input
wire crc16_err; // Set CRC16 error interrupt
wire int_to_set; // Set time out interrupt
wire int_seqerr_set; // Set PID sequence error interrupt
wire [31:0] frm_nat; // Frame Number and Time Register
wire nse_err; // No Such Endpoint Error
wire pid_cs_err; // PID CS error
wire crc5_err; // CRC5 Error
reg [7:0] tx_data_st;
wire [7:0] rx_data_st;
reg [13:0] cfg;
reg ep_empty;
reg ep_full;
wire [7:0] rx_size;
wire rx_done;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -