Description

XPS_FX2 is a communication core to interface Xilinx Microblaze soft processor and a popular USB High Speed microcontroller Cypress CY7C68013A (also known as EzUSB FX2).

The XPS_FX2 supports 8bit Slave FIFO mode of operation on FX2 side. The FX2 has 4 endpoints with 2kB buffers (EP2, EP4, EP6, EP8).

The FX2 firmware was designed to support 4 high speed slave FIFOs: 3x TX (to PC, EP2-4-6), 1x RX (from PC, EP8).

The EP2-4-6 are FPGA outputs and EP8 is FPGA input.

This asymmetry is a consequence of the core being developed for data streaming to the PC (DAQ boards,cameras…).

The XPS_FX2 core side is driven by 48MHz IFCLK which is provided by FX2. The other side is driven by PLB clock and two separate clock signals for the data FIFOs.

The FIFOs can be accessed with PLB bus and/or through direct high speed FIFO ports.

The PLB bus FIFO access is only possible if the PLB clock matches FIFO clock.

Maximal supported bandwidth is normally limited by

Pin Name

FPGA DirectionFX2 directionDescriptionIn the reference design case (1)
 FD[7:0] Bidirectional BidirectionalFD[0:7] are used for byte data transfer
between FPGA and USB FX2 μC.

If the custom IP blocks

  • XPS_FX2 (FX2 microcontroller ↔ FPGA) and

  • XPS_NPI_DMA (FPGA  ↔ DRAM memory)

and MicroBlaze API Commands (MB Commands)

are used, data bytes array could be transfered between

  • TE USB FX2 module's DRAM (MicroBlaze's software) and
  • host computer's memory (host computer's software)
FD[7:0] bus pins: FPGA <-> USB FX2 microcontroller connection;

(1) Reference design case: Logic Architecture Layer = Reference Architecture Layer and reference USB FX2 μC firmware used

 

System integration block scheme

The XPS_FX2 has 4 interfaces:

  • USB FX2 8-bit wide slave FIFO interface synchronous to IFCLK offering 48MB/s peak bandwidth.
  • Xilinx PLBv4.6 created with IPIF wizard for access to 9 32-bit registers. These registers control the whole peripheral.
  • Proprietary synchronous 32-bits wide FIFO_OUT bus used for data streaming directly from receive FIFO. The port is synchronous to RX_FIFO_Clk.
  • Proprietary synchronous 32-bits wide FIFO_IN bus used for data streaming directly to transmit FIFO. The port is synchronous to TX_FIFO_Clk.

Peripheral internal structure block scheme

XPS_FX2 Core Design Parameters

Feature/DescriptionParameter NameAllowable Values

Default Value

VHDL Type

  System Parameters

Target FPGA family

 

C_FAMILYspartan3, spartan3e,

spartan3a,

spartan3adsp,

spartan3an, virtex2p,

virtex4, qvirtex4,

qrvirtex4, virtex5

virtex5string
PLB Parameters
PLB base addressC_BASEADDRValid AddressNonestd_logic_vector
PLB high addressC_HIGHADDRValid AddressNonestd_logic_vector

PLB least significant address bus width

C_SPLB_AWIDTH3232integer
PLB data widthC_SPLB_DWIDTH32, 64, 12832integer

Shared bus topology

C_SPLB_P2P0 = Shared bus topology0integer

PLB master ID bus Width

C_SPLB_MID_WIDTH

log2(C_SPLB_NUM_

MASTERS) with a
minimum value of 1

1integer
Number of PLB mastersC_SPLB_NUM_MASTERS1 - 161integer

Width of the slave data bus

C_SPLB_NATIVE_DWIDTH3232integer
Burst supportC_SPLB_SUPPORT_BURSTS0 = No burst support0integer
XPS_FX2 Parameters
Size of Transmit FIFOC_TX_FIFO_KBYTE2, 4, 8,16,322integer
Size of Receive FIFOC_RX_FIFO_KBYTE0, 22integer
Using Address FIFO (1)C_USE_ADDR_FIFO0 (not working)0integer

Shift transmit FIFO clock by 180 degrees (2)

C_TX_FIFO_CLK_1800, 10integer
XPS_FX2 Core Design Parameters

(1) Address FIFO was designed to avoid FIFO draining before the EP ADDRESS changing. Will be fixed in further releases.

(2) Set to 1 only if the user experience 8-bit data shifting after a received packet of data. Normally set to 0.

XPS_FX2 Core I/O Signals

NameInterfaceI/O

Initial State

Description

