Documente Academic
Documente Profesional
Documente Cultură
c
c
i
i
This block handles the low level USB protocol and signaling. This
includes features such as; data serialization and deserialization, bit stuffing
and clock recovery and synchronization. The primary focus of this block is
to shift the clock domain of the data from the USB 2.0 rate to one that is
compatible with the general logic in the ASIC.
c
c
c
c
c
c
c
c
c
c
c
c
(
This section provides descriptions of each of the blocks shown in
Figure 2.1. These blocks represent high level functionality that is required to
exist in the Macro cell.
This module generates the appropriate internal clocks for the UTM
and the CLK output signal. All data transfer signals are synchronized with
the CLK signal.
The UTM vendor determines the frequency of the external crystal.
The Clock Multiplier circuit and the External Crystal must meet the
requirements defined in the USB 2.0 specification.
After the release of SuspendM, the CLK signal generated by the
transceiver must meet the following requirements:
1) Produce the first CLK transition no later than 5.6 ms after the
negation of SuspendM.
2) The CLK signal frequency error must be less than 10% (±6.00 MHz)
+,
In HS mode there is one CLK cycle per bit time. The frequency of
CLK does not change when the UTMI is switched between HS to FS modes.
In FS mode there are 5 CLK cycles per FS bit time, typically 40 CLK cycles
per FS byte time. If a received byte contains a stuffed bit then the byte
boundary can be stretched to 45 CLK cycles, and two stuffed bits would
result in a 50 CLK delay between bytes.
Figure 2.2 shows the relationship between CLK and the receive data
transfer signals in FS mode. RXActive "frames" a packet, transitioning only
c
c
c
c
c
c
c
c
c
of +/-500 ppm. When the error is calculated over the maximum packet size
up to +/- 12 bits of drift can occur. The elasticity buffer is filled to a
threshold prior to enabling the remainder of the down stream receive logic.
This block may be integrated into the DLL block. An example that will meet
these requirements is a 24 bit deep, 1 bit wide FIFO with a threshold set at
the midpoint. Overflow or underflow conditions detected in the elasticity
buffer can be reported with the RXError signal.
.
The bulk of the logic in the transceiver can be used with HS or FS
operations. The Mux block allows the data from the HS or FS receivers to be
routed to the shared receive logic. The state of the Mux is determined by the
XcvrSelect input.
.),+(
Figure2.4 shows the Transmit Shift and Hold Register.This module is
responsible for reading parallel data from the parallel application bus
interface upon command and serializing for transmission over USB. This
module consists of an 8-bit primary shift register for parallel/serial
conversion and an 8-bit Hold register used to buffer the next data to
serialize.
Ô /((),+(
c
c
c
0
This is a standard USB 1.X compliant serial NRZI encoder module,
which can operate at full-speed or high-speed USB data rates. Whenever a
bit µ1¶ is encountered in the data stream, it is negated. A bit µ0¶ is
transmitted as it is depend on the Operational Mode.
(
!
In order to ensure adequate signal transitions, bit stuffing is employed
when sending data on USB. A zero is inserted after every six consecutive
ones in the data stream before the data is NRZI encoded, to enforce a
transition in the NRZI data stream. Bit stuffing is enabled beginning with the
SYNC Pattern and through the entire transmission. The data "one" that ends
the SYNC Pattern is counted as the first one in a sequence. In FS mode bit
stuffing by the transmitter is always enforced, without exception. If required
by the bit stuffing rules, a zero bit is inserted even after the last bit before the
TXValid signal is negated.
After 8 bits are stuffed into the USB data stream TXReady is negated
for one byte time to hold up the data stream on the DataIn bus. Figure 2.5
show the timing relationship between TXReady and DataIn.
c
c
c
The Byte CLK in Figure 2.5 is identical to the CLK signal in HS mode and
CLK/40 in FS mode.
.),+((
Figure 2.6 shows the receive shift and hold register. This module is
responsible for converting serial data received from the USB to parallel data.
This module consists of an 8-bit primary RX Shift Register for serial to
parallel conversion and an 8-bit RX Hold Register used to buffer received
data bytes and present them to the Data Out bus.
Figure 2.6: Rx Shift/Hold Register
0
This is a standard USB 1.X compliant serial NRZI decoder module,
which can operate at FS or HS USB data rates. The data received on DP,
DM lines is NRZI(1) decoded and it is sent to the bit unstuff module.
(
!
This is a standard USB 1.X compliant serial bit unstuff module, which
can operate at FS or HS USB data rates. The bit unstuff logic is a state
machine, which strips a stuffed 0 bit from the data stream and detects bit
stuff errors. In FS mode bit stuff errors assert the RXError signal. In HS
mode bit stuff errors are used to generate the EOP signal so the RXError
signal is not asserted.
c
c
c
The bit rate on USB is constant, however the bit rate as presented by
the UTMI to the SIE is slightly reduced due to the extraction of inserted 1
bits. Normally a byte of data is presented on the DataOut bus for every 8 bits
received, however after eight stuffed bits are eliminated from the data stream
a byte time is skipped in the DataOut stream. Figure 2.7 shows how
RXValid is used to skip bytes in the DataOut byte stream.
Figure 2.7: Receive Timing for Data with after Unstuffing Bits
Table 2.1: System Interface Signals
c
c
c
!&
Conceptually, there is a "CLKUsable" signal, internal to the UTM,
which blocks any transitions of CLK until it is "usable". This "CLKUsable"
signal is also used to switch the Line State output between CLK
synchronized and combinatorial signaling.
(
There are 3 possible implementations for a UTMI device: HS/FS, FS
Only, or LS Only. The HS/FS version has 4 interface options: 16-bit
unidirectional, 8-bit unidirectional, 16-bit bidirectional/8-bit unidirectional,
and 8-bit bi-directional. In each case, when a 16-bit option is selected CLK
is at 30 MHz, and when an 8-bit option is selected CLK is at 60 MHz.
The 16-bit bidirectional/8-bit unidirectional uses the "DataBus16_8"
signal to switch between them. This signal also switches the CLK frequency.
The FS Only, or LS Only implementations only support 48 MHz and
6 MHz clocks, respectively, and always use 8 bit interfaces (either 8-bit
unidirectional or 8-bit bi-directional).
2
XcvrSelect controls a number of transceiver related elements, it
selects the receiver (source for the Mux block) in the receive data path. It is
used as a gating term for enabling the respective HS or FS Transmit Driver.
Switch internal UTM clocks to shared logic.
Term Select controls a number of termination related elements.
In HS mode the FS Driver is forced to assert an SE0 on the USB,
providing the 50 Ohm termination to ground and generating the HS Idle
state on the bus.
c
c
c
(-
Line State must be used by the SIE for the precise timing of packet
data on the DP/DM signal lines. The SIE uses Line State transitions to
identify the beginning and end of receive or transmit packets on the bus.
Line State represents bus activity within 2 or 3 CLK times of the actual
events on the bus.
+
When XcvrSelect and TermSelect are in HS mode, the Line State
transition from the Idle state (SE0) to a non-Idle state (J) marks the
beginning of a packet on the bus. The Line State transition from a non-Idle
state (J) to the Idle state (SE0) marks the end of a packet on the bus.
When XcvrSelect and TermSelect are in FS mode, the LineState
transition from the J State (Idle) to a K State marks the beginning of a packet
on the bus. The SIE must then wait for the end of the packet. The LineState
transition from the SE0 to the J-State marks the end of a FS packet on the
bus.
Ô 1 Ô(
c
c
c
magnetic field will be created around the line. This magnetic field may
affect the near by lines. To compensate the affect of magnetic field, a bit µ0¶
i.e, -5V is present on DM line. The net affect of the magnetic field will be
zero. Thus the noise is reduced.
Ô 1 1(
The table 2.3 gives the summary of data interface signals those are
referred by the SIE and the UTMI while data is being transmitted. Each of
the signals given in the table 2.3 is clearly described below.
Table 2.3: Data Interface Signals (Transmit)
c
c
c
The table 2.4 gives the summary of data interface signals those are
referred by the SIE and the UTMI while data is being received. Each of the
signals given in the table 2.4 is clearly described below.
Table 2.4: Data Interface Signals (Receive)
c
c
c
c
c
c
c
c
c
If TX Valid is asserted (1) then the signals Data0-7 accepts transmit data
from the SIE. If TX Valid is negated (0) then the signals Data0-7 present
received data to the SIE.
Figure 2.9: 8-Bit Interface Entity Diagram
c
c
c
1 9"-
The UTMI is divided into two modules, which are the transmitter
module and the receiver module.
1 i)(
(
The transmitter module of UTMI has been implemented by considering
the following specifications.
Ý The SYNC pattern µ01111110¶ has to be transmitted immediately after
the transmitter is initiated by the SIE.
Ý After six consecutive µ1¶s occur in the data stream, a zero to be inserted.
Ý The data should be encoded using Non Return to Zero Invert on 1(NRZI
-1) encoding technique.
Ý The EOP pattern two single ended zeros (D+ and D- lines are carrying
zero for two clock cycles) and a bit 1 have to be transmitted after each
packet or after SIE suspends the transmitter.
The behavior of the Transmit State Machine given by USB 2.0
specifications is described and illustrated in Fig.3.1
The Reset signal forces the state machine into the Reset state which
negates TX Ready. When Reset is negated the transmit state machine will
enter the TX Wait state.
In the TX Wait state, the transmit state machine looks for the assertion of
TX Valid. When TX Valid is detected, the state machine will enter the Send
SYNC state and begin transmission of the SYNC pattern.
When the transmitter is ready for the first byte of the packet (PID), it will
enter the TX Data Load state, assert TX Ready and load the TX Holding
Register. The state machine may enter the TX Data Wait state while the
SYNC pattern transmission is completed.
c
c
c
TXReady is used to throttle transmit data. The state machine will remain
in the TX Data Wait state until the TX Data Holding register is available for
more data. In the TX Data Load state, the state machine loads the Transmit
Holding register. The state machine will remain in the TX Data Load state as
long as the transmit state machine can empty the TX Holding Register
before the next rising edge of CLK.
When TXValid is negated the transmit state machine enters the Send
EOP state where it sends the EOP. While the EOP is being transmitted
TXReady is negated and the state machine will remain in the Send EOP
state. After the EOP is transmitted the Transmit State Machine returns to the
TX Wait state.
The summary of the above description is given below.
c
c
c
c
c
c
1 i i
(
The following sections provide examples of FS SYNC and EOP
generation by the Transmit State Machine.
1 i i i
-
The assertion of the TXValid signal initiates packet transmission.
With the bus initially in the Idle state ( 'J' state), a SYNC pattern
("KJKJKJKK") in its NRZI encoding is generated on the USB. To generate
this pattern the SYNC data pattern (0x80) is forced into the Transmit Data
Shift Register by the Transmit State Machine. TXValid will remain asserted
if valid packet data bytes are available to be loaded into the Transmit Data
Holding Register.
c
c
c
The CLK signal is marked "not to scale" because cycles are dropped
in Figure 3.3 to show how CLK edges align with the byte boundaries of the
FS data transmission.
1 i i Ô
-
In FS mode, a single ended zero (SE0) state is used to indicate EOP
and a 'J' state indicates Idle. The SE0 state is asserted for 2 bit times then a 'J'
state is asserted for 1 bit time which is shown in figure 3.4.
Negating the TXValid signal initiates the FS EOP process; bit stuffing
will cease, the bit stuff state machine will be reset, and the FS EOP (two bit
times of SE0 followed by a single 'J' bit) will be asserted on the bus.
TXReady is negated after TXValid is detected false and cannot be
reasserted (dashed line) until after the EOP pattern and 'J' state bit are
transmitted. The delay between the assertion of TXValid and the first
assertion of TXReady is UTM implementation dependent.
c
c
c
c
c
c
1 i Ô Ô +-
The negation of TXValid will initiate the EOP sequence in the
Transmit State Machine which is shown in figure3.6.
TXReady is negated for at least one byte time while the EOP pattern is being
transmitted.
TXReady is negated after TXValid is detected false and cannot be
reasserted (dashed line) until after the EOP pattern is transmitted. The delay
between the assertion of TXValid and the first assertion of TXReady is
UTM implementation dependent.
c
c
c
c
c
c
When the EOP is detected the state machine will enter the Strip EOP
state and negate RXActive and RXValid. After the EOP has been stripped
the Receive State Machine will reenter the RX Wait state and begin looking
for the next packet.
If a Receive Error is detected, the Error State is entered and RXError
is asserted. Then either the Abort 1 State is entered where RXActive,
RXValid, and RXError are negated, or the Abort 2 State is entered where
only RXValid, and RXError are negated. The Abort 1 State proceeds
directly to the RX Wait State, while Abort 2 State proceeds to the Terminate
State after an Idle bus state is detected on DP and DM. The Terminate State
proceeds directly to the RX Wait State.
When the last data byte is clocked off the DataOut bus the SIE must
also capture the state of the RXError signal. The description of the receiver
given above is summarized below.
c
c
c
Figure 3.9 shows RX valid and RX error asserted at the same time.
The state of RX valid is a function of data flow control, while RX error is
asserted when an error is detected.
The present UTMI has been designed according to the fallowing
specifications provided by the USB2.0 protocol.
Ý SYNC and End Of Packet (EOP) generation by the transmitter.
Ý Parallel to Serial conversion of data by the transmitter.
Ý Enabling or disabling the bit stuff and NRZI encoder depends on the
operational mode.
Ý SYNC and EOP detection by the receiver.
Ý Receive error reporting.
Ý Suspension of the transceiver by the SIE.
1 /)(
The receiver module is designed by considering all the above
specifications. VHDL is used to design the receiver module. The receiver
module of the UTMI consists of various blocks such as SYNC detector,
NRZI decoder, bit un stuffer, receive shift and hold Register and EOP
detector.
A receive state machine is developed by considering all the states
given by USB 2.0 receive state machine. Initially the receiver is at Reset
state where the reset signal is high and RX active and RX valid signals are
low. If reset signal goes low the state of the receiver is changed to RX wait
state where it is waiting for SYNC pattern.
c
c
c
1 / i:
When the receiver detects encoded SYNC pattern ³01010100´, the
Receive state machine will enter into strip sync state where the SYNC
pattern is stripped off. To detect the SYNC pattern a state machine is
developed. It checks every bit for every rising edge of the clock. If the
pattern is detected, a signal called sync detected is enabled. This signal is
checked by the Receive state machine. If the signal is high, the Receive state
machine will enter into strip sync state where RX active signal is asserted
and the state machine will enter into RX data state.
1 / Ô0
The received data on DP, DM lines are NRZI decoded. The NRZI
Decoder simply XOR the present bit with the provisionally received bit.
During NRZI decoding, the receive state machine is in RX wait state.
1 / 1(
The Bit Unstuffer examines each bit of the stream. If a zero is
detected after six consecutive µ1¶s the zero bit is deleted. For this purpose, a
state machine is designed which is invoked at every rising edge of the clock.
The state of the machine will change to the next state until six consecutive
µ1¶ and a bit µ0¶ or detected. Otherwise the state of machine will change to
its initial state. During bit Unstuffing, the receive state machine is in RX
data wait state. After the zero bit has been unstuffed, the receive state
machine will enter into RX data state where it asserts RX valid signal.
If a zero is not detected after six consecutive µ1¶ the state machine
asserts a signal called rx_error. This signal is checked by the receive state
machine for every clock. If this signal is high, then the receive state machine
will enter into RX error state where RX error signal is asserted. At the next
c
c
c
rising edge of the clock, the receive state machine will enter into the abort1
state where RX active, RX valid and RX error signals are negated.
1 / /)+(
The serial data received from the bit Unstuffer is shifted into the
receive shift register. After the shift Register is full, it is held there for one
clock duration and then the data is placed on to the data out bus. This 8-bit
data is sampled by the SIE at the next rising edge of the clock during
shifting, the receive state machine is in RX data wait state. During holding,
the receive state machine is in RX data state where it asserts RX valid signal.
1 / 4-
A state machine is developed for EOP detection, which is invoked at
every rising edge of the clock. When two single ended zeroes fallowed by a
µJ¶ state is detected, it asserts a signal called eop_detect which is checked by
the Receive state machine at every rising edge of the clock. When this signal
is high, the receive state machine will enter in to Strip eop state where the
EOP pattern is stripped off and RX active, RX valid signals are negated. At
the next rising edge of the clock. The Receive state machine will enter into
the RX wait state.
c
c
c
/ !"!
The Transmitter module and the Receiver modules of the UTMI are
designed with VHDL and they are simulated in the Model Sim 6.0
simulator. The fallowing sections give the source code, test bench and
simulation results for each module.
The UTMI is designed by combining these two modules and it is
simulated in the Model Sim 6.0. The source code, test bench and simulation
results are given in the fallowing sections.
/ i
(
library Ieee;
use Ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity tx_sm is
port( reset,txvalid:in std_logic;
clk : in std_logic;
txready,txdp,txdm: out std_logic;
dataln : in std_logic_vector(7 downto 0));
end tx_sm;
architecture tx_sm_arch of tx_sm is
signal eop_done,sync_enable,load_data,load_eop: std_logic;
signal txhldreg:std_logic_vector(7 downto 0);
signal
bitstuff_enable,serial_out,serial_bs,serial_nrzi,shift_done:std_logic;
signal count : std_logic_vector(2 downto 0);
signal eop_cnt:std_logic_vector(1 downto 0);
signal eop_start:std_logic;
type st is (idle,txwait,send_sync,data_load,data_wait,send_eop);
signal state : st ;
begin
process( clk)
begin
if clk='1' and clk'event then
if reset ='0' then
case state is
c
c
c
55 ((;()
process(clk)
begin
if clk='1' and clk'event then
if(reset='0')then
if(load_data='1') then
txhldreg<=dataln;
else if(load_data='0' )then
serial_out<=txhldreg(7);
txhldreg<= txhldreg(6 downto 0) & '0';
end if;
else
txhldreg<="01111110";
end if;
end if;
end process;
55 ((
process(clk)
begin
if clk='1' and clk'event then
if(reset='0')then
if(sync_enable='1' or load_data='0')then
count<= count + "001";
if(count="111" )then
shift_done<='1';
else shift_done<='0';
end if;
end if;
else
count<="000";
shift_done<='0';
end if;
end if;
end process;
55 ((7(
process(clk)
begin
if clk='1' and clk'event then
if(reset='0')then
if (bitstuff_enable='1') then
c
c
c
serial_bs<='0';
else serial_bs<= serial_out;
end if;
else serial_bs<='0';
end if;
end if;
end process;
55 ((77(
process(clk)
type seq_state is (s0,s1,s2,s3,s4,s5);
variable st : seq_state;
begin
if clk='1' and clk'event then
if(reset='0')then
if(state=data_wait) then
case st is
when s0 => bitstuff_enable<='0';
if (serial_out ='1') then st:= s1;
else st:=s0;
end if;
when s1 => bitstuff_enable<='0';
if (serial_out ='1') then
st:= s2;
else st:=s0;
end if;
when s2 => bitstuff_enable<='0';
if (serial_out ='1') then
st:= s3;
else st:=s0;
end if;
when s3 => bitstuff_enable<='0';
if (serial_out ='1') then
st:= s4;
else st:=s0;
end if;
when s4 => bitstuff_enable<='0';
if (serial_out ='1') then
st:= s5;
else
st:=s0;
c
c
c
end if;
when s5 => if (serial_out ='1') then
bitstuff_enable<='1';
st:= s0;
else st:=s0;
end if;
when others=> bitstuff_enable<='0';
st:=s0;
end case;
else
bitstuff_enable<='0';
end if;
else
bitstuff_enable<='0';
st:=s0;
end if;
end if;
end process;
55 ((;
process(clk)
begin
if clk='1' and clk'event then
if(reset='0')then
if(state=send_eop)then
if (load_eop='1') then
if(eop_cnt <="01" )then
serial_nrzi<='0';
eop_cnt<=eop_cnt+"01";
eop_done<='0';
eop_start<='1';
else
serial_nrzi<='1';
eop_done<='1';
eop_cnt <="00";
eop_start <=¶0¶;
end if;
end if;
else if(serial_bs='1') then
serial_nrzi<=not serial_nrzi;
else
c
c
c
serial_nrzi<= serial_nrzi;
end if;
end if;
else
eop_cnt <="00";
serial_nrzi<='0';
eop_done<='0';
eop_start<='0';
end if;
end if;
end process;
55 ((
process(clk)
begin
if clk='1' and clk'event then
if(reset='0')then
if(load_eop='0')then
txdp<=serial_nrzi;
txdm<= not serial_nrzi;
else if(eop_start='1')
txdp<=serial_nrzi;
txdm<=serial_nrzi;
else
txdp<=serial_nrzi;
txdm<= not serial_nrzi;
end if;
end if;
end if;
end if;
end process;
end tx_sm_arch;
/ Ô()(
library Ieee;
use Ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity tx_sm_tb is
end tx_sm_tb;
c
c
c
end if;
end process;
end tx_sm_arch_tb;
The figure 4.10 shows when reset_i is low and txvalid_i signal is
asserted by the SIE, Encoded sync pattern 01010100 is sent on to the
txdp_i line. The opmode 00 shows that the transmitter is in normal mode and
the data 10110100 is NRZI encoded and sent on to the txdp_i line after sync
has been transmitted after txreday_i goes high. The txready_i signal goes
low immediately after the SIE data loaded into TXhold register. When
reset_i is high the transmitter is in reset state.
c
c
c
The figure 4.11 shows that when reset_i is low and txvalid_i signal is
high and opmode is ³10´ NRZI encoding is disabled. The data 10111110 is
transmitted as it is on to txdp_i and txdp_i is lines. After the transmission of
data on to the serial bus, the transmitter asserts txready_i signal.
c
c
c
The figure 4.13 shows that when reset_i is low and txvalid_i is de
asserted by SIE, the EOP pattern (two SE0s and one J state) is transmitted on
to txdp_i, txdm_i lines after the
EOP pattern is transmitted, the transmitter enters into TX wait state
where it is waiting for the SYNC pattern.
/ /
library Ieee;
use Ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity rx_sm is
port( reset,rxdp,rxdm:in std_logic;
rxvalid,rxactive,rxerror_o:out std_logic;
clk : in std_logic;
data_out: out std_logic_vector(7 downto 0));
end rx_sm;
architecture rx_sm_arch of rx_sm is
signal eop_detect,sync_detect,rxerror_bs:std_logic;
signal sync_error,j,k,se0:std_logic;
signal rxhldreg:std_logic_vector(7 downto 0);
signal unstuff_enable,shift_done,serial_in:std_logic;
signal count : std_logic_vector(3 downto 0);
signal rxerror:std_logic;
signal temp: std_logic;
type st is
(rx_wait,strip_sync,rx_data,rxdata_wait,strip_eop,rx_
error_st, abort);
signal state_m : st;
begin
j<= rxdp and not(rxdm);
k<= not(rxdp) and rxdm;
se0<= not(rxdp) and not(rxdm);
rxerror_o <= rxerror;
--process for RECEIVE STATE MACHINE
process( clk,reset)
begin
if clk='1' and clk'event then
c
c
c
st:=s4;
else st:=s0;
sync_error<='1';
sync_detect<='0';
end if;
when s4 => if(k='1')then
st:=s5;
else st:=s0;
sync_error<='1';
sync_detect<='0';
end if;
when s5 => if(j='1')then
st:=s6;
else st:=s0;
sync_error<='1';
sync_detect<='0
end if;
when s6 => if(k='1')then
st:=s7;
else st:=s0;
sync_error<='1';
sync_detect<='0';
end if;
when s7 => if(k='1')then
st:=s0;
sync_detect<='1';
sync_error<='0';
else st:=s0;
sync_error<='1';
sync_detect<='0';
end if;
when others=> st:=s0;
sync_detect<='0';
end case;
end if;
else
st:=s0;
sync_detect<='0';
sync_error<='0';
end if;
c
c
c
end if;
end process;
--process for eop detection //2 seo's - 1j
process(clk)
type state is(s0,s1,s2);
variable st: state;
begin
if clk='1' and clk'event then
if(reset='0')then
if(state_m=rxdata_wait or state_m=rx_data)then
case st is
when s0 => if se0='1' then
st:=s1;
else
st:=s0;
eop_detect<='0';
end if;
when s1 => if se0='1' then
st:=s2;
else
st:=s0;
eop_detect<='0';
end if;
when s2 => if j ='1' then
st:=s0;
eop_detect<='1';
else
st:=s0;
eop_detect<='0';
end if;
when others=> st:=s0;
eop_detect<='0';
end case;
else
eop_detect<='0';
end if;
else
st:=s0;
eop_detect<='0';
end if;
c
c
c
end if;
end process;
--process for NRZI DECODING
process(clk,rxdp)
begin
if clk='1' and clk'event then
if (reset='0')then
if(state_m=rxdata_wait)then
if( rxdp='1'and temp ='1')then
serial_in<='0';
temp<=rxdp;
else if(rxdp='0'and temp='1')then
serial_in<='1';
temp<=rxdp;
else if(rxdp='1'and temp ='0')then
serial_in<='1';
temp<=rxdp;
else if(rxdp='0'and temp ='0')then
serial_in<='0';
temp<=rxdp;
end if;
end if;
end if;
end if;
end if;
else
serial_in<='0';
temp<='0';
end if;
end if;
end process;
--process for bit RX ERROR REPORT
Process (clk)
type state is(s0,s1,s2,s3,s4,s5,s6);
variable st:state;
begin
if clk='1' and clk'event then
if (reset='0') then
if(state_m=rxdata_wait or state_m=rx_data)then case st is
when s0 => rxerror_bs<='0';
c
c
c
unstuff_enable<='0';
if (serial_in ='1')then
st:=s1;
else
st:=s0;
end if;
when s1 => rxerror_bs<='0';
unstuff_enable<='0';
if (serial_in ='1')then
st:=s2;
else
st:=s0;
end if;
when s2 => rxerror_bs<='0';
unstuff_enable<='0';
if (serial_in ='1')then
st:=s3;
else
st:=s0;
end if;
when s3 => rxerror_bs<='0';
unstuff_enable<='0';
if (serial_in ='1')then
st:=s4;
else
st:=s0;
end if;
when s4 => rxerror_bs<='0';
unstuff_enable<='0';
if (serial_in ='1')then
st:=s5;
else
st:=s0;
end if;
when s5 => rxerror_bs<='0';
unstuff_enable<='0';
if (serial_in ='1')then
st:=s5;
else
st:=s0;
c
c
c
end if;
when s6 => if (serial_in ='0')then
unstuff_enable<='1';
rxerror_bs<='0';
st:=s0;
else
rxerror_bs<='1';
unstuff_enable<='0';
st:=s0;
end if;
when others=> st:=s0;
end case;
else
rxerror_bs<='0';
end if;
else
st:=s0;
rxerror_bs<='0';
unstuff_enable<='0';
end if;
end if;--process
end process;
--process for RX REGISTER loading
process(clk)
begin
if clk='1' and clk'event then
if(reset='0') then
if(state_m=rxdata_wait ) then
if(unstuff_enable='0')then
rxhldreg(7 downto 0)<= rxhldreg(6 downto 0) &
serial_in;
else
rxhldreg(7 downto 0)<= rxhldreg(7 downto 0);
end if;
end if;
if(shift_done='1')then
data_out<= rxhldreg;
end if;
else
c
c
c
c
c
c
signal rxvalid_o,rxactive_o,rxerror_o:
std_logic;
signal clk_i : std_logic:='0';
signal data_out:std_logic_vector(7 downto 0);
signal cnt:std_logic_vector(7 downto 0);
signal count:std_logic_vector(3 downto 0);
signal data_count:std_logic_vector(3 downto 0);
signal eop_count:std_logic_vector(1 downto 0);
signal data_in:std_logic_vector(7 downto 0);
signal eop_start:std_logic;
component rx_sm
port( reset,rxdp,rxdm:in std_logic;
rxvalid,rxactive,rxerror_o:out std_logic;
clk : in std_logic;
data_out : out std_logic_vector(7 downto 0));
end component;
begin
instance: rx_sm
port map( reset=>reset_i,
rxdp=>rxdp_i,
rxdm=>rxdm_i,
rxvalid=>rxvalid_o,
rxactive=>rxactive_o,
rxerror_o=>rxerror_o,
clk=>clk_i,
data_out=>data_out);
clk_i<= not clk_i after 50 ns;
reset_i<= '0' after 200 ns;
rxdp_i<=rxdp_i;
rxdm_i<=not(rxdp_i) when data_count <=´1010´
and eop_start=¶0¶ else
rxdp_i;
process(clk_i)
begin
if clk_i='1' and clk_i'event then
if(reset_i='1')then
eop_start<=¶0¶;
c
c
c
cnt<="01010100";
count<="0000" ;
data_in<="10110101";
data_count<="0000";
eop_count<="00";
else if(count<="0111")then
rxd_i<=cnt(7);
cnt<= cnt(6 downto 0)&'0';
count<= count+"0001";
else if(data_count<="1001")then
count<="0000";
data_in<= data_in+"00000001";
cnt<=data_in;
data_count<=data_count+"0001";
else if(eop_count<="01")then
eop_start<=¶1¶;
rxdp_i<='0';
eop_count<=eop_count+"01";
data_count=´1011";
else
rxdp_i<='1';
eop_start<=¶0¶;
data_count=´0000";
end if;
end if;
end if;
end if;
end if;
end process;
end rx_sm_arch_tb ;
c
c
c
The figure 4.14 shows that when reset_i is low and the SYNC pattern
³01010100´ is detected on the serial bus, rxactive_i is asserted and the data
³00101100´ received on rxdp_i is decoded because the receiver is in
normal mode (i.e., opmode is ³00´). The data is sent on to the data_out bus
and the receiver asserts rxvalid_o signal.
c
c
c
The figure 4.15 shows that when reset_i is low and rxactive_i is high
and opmode is ³10´, NRZI decoding is disabled and the data received on the
bus is sent on to the data_out bus as it is. The receiver asserts the rxvalid_o
signal.
The figure 4.16 shows that when reset _i is low and rxactive_i is
high, EOP pattern (two SEOs and one J state ) is detected on the serial bus.
Whenever the EOP pattern is detected on the bus, the receiver enters into
Strip EOP State where rxactive_o and rxvalid_i signals are de asserted. At
the raising edge of the next clock the receiver enters into RX wait state
where it is waiting for next SYNC pattern on the serial bus.
c
c
c
The figure 4.17 shows that when reset_i is low and rxactive_i is high
and if a zero is not detected after six consecutive one¶s are detected on the
serial bus, the receiver asserts the rxerror_o signal. Consequently rxerror_o
goes low and rxvalid_o is also low. The receiver enters into RX wait state.
c
c
c
c
c
c
/ 6()($%
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity utmi_top_tb is
end utmi_top_tb;
architecture utmi_arch_tb of utmi_top_tb is
component utmi_top
port(txvalid,xcvr,suspendM,term_select,reset : in std_logic;
rxvalid,rxactive,rxerror : out std_logic;
linestate : out std_logic_vector(0 to 1);
clk,dp,dm : inout std_logic;
data_bustx,data_busrx : inout std_logic_vector(0 to 7));
end component;
signal suspendM_i,term_select_i :std_logic;
signal rxvalid_i,rxactive_i,rxerror_i : std_logic;
signal linestate_i : std_logic_vector(0 to 1);
signal clk_i,dp_i,dm_i : std_logic;
signal reset_i:std_logic:='1';
signal txvalid_i:std_logic:='0';
signal data_bus_i : std_logic_vector(0 to 7);
signal fs_clk:std_logic:='0';
signal hs_clk:std_logic:='1';
signal xcvr_i:std_logic:= '1';
signal count:std_logic_vector(0 to 3):="0000";
begin
reset_i<='0' after 100 ns;
xcvr_i<= '0' after 10 us;
fs_clk<= not fs_clk after 84 ns;
hs_clk<=not hs_clk after 2 ns;
clk_i<= fs_clk when xcvr_i='1' else
hs_clk;
term_select_i<='0' after 9 us when xcvr_i='0' else '1' after 9 us;
term_select=>term_select_i,
reset=>reset_i,
rxvalid=>rxvalid_i,
rxactive=>rxactive_i,
rxerror=>rxerror_i,
linestate=>linestate_i,
clk=>clk_i,
dp=>dp_i,
dm =>dm_i,
data_bustx=>data_bus_i);
process(clk_i)
begin
if clk_i='1' and clk_i'event then
if reset_i='0'then
if(count<="1000")then
txvalid_i<='1' ;
data_bus_i<="00000000";
data_bus_i<=data_bus_i+"00000001";
count<= count+"0001";
else
txvalid_i<='0' ;
data_bus_i<="UUUUUUUU";
end if;
end if;
end if;
end process;
end utmi_arch_tb;
c
c
c
The figure 4.18 shows that when reset is low and xcvr signal is
high(i.e, full speed operation) the clock duration is 84 ns i.e., the fs_clk
signal is assigned to the clk signal. When txvalid is asserted by the SIE,
encoded SYNC pattern ³01010100´ is transmitted on to the serial bus (i.e,
DP, DM lines) when the receiver detects the SYNC pattern, it asserts RX
active signal. After SYNC has been transmitted, the data ³00000000´ is
transmitted on to the bus after NRZI encoding. After the data ³00000000´
has been transmitted, the transmitter asserts TX ready signal. When the
encoded data is received on the serial bus, the receiver decodes the data
asserts rxvalid signal and the data on the data_bustx is sent onto the
data_busrx. The receiver is in normal mode (i.e, the opmode signalis ³00´).
c
c
c
The figure 4.19 shows that when reset is low and suspend M goes low, TX
valid signal is de asserts SIE. The EOP pattern is transmitted on to the serial
bus, whenever receiver receives EOP pattern rxactive signal goes low and
ravalid goes low whatever the data present on the data_busrx is remained as
it is until next SYNC pattern is detected.
c
c
c
c
c
c
4 !"
-
4 i
((
The individual modules of UTMI have been designed, verified
functionally using VHDL simulator.
The UTMI Transmitter is capable of converting parallel data into
serial bits, performing bit stuffing and NRZI encoding.
The UTMI Receiver is capable of performing NRZI decoding
bitunstuffing and converting serial bits into parallel data. The functional
simulation has been successfully carried out. The design has been
synthesized using FPGA technology from Xilinx. This design is targeted to
the device familyĺspartan2, deviceĺxc2s30, packageĺcs144 and speed
gradeĺ -5.Thedevice belongs to the
Vertex-E group of FPGAs from Xilinx.
4 Ô
The UTMI has been implemented is 8-bit one, it can also be extended
to 16- bit UTMI.
The UTMI can be designed to generate special packets such as
preamble, Split and Ping .
It can also be designed to generate CRCs for control and data packets.
If an SIE and Device specific logic are designed, the combination of
UTMI, SIE and Device specific logic can be used as controller of a USB
device.
c
c
c
8 "--! "
The UTMI has been developed into a common code (Generalized USB
Transceiver) which can be used for developing the complete USB device
stack.
Some of the Low speed and High speed USB devices, which are presently in
the market, are:
1. Optical Mouse
2. Key Board
3. Printer
4. Scanner
5. Joy Stick
6. Memory Stick
7. Flash Memory
8. Mobiles
9. Video cameras.
c
c
c
7(
A VHDL primer J.Bhaskar
>7((
www.usb.org
www.opencore.org
www.digitalcoredesign.org
www.deeps.org
c
c
c