The Intellectual Property (IP) core is intended solely for our clients for physical integration into their own technical products
after careful examination by experienced technical personnel for its suitability for the intended purpose.
The IP was not developed for or intended for use in any specific customer application. The firmware/software of the device
may have to be adapted to the specific intended modalities of use or even replaced by other firmwa re/software in order to
ensure flawless function in the respective areas of application.
Performance data may depend on the operating environment, the area of application, the conf iguration, and method of
control, as well as on other conditions of use; these may deviate from the technical specifications, the Design Guide speci
fications, or other product documentation. The actual performance characteristics can be determined only by measurements subsequent to integration.
The reference designs were tested in a reference environment for compliance with the legal requirements applicable to the
reference environment.
No representation is made regarding the compliance with legal, regulatory, or other requirements in other environments. No
representation can be made and no warranty can be assumed regarding the suitability of the device for a specific purpose
as defined by our customers.
SLS reserves the right to make changes to the hardware or firmware or software or to the specifications without prior notice
or to replace the IP with a successor model to improve performance or design of the IP. Of course, any changes to the
hardware or firmware or software of any IP for which we have entered into an agreemen t with our custo mers will be made
only if, and only to the extent that, such changes can reasonably be expected to be acceptable to our customers.
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 5
Typographic
Conventions
Visual CueMeaning
The user guide uses the typographic conventions as shown below:
Bold Type with Initial Capital
letters
Bold Type with Italic LettersAll Definitions, Figure and Table Headings are displayed in Italics.
All headings and Sub headings Titles in a document are displayed in
bold type with initial capital letters; Example: Core Architecture,
Operation.
Examples:
Table 4-1. Register Details, Figure 2-1. USB 20SR IP
Core Architecture
Italic typeVariable names are enclosed in angle brackets (< >) and shown in italic
type. Example: <USB20SR Installation Path>.
1., 2.
•
Numbered steps are used in a list of items, when the sequence of items
is important. such as steps listed in procedure.
Bullets are used in a list of items when the sequence of items is not
important.
The hand points to special information that requires special attention
The caution indicates required information that needs special consideration and understanding and should be read prior to starting or continuing with the procedure or process.
System Level Solutions
January 2013
The warning indicates information that should be read prior to starting
or continuing the procedure or processes.
The feet direct you to more information on a particular topic.
v
USB 2.0 (USB20SR) Device IP Core User Guide
Page 6
Contents
About this Guide ................................................................................................................iii
How To Find Information ........................................................................................................................iii
How to Contact SLS ............................................. ............................... ............................... .. ...................iv
Further Information...................................................................................................................................3
On Chip RAM...........................................................................................................................................6
TEST MODE .............................................................. ............................... .............................................24
6.Using USB20SR IP in SOPC Builder .....................................................................................37
System Level Solutions
January 2013
vii
USB 2.0 (USB20SR) Device IP Core User Guide
Page 8
1. Introduction
The USB 2.0 Device IP Core (USB20SR) is a RAM based, 32-bit Avalon
interface and ULPI interface support. The core supports both High Speed
(480 Mbps) and Full Speed (12 Mbps) functionality. The core supports three
endpoints Control, IN and OUT. Support of up to 15 endpoints can be added
inside the IP Core as per customer request. Endpoint can be used for IN or
OUT operation at a time. Support of IN and OUT operation on a single
endpoint can be added as per customer request to add support of 15 IN and 15
OUT endpoint. Each endpoint has an endpoint controller that supports
interrupt, bulk, and isochronous transfers.
The core is an RTL design in Verilog that implements an USB device
controller on an ASIC or FPGA. The core has been optimized for popular
FPGA devices and its functionality has been verified on the real hardware. It
is provided as Altera Quartus II Mega function (Altera SOPC Builder ready
component) and integrates easily into any SOPC Builder generated system
using Nios
®
II Avalon bus.
System Level Solutions
January 2013
This user guide will provide you with some basic technical details of
USB20SR device core acting as an Avalon slave in Altera’s SOPC builder.
SOPC builder is a software tool that allows for the creation of a Nios II system
module or a more general multi master System On A Programmable Chip
module. A complete Nios II system module contains a Nios II (soft core 32
bit RISC) processor and its associated system peripherals.
For development kits lacking USB interface, SLS has ULPI interface Snap
On Board available, along with a USB 2.0 device IP core integrated into
SOPC builder. The Snap On Board snaps on to the Altera Standard Santa
Cruz header, therefore, now your Nios development kit is with USB 2.0
interface without any extra effort. So now using SOPC builder one can build
a system with USB interface in just a few minutes.
To develop your Embedded System using USB 2.0 ULPI interface refer to
USB 2.0 On-The-Go (ULPI) Snap On Board Reference Manual. Y ou can also
1
USB 2.0 (USB20SR) Device IP Core User Guide
Page 9
refer to CoreCommander Reference Manual.
Introduction
Features
Following are the USB20SR Device IP core features:
USB 2.0 USB IF high-speed certified
Supports both High Speed (480 Mbps) and Full Speed (12 Mbps)
High speed or Full speed operation selection through Software
Low speed (1.5 Mbps) support also available on special request.
Please contact support@slscorp.com for more details
ULPI Interface support
Pre configured for 3 endpoints
•CONTROL
•IN
•OUT
Configurable for up to 15 IN/OUT endpoints which can support Bulk,
Interrupt, Isochronous functionality on each endpoint on customer
request at additional cost.
Fully software controlled CONTROL, IN and OUT endpoints
Avalon Bus compliant
Optimized LE count
For information about USB20SR IP Core installation directory
structure and its content, licensing, component implementation and its
support, refer readme.html located at <USB20SR Installation Path>\ usb20sr. <USB20SR Installation Path> is the installation directory. The
default installation directory is c:\altera\<version #>\ip\sls. Where version no.
is Quartus setup version.’
3
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 11
2. Core Architecture
Protocol
Layer
ULPI
Interface
ULPI
PHY
Mi cro Con t ro ller/Processor I nterface
(ex. AVAL ON BUS INTERF ACE )
EndPoint
Registers
D+
D-
External
On Chip RAM
USB2.0 System Top
EP0
Controller
The USB 2.0 Device communicates through two differential lines
(D+ & D-) that connect to a transceiver . The transceiver or physical interface,
in turn, connects to the core via interface signals. Since the core supports all
the transfer types - Control, Bulk, Isochronous and Interrupt, each transfer
type retains a separate pipe for OUT and IN operation.
overall architecture of the USB20SR IP core.
Figure 2-1. illustrates
Figure 2-1.USB20SR Device IP Core Architecture
Each of the blocks is described in detail below:
The Micro Controller/Processor interface provides a bridge between Host
Interfaces (ex. Nios II Processor) and internal data memory and control
registers.
System Level Solutions
January 2013
USB 2.0 (USB20SR) Device IP Core User Guide
4
Page 12
ULPI PHY
ULPI PHY
ULPI Interface
Protocol Layer
EndPoint
Registers
EP0 Controller
The ULPI PHY chip is the external chip that provides a link between USB2.0
IP and the physical USB data lines D+ & D-. The maximum clock from the
PHY is 60MHz in 8 bit mode. All the blocks of USB IP Core related to USB
activity run from the clock provided by the ULPI PHY for synchronization.
The ULPI block connects through the external PHY. It controls speed negotiation as well as handles all functions related to the line signals. It also handles
theULPI PHY chip configuration for device operation.
This block De assembles/Assembles the packet, handles all the standard
USB 2.0 protocol handshakes and control correspondence. Proto layer also
handles all error conditions of USB protocol.
This block has control and status registers for each endpoints. One can
configure any specific endpoint through these registers via Avalon interface.
Detail description of each register as well as it’s bit is given inside the
Tabl e 4-1 Regist er Description.
This module will be implemented fully inside the hardware when the IP Core
is enabled in debug mode. IP Core can be switched into debug mode in place
of normal mode to verify the ULPI Phy chip interface functionality with the
HOST PC.
The section below explains the steps to verify the ULPI PHY chip
functionality with the host PC.
1.Open the usb20sr_debug.v file located at <USB20SR Installation
Path>\hardware\component\hdl.
2.Disable the "‘define SR_ENABLE" line inside the file.
3.Recompile your design.
4.Download the .sof file on your board.
5.Connect the device with the Host PC through the USB 2.0 compliant
cable.
6.The default SLS device should be enumerated on the Host PC without
running a Nios II project.
7.If the device enumeration fails with the host PC, then there will be an
error in generating the reference design or PHY interface on the board.
5
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 13
Core Architecture
On Chip RAM
Micro Controller/
Processor
Interface
This memory is used to store transmitted as well as received data for EndPoints. Size of this memory is 2Kbyte for IN and 2Kbyte for OUT endpoints
in default configuration of the IP Core. Micro controller and device interfaces
with this memory through two different memory ports with separate clock for
each. Size of this memory should be increased through SOPC builder
parameter settings, if number of endpoint increases to use separate memory
buffers for each endpoint.
This block provides a consistent core interface between the internal functions
of the core and the function-specific host or micro controller.
System Level Solutions
January 2013
6
USB 2.0 (USB20SR) Device IP Core User Guide
Page 14
3. Operation
ULPI
PHY
Core
Logic
Host
Or
Hub
EP0
EP2
(
F
u
n
c
t
i
o
n
S
uP )
F
u
n
c
t
i
o
n
S
(uP )
EP1
This core has been designed to compatible with avalon specific interface. The
Figure 3-1. below shows how the core connects to the function micro
controller and HOST.
IP core functionality is controlled by function controller as shown in
Figure 3-1. through endpoint registers.
Figure 3-1.Operational Block Diagram
The USB core uses onchip memory (512*32) for IN operation as well as
(512*32) for OUT operation separately. IN and OUT memory starts from the
same location inside the IP Core (0x20000).
IN memory is write only memory and OUT memory is read only memory for
processor. For device OUT memory is write only memory and IN memory is
read only memory. No soft ware in tervention is needed between endpoint
access. Double buffer mechanism is used for reducing the latency
requirement on the software, and increasing USB throughput.
System Level Solutions
January 2013
USB 2.0 (USB20SR) Device IP Core User Guide
7
Page 15
Operation
EndPoints
This USB core supports 3 endpoints (Control, IN, OUT). The function
controller must set up the endpoints by writing to the endpoint register:
EPn_CSR. EPn_IMS, EPn_BUFx.
Buffer Pointers
The buffer pointers point to the input/output data structure in memory. If all
buffers are not allocated, the core will respond with NAK acknowledge to the
USB host.
This core supports a double buffering feature which reduces the latency
requirements on the functions micro controller and driver software. Data is
being retrieved/filled from/to the buffers in a round robin fashion. When data
is sent to/from an endpoint, first buffer0 is used. When the first buffer is
empty/full, the function controller, may be notified via an interrupt. The
function controller can refill/empty buffer0 now. The core will now use buffer
1 for the next operation. When the second buffer is full/empty, the function
controller is interrupted, and the core will use buffer0 again, and so on. A
buffer that has the used bit set cause the core for replying with NAK/NYET
acknowledgments to the host.
The Buffer’s Used bitsindicate when a buffer has been used (this information
is also provided in the Interrupt Source Register). The function controller
must clear these bits after it has emptied/refilled the buffer.
Data Organization
Since the buffer memory is 32 bits wide and USB defines all transactions on
byte boundaries it is important to understand the relationship of data in the
buffer to actual USB byte sequence. This USB core supports Little Endian
byte ordering.
System Level Solutions
January 2013
8
USB 2.0 (USB20SR) Device IP Core User Guide
Page 16
Interrupts
Config/Status Bits
Interrupt Mask
Buffer 0 Poi nter
Buffer 1 Poi nter
EPn _CSR:
EPn_IMS:
EPn_BUF0:
EPn_BUF1:
Interrupt Source
Buffer 1 Size
Use d Bit
Use d Bit
0
16173031
Buffer 0 Size
Figure 3-2.Data Organization
Interrupts
The buffer pointer always point to byte 0. The USB core always fetches four
bytes from the buffer memory. The actual final byte that is transmitted in the
th
N
transaction depends on the Buffer Size. The MaxPacketSize must always
be a multiple of 4 bytes.
The USB core provides interrupt outputs. The output is fully programmable.
The usage of the interrupt is up to the system into which the USB core is
incorporated.
The interrupt mechanism in the USB core consists of a two level hierarchy:
1.The main interrupt source register (INT_SRC) indicates interrupts
2.The endpoint interrupt source register indicates events that are
Timing
The interrupt output are asserted when the condition that is enabled in the
interrupt mask occurs. They remain asserted until the main interrupt register
is read.
Software Interaction
An interrupt handler should first read the main interrupt source register
(INT_SRC) to determine the source of an interrupt. It must remember the
value that was read until it is done processing of each interrupt source. If any
of the bits 15 to 0 are set, the interrupt handler should also read the appropriate
9
that are endpoint independent. These interrupts indicate overall events
that have either global meaning for all endpoints or can not be associated
with an endpoint because of an error condition.
specific to an endpoint.
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 17
Operation
endpoint interrupt register to determine endpoint specific events. Multiple
interrupt sources may be indicated at any given time. Software should be
prepared to handle every interrupt source it cares about.
A care must be taken not to lose interrupt sources, as the main interrupt source
register is cleared after interrupt source register read operation.
System Level Solutions
January 2013
10
USB 2.0 (USB20SR) Device IP Core User Guide
Page 18
This section describes all the registers inside the USB20SR Core. The
Register field describes the name of the register. The Offset field describes
the offset of register in USB IP. The Access field describes the type of access
to the register that is read or write. Description field describes the type and
function of register.
Table 4-1. Register Description
4. Core Registers
Table 4-1 shows the register details.
Sr.
RegisterOffsetWidthAccessDescription
No.
1DCVERSION 0x00 32ROIP Core Version/Product ID description register
2FUNC_ADR0x048RWUSB function address register
3INT_MSK0x08 16RWInterrupt Mask for endpoint independent interrupt
sources
4INT_SRC0x0c 32ROCInterrupt source register
5MAIN_CSR0x108RWControl/Status register
6FRM_NAT0x14 32ROFrame number and time
7TEST_MODE0x208RWTest mode register for enabling test mode inside
the IP Core
8SETUP_PACK_10x30 32ROFirst four bytes of received setup packet
9SETUP_PACK_20x3432ROSecond fo ur b y tes of received setup packet
10ULPI_PHY_CS0x1f08RWULPI PHY Chip enable or disable register
11ULPI_REG_
ACCESS
12D_SPEED_SEL0x1f88RWDevice IP Core speed select register
1.Endpoint buffer memory (2K size) is starting from offset address
0X20000.
2.The above table includes all 15 endpoint register details of the IP Core
with its offset. From these endpoint registers, only those are applicable
whose support is enabled inside the hardware. For example if IP Core
supports 6 endpoints then all endpoints from 0 to 5 are applicable while
endpoints from 6 to 15 are not applicable. The IP Core supports 3
endpoints by default.
DCVERSION
This register represent IP Core Version/Product ID description of the core. .
Table 4-2 shows the DCVERSION register description.
Table 4-2. DCVERSION Register Details
BitAccessDescription
31:16 ROThese bits represent the hexadecimal value of Product ID. (i.e. 0A0 4 for USB20SR)
15:8RO These bits represent the hexadecimal value of IP Core Version. (i.e. 13 for IP Core Ver-
sion 1.3)
7:0RO These bits represent the hexadecimal value of Customer Number and Customer
Release Number. (i.e. 0 for Customer Number and 0 for Customer Release Number, if
any)
Value after Reset: 00000000h
System Level Solutions
January 2013
USB 2.0 (USB20SR) Device IP Core User Guide
14
Page 22
FUNC_ADR
FUNC_ADR
This register is used to set the function address of the device received in set
address request from host. Function address should be written inside this reg
ister before replying the status stage of the SET_address request. Device
address will be set inside the IP Core after status stage reply of the
SET_ADDRESS request.
Table 4-3 shows the list of FUNC_ADR register
description.
Table 4-3. FUNC_ADR Register Details
BitAccessDescription
7RWReserved
6:0RWFunction address value
Value after Reset: 00h
INT_MSK
The interrupt mask register defines functionality of interrupt output with
regard to event not associated to endpoints. Processor can enable or disable
the interrupts as per the application requirement. The information-only-inter
rupts can be disabled while other interrupts should be handled properly by
processor for configuration of the device according to the device speed as
well as data communication to and from the host PC.
of Interrupt Mask register description.
1: Enable interrupt generation due to Speed Negotiation Done
0: Disable interrupt generation due to Speed Negotiation Done
8RWUSB Reset Mask
1: Enable interrupt generation due to USB reset
0: Disable interrupt generation due to USB reset
7RWUTMI RX Error Mask
1: Enable interrupt generation due to UTMI RX Error
0: Disable interrupt generation due to UTMI RX Error
15
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 23
6RWDevice Detached Mask
1: Enable interrupt generation due to device is detached
0: Disable interrupt generation due to device is detached
5RWDevice Attach Mask
1: Enable interrupt generation due to device is attached
0: Disable interrupt generation due to device is attached
4RWResume Mode Mask
1: Enable interrupt generation due to device resumes
0: Disable interrupt generation due to device resumes
3RWSuspend Mode Mask
1: Enable interrupt generation due to device suspends
0: Disable interrupt generation due to device suspends
2RWNo such endpoint Mask
1: Enable interrupt generation due to no such endpoint error
0: Disable interrupt generation due to no such endpoint error
Core Registers
1RWPID Error Mask
1: Enable interrupt generation due to PID Error
0: Disable interrupt generation due to PID Error
0RWCRC5 Error Mask
1: Enable interrupt generation due to CRC5 error
0: Disable interrupt generation due to CRC5 error
Value after Reset: 0000h
INT_SRC
This register identifies the interrupt source. Whenever the function controller
receives an interrupt, the interrupt handler must read this register to determine
the source and cause of an interrupt. All endpoint independent device inter
rupt clears, once read operation is completed over the register. The software
interrupt handler must make sure that it keeps whatever information is
required to handle the interrupt.
After getting this interrupt, processor should configure the endpoints according to the
device speed.
Device sets this bit, while the speed negotiation process is completed during reset
stage. Device performs the speed negotiation process to decide the device communication with host (high speed or full speed mode).
1: Speed negotiation process is completed.
0: Speed negotiation process is not completed.
28ROCUSB Reset
Software must reconfigure the endpoint registers after detecting this interrupt.
Device sets this interrupt bit when host performs USB reset operation over the device.
Device resets the IP Core internally and all registers. Host performs this operation
when a device is attached with the host and also when an application driver resets the
device whenever it finds any problem with the device communication.
1: Device is reset.
0: Device is not reset.
27ROCUSB Rx Error
This interrupt bit is for information purpo s e on l y.
Devicesets this interrupt whenever it finds any undesired D+ and D- value during data
receive operation. Data lines status is verified continuously for attached speed mode of
the device. Device takes all necessary steps to handle this error .
1: Rxerror is received
0: Rxerror is not received
26ROCDetached
Device sets this interrupt bit when it is detached from the host and vbus is removed or
the device is disconnected through disconnect register (D_CNCT).
1: Device is disconnected
0: Device is not disconnected
25ROCAttached
Device sets this interrupt bit when it is attached to the host pc and Vbus goes high.
Device should be enabled to connect with host through connect register (D_CNCT) for
getting this interrupt.
1: Device is attached
0: Device is not attached
24ROCResume
Device sets this interrupt bit whenever it resumes from suspend state. Host controller
resumes the device from suspend state if it requires to perform any operation over a
suspended device or device responses with remote wake up event.
1: Device is resumed
0: Device is not resumed
17
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 25
23ROCSuspend
Device sets this bit when there is no any activity on USB data lines for 3ms and goes
into suspend state. Software can use this information for power saving of component
used with USB.
1: Device is suspended
0: Device is not suspended
22ROCNo Such Endpoint
This interrupt bit is for information purpose only. This bit provides status of one possible
error of USB communication.
Device sets this bit whenever any endpoint number selected inside the received token
is not supported by the device. Device takes all necessary action to handle this error
itself and no any intervention is needed from processor. e.g. Token received with EP no
= 4 and device supports only three EPs.
1: Token is received with endpoint number error
0: Token is not received with endpoint number error
21ROCPID Error
This interrupt bit is for information purpose only. This bit provides status of one possible
error of USB communication.
Device sets this bit whenever any token is received with PID checksum error from host.
Device takes all necessary action to handle this error itself and no any intervention is
needed from processor.
1: Packet received with PID checksum error.
0: Packet with PID checksum error is not received.
Core Registers
20ROCBad Token (CRC5 error)
This interrupt bit is for information purpose only. This bit provides status of one possible
error of USB communication.
Device sets this bit whenever any token is received with CRC5 error from host. Device
takes all necessary action to handle this error itself and no any intervention is needed
from software.
1: Packet is received with token error.
0: Packet is not received with token error
19:16ROReserved
15ROEndpoint 15 interrupt
Device sets this bit when any interrupt bit of endpoint15 is set to high. This bit gets
cleared when software reads endpoint15 interrupt register. Details of the endpoint
interrupt event is given inside the endpoint interrupt register information.
1: Interrupt bit is set inside endpoint15.
0: Interrupt bit is not set inside endpoint15.
System Level Solutions
January 2013
18
USB 2.0 (USB20SR) Device IP Core User Guide
Page 26
INT_SRC
14ROEndpoint 14 interrupt
Device sets this bit when any interrupt bit of endpoint14 is set to high. This bit gets
cleared when software reads endpoint14 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint14.
0: Interrupt bit is not set inside endpoint14.
13ROEndpoint 13 interrupt
Device sets this bit when any interrupt bit of endpoint13 is set to high. This bit gets
cleared when software reads endpoint13 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint13.
0: Interrupt bit is not set inside endpoint13.
12ROEndpoint 12 interrupt
Device sets this bit when any interrupt bit of endpoint12 is set to high. This bit gets
cleared when software reads endpoint12 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint12.
0: Interrupt bit is not set inside endpoint12.
11ROEndpoint 11 interrupt
Device sets this bit when any interrupt bit of endpoint11 is set to high. This bit gets
cleared when software reads endpoint1 1 interrupt register . Det ails of the endpoint inter-
rupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint11.
0: Interrupt bit is not set inside endpoint11.
10ROEndpoint 10 interrupt
Device sets this bit when any interrupt bit of endpoint10 is set to high. This bit gets
cleared when software reads endpoint10 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint10.
0: Interrupt bit is not set inside endpoint10.
9ROEndpoint 9 interrupt
Device sets this bit when any interrupt bit of endpoint9 is set to high. This bit gets
cleared when software reads endpoint9 interrupt register. Details of the endpoint inter
rupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint9.
0: Interrupt bit is not set inside endpoint9.
-
19
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 27
8ROEndpoint 8 interrupt
Device sets this bit when any interrupt bit of endpoint8 is set to high. This bit gets
cleared when software reads endpoint8 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint8.
0: Interrupt bit is not set inside endpoint8.
7ROEndpoint 7 interrupt
Device sets this bit when any interrupt bit of endpoint7 is set to high. This bit gets
cleared when software reads endpoint7 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint7.
0: Interrupt bit is not set inside endpoint7.
6ROEndpoint 6 interrupt
Device sets this bit when any interrupt bit of endpoint6 is set to high. This bit gets
cleared when software reads endpoint6 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint6.
0: Interrupt bit is not set inside endpoint6.
Core Registers
5ROsEndpoint 5 interrupt
Device sets this bit when any interrupt bit of endpoint5 is set to high. This bit gets
cleared when software reads endpoint5 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint5.
0: Interrupt bit is not set inside endpoint5.
4ROEndpoint 4 interrupt
Device sets this bit when any interrupt bit of endpoint4 is set to high. This bit gets
cleared when software reads endpoint4 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint4.
0: Interrupt bit is not set inside endpoint4.
3ROEndpoint 3 interrupt
Device sets this bit when any interrupt bit of endpoint3 is set to high. This bit gets
cleared when software reads the endpoint3 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint3.
0: Interrupt bit is not set inside endpoint3.
System Level Solutions
January 2013
20
USB 2.0 (USB20SR) Device IP Core User Guide
Page 28
MAIN_CSR
2ROEndpoint 2 interrupt
Device sets this bit when any interrupt bit of endpoint2 is set to high. This bit gets
cleared when software reads endpoint2 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint2.
0: Interrupt bit is not set inside endpoint2.
1ROEndpoint 1 interrupt
Device sets this bit when any interrupt bit of endpoint1 is set to high. This bit gets
cleared when software reads the endpoint1 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint1.
0: Interrupt bit is not set inside endpoint1.
0ROEndpoint 0 interrupt
Device sets this bit when any interrupt bit of endpoint0 is set to high. This bit gets
cleared when software reads the endpoint0 interrupt register. Details of the endpoint
interrupt event is given inside endpoint interrupt register information.
1: Interrupt bit is set inside endpoint0.
0: Interrupt bit is not set inside endpoint0.
MAIN_CSR
Value after reset: 00000000h
Register detail given above includes all 15 endpoint interrupt but only those
are applicable which are available inside the hardware.
To get more in formation about USB error, read the proto layer section of
USB2.0 specification.
This is the main configuration and status register of the core. This register
provides current status of the device.
Table 4-6 shows the Control/Status
register description.
21
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
This bit is used to generate a remote wakeup event from the device while device is in
suspend state. The device should be enumerated with re mote wake up functionality
support to use this bit. After the remote wake up operation is completed successfully,
the device clears this bit. Remote wake up should not be performed until host enables
the device for remote wake up event through Set feature. Device clears this bit after
performing a resume request.
1: Device is enabled for remote wake up
0: Device is disabled for remote wake up
6ROReserved
5ROReserved
Core Registers
4:3ROLinestate
These bits provide the current state of D+ and D- line.
Linestate[0] = D+ line
Linestate[1] = D- line
2RODevice attached
This bit is used to check the status of the attached device.
Device sets this bit, when it is attached to the Host and Vbus is available from the Host
PC Port.
1: Device is attached to the host.
0: Device is detached from the host.
System Level Solutions
January 2013
22
USB 2.0 (USB20SR) Device IP Core User Guide
Page 30
FRM_NAT
1RODevice speed
This bit is used to configure the endpoints according to device speed.
Device sets this bit when it is connected into high speed mode with the Host PC after the
successful speed negotiation. Device clears this bit when it is connected to the Host PC
into full speed mode due to speed negotiation is failed. While the Host PC does not sup-
port EHCI controller or EHCI is disabled, speed negotiation is failed and device is con-
nected into full speed mode. When the device is enabled for high speed mode using
D_SPEED_SEL register and it is attached into full speed mode with the host then the
message will be displayed that device can be connected into high speed mode.
1: Device is attached into high speed mode
0: Device is attached into full speed mode
0ROSuspend
This status bit is used to check whether the device is in suspend state or not.
Device sets this bit when it goes into suspend state and clears the bit when it resumes
from suspend state. When the device is in suspend state there would not be any USB
device related operation from the host.
1: Device is suspended
0: Device is active
Value after Reset: 00h
FRM_NAT
This register tracks frame number as received from the SOF token, and the
frame time.
Table 4-7 shows the Frame Number and Time register
description.
Table 4-7. Frame Number and Time (FRM_NAT ) Register Details
BitAccessDescription
31:28RONumber of frames with the same frame number (this field may be used to determine
current microframe)
27ROReserved
26:16ROFrame number as received from SOF token
15:12ROReserved
11:0ROTime since last SOF in 0.5 uSresolution
Value after reset: 00000000h
23
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 31
Core Registers
TEST MODE
This register is used to configure the device into specific test mode for
compliance test of the device. Different test modes are used for compliance
test to check verify the device against its all electrical test cases. Once device
is enabled into any test mode, it can not be used for any other operation.
External reset should be used to exit the device from the test mode.
Table 4-8 shows the Test Mode register description.
Table 4-8. Test Mode (TEST MODE) Register Details
BitAccessDescription
7:5ROReserved
4RWEnable_test_mode
This bit is used to enable test mode on device selected from first four bits of this register
for compliance test. At a time only one test mode should be selected in first four bits.
1: Test mode enable
0: Test mode disable
3RWTest_packet_mode
This bit is used to select Test-packet mode for compliance test.
1: test mode is selected
0: test mode is not selected
2RWTest_se0_mode
This bit is used to select Test-SE0 mode for compliance test.
1: test mode is selected
0: test mode is not selected
1RWTest_k_mode
This bit is used to select T est-K mode for compliance test.
1: test mode is selected
0: test mode is not selected
0RWTest_J_mode
This bit is used to select T est-J mode for compliance test.
1: test mode is selected
0: test mode is not selected
Value after Reset: 00h
System Level Solutions
January 2013
24
USB 2.0 (USB20SR) Device IP Core User Guide
Page 32
SETUP_PACK_1
SETUP_PACK_1
This register is used to read first four bytes received of setup packet.
Table 4-9 shows the First Setup Packet register description.
Setup packet is received with 8 bytes data information and from that, first four bytes
are stored in this register. After getting a setup packet receive interrupt on control
endpoint, processor should read this register for getting information of first four bytes of
setup packet.
Value after reset: 00000000h
SETUP_PACK_2
This register is used to read second four bytes received of setup packet.
Table 4-10 shows the Second Setup Packet register description.
Second four bytes of setup packet is stored in this register. Processor should read
this register after reading first four bytes of setup packet to get the complete
information of received setup packet.
ULPI_PHY_CS
25
Value after reset:00000000h
This register is used to control the chip select pin of the ULPI PHY Chip
through processor. Processor can enable or disable the ULPI PHY Chip
through this register as per the application requirement.
ULPI PHY Chip Enable register description.
T able 4-11 shows the
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
ULPI PHY Chip has number of different registers inside it to cont rol its functionality through Phy Chip interface. This register is used to provide read or
ACCESS
write access of the ULPI chip register to the processor. Processor can read or
write the specific register of ULPI PHY Chip through proper configuration of
the register inside the USB IP Core.
This bit is used to enable PHY chip register read operation inside
the device IP Core. This bit should be set by the processor when it
want to read any register of the PHY chip. Device clears this bit
when it completes register read operation and load the read data.
This bit is used to enable PHY chip register write operation. This bit
should be set by the processor when it want to write any register of
the PHY chip. Device clears this bit when it completes register write
operation.
These bits are used to store readdata received from selected register during read operation.
15:8RWPhy Reg writedata
These bits of the register is used to specify write data which will be
loaded inside the selected PHY register when write operation is
enabled through write_en bit setting.
7:0RWPhy register address
This address bits are used to select PHY chip register on which
read or write operation needs to be performed.
Value after Reset: 00h
D_SPEED_SEL
This register is used to configure the USB device core for specific speed
communication. With the use of this register, device core can be used as a
USB20 high speed device or it can be used as a USB1.1 Full speed device.
Table 4-13 shows the Device Speed Select register description.
7:1RWReserved
0RWThis bit is used to select speed mode for USB device IP Core.
Device can be set into high or full mode before it is connected to the
host PC.
In high speed mode, device can be attached to host in high speed if
EHCI controller is available and speed negotiation is successful
otherwise it is connected into full speed with full speed controller.
In full speed mode device can be attached to the host into full
speed only even though enhanced host controller is present.
1: Device is enabled for high speed connection
0: Device is enabled for full speed connection
Value after Reset: 01h
D_CNCT
This register is used to control device connect/disconnect operation through
processor. This is 8 bit register. For connection of the device with the host,
0x01 should be written to the register and to disconnect the device from host
0x00 should be written to the register.
27
T abl e 4-14 shows the Device Connect/
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
7:1RWReserved for future use
0RWConnect/Disconnect
1 = Device is enabled for connection
0 = Device is disabled for connection
Value after Reset: 00h
Endpoint
Registers
Figure 4-1.Endpoint Register
EPn_CSR
Each endpoint has 4 registers associated with it. These registers have exactly
the same definition for each endpoint except for control endpoint (please refer
a control endpoint related special notes where its flow is different compare to
other endpoints.)
This is the control and status register of the endpoint. Through this register
processor can configure the endpoint with few basic functionality support. It
can also use this register to get back some information during communication
to take few decisions based on it. Detail description for usage of each bit of
this register is given in table below.
register description
Buffer_select[0]
This register bit is used to select a buffer for next transaction over selected endpoint.
Each endpoint of the IP Core has double buffer support for reducing data communication
latency over a endpoint. Device toggles this bit after successful transaction over a
selected endpoint. This bit is used with buffer done bit of the buffer registers to select the
buffer for next transaction. To use single buffer communication over adevice,
buffer-done bit of buffer1 should always be disabled. IP Core buffer selection is as given
below.
0: Buffer0 of the endpoint is selected.
1: Buffer1 of the endpoint is selected.
Buffer_select[1]
This bit usage is reserved. Support of this bit is given to add support for four buffer over a
endpoint, which is configured for IN and OUT operation support as per the custom
request. By default endpoint can perform a single direction communication either IN or
out.
Note: Control endpoint does not use this information for buffer selection and it is reserved
as it support data communication on both direction. Control endpoint uses buffer0 for
OUT operation and buffer1 for IN operation.
29:28 RWDATAPID_sel
These two bits are used by device to keep track of the next expected datapid for the
transaction over a endpoint. Device handles these two bits on its own to keep track of the
next datapid once it get initialized.
Processor should reset these bits after getting device reset or setup packet request with
endpoint clear feature or set interface or set configuration. Misuse of these bits can give
loss of data packets. Refer proto layer specification for more detailed information of data
pid usage for different types of USB application design.
Note: Control endpoint does not use this information and hardware itself takes carefor
this data bit.
27:26 RWEP_TYPE
Endpoint Type
These two control bits are used by device to select the type of the endpoint.
00: Control Endpoint
01:IN EndPoint
10: OUT Endpoint
11: Reserved
29
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 37
25:24 RWTR_TYPE
Transfer Type
This two bits are used to configure the endpoint for different types of transfer support on
it. USB controller handles transaction over the endpoint differently depending on this
input.
Temporarily Disable EP
These two bits are used to control the endpoint during error condition. Halt feature of the
endpoint is set to send stall handshake to the host controller. Endpoint can be disabled
temporary through these bits for avoiding any process by controller over the endpoint.
00: Normal
01: Force the core to ignore transfer over this EP
10: Set EP HALT
11: Reserved
Core Registers
21:18 ROEP_number
17RWLRG_OK
These bits are used to show the number. Endpoint numbers are fixed from hardware
itself and it can not be changed through software.
1 - Accept data packets of more than MAX_PL_SZ (RX only)
0 - Ignore data packets of more than MAX_PL_SZ (RX only)
16RWSmall_ok
This bit is used by device to check whether endpoint is configured for receiving packet
with payload size less then max packet length. If this bit is set to 1, then device will
accept the received packet with payload less then the maximum packet length size set
ting of the endpoint. If this bit is set to 0 then endpoint will receive only those packet from
host which has data payload size as its maximum packet length size. Device will discard
all small packets received from host on its own and no information will be provided to
host.
15ROReserved
14ROReserved
13ROReserved
-
System Level Solutions
January 2013
30
USB 2.0 (USB20SR) Device IP Core User Guide
Page 38
EPn_IMS
12:11RWTF_FR
Number of transaction per microframe (HS mode only)
These bits are used for isochronous data communication only. These bits are not used
for bulk and interrupt transfer over a device. These bits are used to give information of
the number of transaction per microframe. Bit value setting depends on the endpoint
description given inside the enumeration process.
10:0RWMAX_PL_SZ
Maximum payload size (MaxPacketSize) in bytes
These bits are used by device to get information of max payload size of the endpoint. Dif-
ferent endpoint can be configured with different maximum packet length within its max
limit for select transfer type. Endpoint maximum value should be matched with the end-
point max packet length description given inside the endpoint descriptor during enumera-
tion process. Mismatch between these two can give unexpected device behavior.
Value after Reset: All bits of the register will be zero after reset except
endpoint number.
EPn_IMS
The interrupt register for each endpoint has mask bits for interrupt output and
bits that indicate the interrupt source when an interrupt has been received.
Interrupt source bits are set depending on its mask bit setting given inside the
same register. Interrupt bit clears after read oper ation of the register.
Table 4-16 shows the Endpoint Interrupt Mask/Source register description.
1: Enable interrupt generation due to ISO Out Packet Error
0: Disable interrupt generation due to ISO Out Packet Error
28RWPID Sequence Error Mask
1: Enable interrupt generation due to PID Sequence Error
0: Disable interrupt generation due to PID Sequence Error
27RWBuffer used Mask
1: Enable interrupt generation when buffer used bit of buffer registers is set.
0: Disable interrupt generation when buffer used bit of buffer registers is set.
26RWUnsupported PID Mask
1: Enable interrupt generation due to unsupported PIDerror
0: Disable interrupt generation due to unsupported PIDerror
31
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 39
25RWCRC 16 error Mask
1: Enable interrupt generation due to CRC16 error occurred in received data packet.
0: Disable interrupt generation due to CRC16 error occurred in received data packet
24RWTime out error Mask
1: Enable interrupt generation due to timeout error
0: Disable interrupt generation due to timeouterror
23:08ROReserved
7ROCISO out packet lose
This interrupt is only supported for isochronous out endpoint and for other endpoints. It
is reserved with value set to 0. Device sets this bit for isochronous out endpoint when-
ever any received packet lose on isochronous out endpoint.
1: Received packet is lose
0: Received packet is not lose
6ROCSetup packet receive
This interrupt is only supported for control endpoint and for other endpoints it is reserved
with value set to 0. Device sets this bit for control endpoint whenever any setup packet
request is received on control endpoint.
1: Setup packet is received
0: Setup packet is not received
Core Registers
5ROCPID Sequence Error
This interrupt bit is for information purpose only.
Device sets this bit whenever it receives a data packet with PID sequence error on out
endpoint. Device takes necessary action to handle this error condition.
1:Data packet is received with PID sequence error
0:Data packet is not received with PID sequence error
4ROCBuffer 1 Used
Device sets this bit whenever the IN/OUT operation gets completed on an endpoint
buffer1. For IN endpoint, device sets this interrupt bit when it transmits all dat a from
buffer 1 and buffer 1 is empty. For OUT endpoint, device sets this bit when it receives
short data packet or if there is no enough space to receive other max_packet_size
packet inside the buffer 1 at the end of the current packetreceive operation. It also sets
the buffer used bit of the buffer1 register of the endpoint before this interrupt is set to
high.
1: Operation is completed on buffer 1.
0: Operation is not completed on buffer 1
Note: Control endpoint uses single buffer communication for IN and OUT operation.
Device sets buffer0 used bit when out operation is finished.
System Level Solutions
January 2013
32
USB 2.0 (USB20SR) Device IP Core User Guide
Page 40
EPn_BUF
3ROCBuffer 0 Used
Device sets this bit whenever IN/OUT operation gets completed on an endpoint buffer0.
For IN endpoint, device sets this interrupt bit when it transmits all data from buffer 0 and
buffer 0 is empty. (updated buffer size value of buffer register = 0). For OUT endpoint,
device sets this bit when it receives short data packet or if there is no enough space to
receive other max_packet_sizepacket inside the buffer0 at the end of the packet
receive operation. It also sets the buffer used bit of the buffer0 register ofthe endpoint
before this interrupt is set high.
1: Operation is completed on buffer 0
0: Operation is not completed on buffer 0
Note: Control endpoint uses single buffer communication for IN and OUT operation.
Device sets buffer0 used bit when out operation is finished.
2ROCUnsupported PID error
This interrupt bit is for information purpose only.
Device sets this bit whenever it receives unsupported PID for the endpoint. It means if
endpoint is configured as out endpoint and it receives Token byte for IN operation
selection. Device takes necessary action for handling this error.
1: Unsupported PIDis received inside token byte
0: Unsupported PIDis not received inside token byte
1ROCBad packet error
This interrupt bit is for information purpose only. This interrupt receives on OUT endpoint
only.
Device sets this bit whenever it receives data packet with CRC16 error.
1: Data packet is received with CRC16 error.
0: Data packet is not received with CRC16 error.
0ROCTime out error
This interrupt bit is for information purpose only.
Device sets this bit on different condition for IN and out endpoint. Device sets this bit for
out endpoint when data packet is not received after out token packet within out
operation time out limitation as per the specification. For IN endpoint, device sets this bit
when it does not receive ACK token from host after data packet transmission within IN
operation time out limitation as per the specification. Device takes necessary action to
handle this error.
1: Time out error is received
0: Time out error is not received
Value after Reset: 00000000h
EPn_BUF
The endpoint buffer register holds the buffer pointer for each endpoint. Each
endpoint has two buffer registers, thus allowing double buffering as well as
buffer start address inside the on chip buffer memory . Each buffer register has
33
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 41
exactly the same definition and functionality. Control endpoint supports IN
and OUT operation both and it uses two buffer registers for different
operation and support single buffer for each direction communication.
Control endpoint uses Buffer0 for all OUT operation over it and buffer1 for
all IN operation over it.
This bit is used to control the buffer usage by the processor and device IP Core. When
the bit value of this bit is set to 1, processor can read or write to buffer0 memory space.
While the bit value is set to 0, device IP Core can use the buffer0 memory space to
store received data or to transmit data in response of IN token received for endpoint.
Default value after reset is 1 for this bit. For IN endpoint, processor resets this bit with
proper setting of buffer pointer as well assize,once it completes copying of data inside
the on chip buffer memory. For OUT endpoint, processor clears this bit to receive data
from host. Device uses the endpoint buffer if its used bit is cleared by the processor.
Device sets the used bit when it completes the usage of buffer. Device does not receive
or transmit data on endpoint if there is no any buffer available for given endpoint and
sends NACK token in response of IN or OUT operation.
1: Buffer is not available for the device and processor can process on buffer space as
well as can configure the buffer register for next operation.
0: Buffer is available for the device and processor can not processthe buffer space as
well as buffer register until the used bit is set by the device.
Note: The used bit inside the buffer registers of control endpoint is cleared when setup
packet receive operation starts inside the IP core.
Core Registers
System Level Solutions
January 2013
34
USB 2.0 (USB20SR) Device IP Core User Guide
Page 42
EPn_BUF
30:17RWBUF_SIZE
These bits of the register is used by the processor to inform the size of the buffer to
device IP Core. The processor can change value of these bits before clearing the used
bit of the register. Device IP Core uses this information, if used bit is cleared by
processor to check how many number of received bytes can be stored inside the buffer
or how many number of bytes can be transmitted from buffer in response of IN token.
Device updates the value of these bits as it progress with its use. e.g. device buffer
register is allocated with size 1024 for OUT endpoint and device receives a 512 byte
successfully. Then after sending ACK handshake it reduces the buffer size with 512
bytes (received number of bytes) space. Similarly for IN operation.
16:0RWBUF_PTR
These bits are used to inform the device about thestarting location of the allocated
buffer for endpoint. Processor decides the starting location of the endpoint buffer and
informs about that to the device IP Core through these bits. Device IP Core can store or
transmit data from starting location of the buffer up to its available size, if used bit of
buffer register is cleared. Device IP Core updates buffer pointer with the number of
bytes transmitted from buffer or received inside the buffer to keep track of starting location for the next data packet inside the buffer to transmit or receive if its usedbit is
cleared.
Value after Reset: FFFF0000h(Control EP)
Value after Reset: FFFFFFFFh(EP1:EP15)
1.All endpoints except control endpoint support double buffering or
reducing latency on data transmit or receive operation for device. Also
All endpoints except control endpoint supports only in one direction
communication depending on its CSR register configuration. It means
endpoint configured as an OUT endpoint can not support IN operation
over it. This support can be added as per the customer request.
2.For control endpoint, buffer0 is used for OUT operation while buffer1 is
used for IN endpoint.
3.During IN endpoint operation, the buffer act as write only register while
in OUT endpoint operation buffer act as read only register.
35
System Level Solutions
January 2013USB 2.0 (USB20SR) Device IP Core User Guide
Page 43
5. Core IOs
Table 5-1 list all the IOs of the USB20SR IP core.
Table 5-1. Core IOs
NameWidthDirectionDescription
Data8Bi-DiBi-Direction Data Line for ULPI interface
Dir1InDirection line of ULPI interface. Use the Fast output register,
Fast input register, Fast enable register setting from assignment
editor of Quartus II software Tool to implement control and data
registers of bidirectional lines inside the IO pin
Nxt1InNext line of ULPI interface
Stp1OutStop line for ULPI interface
Extern_reset1
Phy_cs_n1OutChipselect of ULPI Phy chip. Chipselect is active low signal
Phy_reset_n1OutReset pin of ULPI phy chip. Phy reset signal is active low signal
phy_clk1 InInput Phy clock (60 MHz)
In
External reset input of IP Core reset as well as ULPI Phy chip
reset. Reset input is active high signal
System Level Solutions
January 2013
36
USB 2.0 (USB20SR) Device IP Core User Guide
Page 44
6. Using USB20SR IP
in SOPC Builder
To use USB20SR Device IP core in SOPC Builder follow the steps below:
1.Running usb20sr_<licensetype>_v<version #>.exe will automatically
place the USB20SR component into SOPC Builder GUI. You can see
that USB20SR component is now added in the final view of the SOPC
builder system. See
Figure 6-1.
Figure 6-1.USB20SR Device IP Core in SOPC Builder
System Level Solutions
January 2013
37
USB 2.0 (USB20SR) Device IP Core User Guide
Page 45
Using USB20SR IP in SOPC Builder
2.Since the core is a slave, there must be an Avalon master. Usually, this
master is the Nios processor. Using the SOPC builder tool, inclu de the
Nios processor (must have the Nios development kit). Then add any
other peripherals required for the final design and assign the base
address and irqs.
To generate complet e reference design from scratch refer tutorial of design
from scratch if you are new to SOPC builder tool.
For further reference, refer Core Registers Section.
System Level Solutions
January 2013
38
USB 2.0 (USB20SR) Device IP Core User Guide
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.