ChipScope[0:31]

-O-Debug port
USB_IFCLK-I-USB 48MHz clock
USB_SLRD-O0USB Data Read strobe
USB_SLWR-O0USB Data Write strobe

USB_FLAGA

-I-

USB programmable status flag (not used)

USB_FLAGB-I-USB TX FIFO full flag
USB_FLAGC-I-USB TX FIFO empty flag
USB_FLAGD-I-USB RX FIFO empty flag

USB_SLOE

-O0

Toggles FX2 IO buffer (1=read from USB)

USB_PKTEND

-O0

Commences current packet (if smaller than 512 bytes)

USB_FIFOADR[1:0]

-O0

Selects USB endpoint:

  • "00"=EP2,
  • "01"=EP4,
  • "10"=EP6,
  • "11"=EP8
USB_FD[7:0]-I/O0USB tristate data Bus
TX_FIFO_Clk-I-TX FIFO clock
RX_FIFO_Clk-I-RX FIFO clock
TX_FIFO_DIN[0:31]FIFO_INI-TX FIFO input data
TX_FIFO_VLDFIFO_INI-TX FIFO data valid strobe
TX_FIFO_RDYFIFO_INO0TX FIFO is ready flag
RX_FIFO_DOUT[0:31]FIFO_OUTOzerosRX FIFO output data
RX_FIFO_VLDFIFO_OUTO0RX FIFO data valid strobe
RX_FIFO_RDYFIFO_OUTI-RX FIFO is ready flag
IP2INTC_Irpt-O0Processor interrupt
OTHERS ARE PLBv4.6 SIGNALSPLBv4.6---
XPS_FX2 I/O Signal Descriptions

Writing and reading to/from FIFO_IN and FIFO_OUT ports

The point to point unidirectional buses use simple handshaking protocol.

When (slave) “ready” signal is high the port is open for writing.

A write is performed when “valid” signal goes high. The “data” should be valid when valid signal is high. If “valid” signal goes high and the ready is low then the data are discarded.

The signals are updated on rising edge of clock.

The “valid” signal can be also continuous.

FIFO_IN port is ready when it is not under reset or being full.

If FIFO_OUT port is not ready then it will not send data ("valid" stays low and data stays in FIFO).

FIFO_OUT port latency to act upon "ready" goes low is 1 cycle.

FIFO high speed communication ports principle of operation

XPS_FX2 Core Registers

XPS_FX2 has a full access of a microprocessor to the core functionality through a 5 user 32-bit and 7 IPIF Interrupt registers attached to PLBv4.6 bus.

Base Address + Offset (hex)

Register Name

Access Type

Default Value (hex)

Description
XPS FX2 IP Core Grouping
C_BASEADDR + 00CRR/W0x00000000Control Register
C_BASEADDR + 04FTRR/W0x00000000FIFOs Threshold Register
C_BASEADDR + 08SRRead0x00000000Status Register
C_BASEADDR + 0CFWRR/W0x00000000FIFO Write Register
C_BASEADDR + 10FRRRead0x00000000FIFO Read Register
IPIF Interrupt Controller Core Grouping
C_BASEADDR + 200INTR_DISRRead0x00000000interrupt status register
C_BASEADDR + 204INTR_DIPRRead0x00000000interrupt pending register
C_BASEADDR + 208INTR_DIERWrite0x00000000interrupt enable register

C_BASEADDR + 218

INTR_DIIRWrite0x00000000

interrupt id (priority encoder) register

C_BASEADDR + 21C

INTR_DGIERWrite0x00000000

global interrupt enable register

C_BASEADDR + 220

INTR_IPISRRead0x00000000

ip (user logic) interrupt status register

C_BASEADDR + 228

INTR_IPIERWrite0x00000000

ip (user logic) interrupt enable register

XPS_FX2 Core Registers

The First (LSB) interrupt from user_logic is masked on the left!!

Details of XPS_FX2 Core Registers

The parts of the registers (or the whole registers) with a non-capital designation (e.g. wr_fifo_rst) are usually the names of the HDL signals connected to the described register.

Control Register (CR)

The Control Register is used to control basic peripheral functions. All the bit flags are assembled here.

BitsNameDescription Reset ValueDescription Reset ValueValid Value
31tx_fifo_rstTransmit FIFO reset00,1
30rx_fifo_rstReceive FIFO reset00,1
29tx_fifo_disableWhen '1' TX_FIFO_RDY='0'00,1
26-27usb_fifoadrUSB endpoint selection (1)0x0Valid Endpoints:
  • 0 = EP2
  • 1 = EP4
  • 2 = EP6
0-15pktend_timeoutPacket end timeout (2)0x00-32767
Control Register bits

Packet end timount and USB_PKTEND

(1) Endpoint EP8 is read only and is switched automatically when data arrives. To achieve maximal throughput use only one endpoint and prevent TX FIFO draining (TX FIFO empty should not occur).

(2) Packet end timeout timer automatically asserts USB_PKTEND signal when TX_FIFO is empty for a programmed number of cycles and current USB EndPoint FIFO is not empty.

Cycle timer is also reset when switched to EP8 – incoming data. The USB_PKTEND send current packet and enables the PC to receive packet smaller than 512 bytes. If user setup the timer properly then the packets are automatically send when there is no more data available in the TX_FIFO.

FIFOs Threshold Register (FTR)

This register is used to setup thresholds for interrupt triggering when FIFO occupancy reaches set number of words. For RX FIFO the prog_full flag goes high when number of words in a FIFO is higher than threshold. For TX FIFO the prog_empty flag goes high when number of words in a FIFO is lower than threshold.

The tx_fifo_threshold can have 9, 10 or 11 bits according to size of the TX_FIFO. This register is usually accessed using 16-bit writes.

FIFOs Threshold Register (FTR) bits
Status Register (SR)

In the status register the peripheral reports of the current status. The tx_fifo_count can have 9-13 bits according to size of the TX_FIFO. This register is usually accessed using 16-bit reads

 

BitsNameDescriptionReset Value
19-31tx_fifo_countTransmit FIFO occupancy in words0
18tx_fifo_overflowTransmit FIFO overflow flag0
17tx_fifo_fullTransmit FIFO full flag0
16tx_fifo_emptyTransmit FIFO empty flag1
7-15rx_fifo_countReceive FIFO occupancy in words0
3rx_fifo_prog_fullReceive FIFO programmable full flag0
2rx_fifo_underflowReceive FIFO underflow flag0
1rx_fifo_fullReceive FIFO full flag0
0rx_fifo_emptyReceive FIFO empty flag1
Status Register (SR) bits
FIFO Write Register (FWR)

Single beat write to this register puts a single word (4 bytes) to TX FIFO. For proper operation PLB clock frequency should be less or equal to TX_FIFO_Clk.

FIFO Read Register (FRR)

Single beat read from this register pops one word (4 bytes) from RX FIFO. For proper operation PLB clock frequency should be less or equal to RX_FIFO_Clk.

Interrupt enable/pending registers

With INTR_IPIER register the user can enable/disable peripheral interrupt sources. With INTR_IPISR the user can identify interrupt source. Writing a value to INTR_IPISR also clears interrupt.

"Ghost" interrupts

The user must make sure that triggered interrupts will be cleared in a consinstent way (single owner); the user (host computer's software) must only clear triggered interrupts. Otherwise the user will trigger "ghost" interrupts which were not triggered by peripheral, but the interrupt controller itself.

Writing 0x7 to INTR_DIER will enable IP interrupt sources and writing 0x80000000 to INTR_DGIER will enable global interrupt.

The image below presents a conection of user logic interrupt to INTR_IPIER and INTR_IPISR.

Interrupt enable/pending registers

Programming model

By setting control register (CR) make sure that user not override the previously set bits.

Example 1

Resetting the TX_FIFO:

1. Write 0x00000001 to CR

2. Write 0x00000000 to CR

Example 2

Resetting the RX_FIFO:

1. Write 0x00000002 to CR

2. Write 0x00000000 to CR

Example 3

Setting the endpoint address to EP4

1. Write 0x00000010 to CR

Example 4 (if Reference Design is used): test XPS_NPI_DMA and XPS_FX2 using MB Commands 

XPS_NPI_DMA and XPS_FX2 custom IP blocks are both necessary to connect  (throgh USB connection) host computer's software  and TE USB FX2 module's DRAM.

The MB Commands FX22MB_REG0_START_RX, FX22MB_REG0_START_TX, FX22MB_REG0_STOP are used for data throughput and integrity test.

MB Commands require the XPS_I2C_SLAVE custom IP block and a proper FX2 interrupt handler (i2c_slave_int_handler() function in interrupt.c running on MicroBlaze); the FX2 interrupt handler is called to handle the signal interrupt xps_i2c_slave_0_IP2INTC_Irpt. The i2c_slave_int_handler() function actually execute the I2C delivered MB Command.

Write test should be executed before read test; otherwise the read test will fail.

  • No labels