Router 1X3 - RTL Design and Verification
Router 1X3 - RTL Design and Verification
I.
INTRODUCTION
A router is a networking device that forwards data packets between computer networks. A router is
connected to two or more data lines from different networks (as opposed to a network switch, which connects
data lines from one single network). When a data packet comes in on one of the lines, the router reads the
address information in the packet to determine its ultimate destination. Then, using information in its routing
table or routing policy, it directs the packet to the next network on its journey. This creates an
overlay internetwork. Routers perform the "traffic directing" functions on the Internet. A data packet is typically
forwarded from one router to another through the networks that constitute the internetwork until it reaches its
destination node.
II.
THEORETICAL BACKGROUND
A router is a device that forwards data packets along networks. It is connected to at least two networks,
commonly two LANs or WANs or a LAN and its ISP's network and is located at gateways, the places where
two or more networks connect. It is an OSI layer 3 routing device. It drives an incoming packet to an output
channel based on the address fields contained in the packet header. Routers use headers and forwarding tables to
determine the best path for forwarding the packets, and they use protocols to communicate with each other and
configure the best route between any two hosts.
62
Diagrammatic Comparison between OSI Reference Model and TCP/IP Reference Model
1.
Router packet:
Packet format: the packet consists of 3 parts: Header, payload and parity each of 8 bit width and the length of
the payload can be extended between 3 between 1 byte to 63 byte.
63
DA: destination address of the packet is of 2 bits. The router drives the packet to the respective ports
based on this destination address of the packets.
Each output port has 2-bit unique port address. If the destination address of the packet matches the port address,
then router drives the packet to the output port. The address 3 is invalid.
Length: length of the data is of 6-bits. It specifies the number of the number of the data bytes. A packet
can have a minimum data size of 1 byte and a maximum size of 63 bytes.
If length =1, it means data length is 1 byte
If length =2, it means data length is 2 bytes
If length =63, it means data length is 63 bytes
Payload: payload is the data information. Data should be in terms of the bytes.
Parity: This field contains the security check of the packet. It is calculated as bitwise parity over the
header and payload bytes of the packet as mentioned below.
2.
64
After the last payload byte has been driven, on the next falling edge of the clock, the packet_valid signal
must be de-asserted, and the packet parity should be driven. This signals packet completion.
The testbench shouldn`t drive any byte when busy signal is detected instead it should hold the last driven
values.
The `busy` signal when asserted drops any incoming byte of the data.
The err signal is asserted when a packet parity mismatch is detected.
3.
Router : FIFO
Functionality
There are 3 FIFOs used in the router design. Each FIFO is of 9 bits wide and 16 bit bytes depth. The
FIFO works on the system clock and is reset with a synchronizer active low reset.The FIFO is also internally
reset by an internal reset signal soft_reset. Soft_reset is an active high signal which is generated by the
SYNCHRONIZER block during time out state of the ROUTER.
If resetn is low then full=0, empty=1 and data_out=0.
65
Signal data_in is sampled at the rising edge of the edge of the clock when write_enb is high.
Write operation only takes place when FIFO is not full in order to avoid over_run condition.
Read operation:
The data is read from data_out at rising edge of the clock, when read_enb is high.
Read operation only takes place when the FIFO is not empty in order to avoid under run condition.
During the read operation when a header byte is read, an internal counter is loaded with the payload
length of the packet plus 1 (parity byte) and starts decrementing every clock till it reached 0. The
counter holds 0 till it is reloaded back with a new packet payload length.
Full- FIFO status which indicates that all the locations inside FIFO have been written.
Empty- FIFO status which indicates that all the locations of the FIFO have been read and made empty.
ROUTER : SYNCHRONIZER
Functionality:
This module provides synchronization between router FSM and router FIFO modules. It provides faithful
communication between the single input port and three output ports.
detect_add and data_in signals are used to select a FIFO till a packet routing is over for the selected
FIFO.
The signal vld_out_x signal is generated based on empty status of the FIFO as shown below :
vld_out_0=~empty_0
vld_out_1=~empty_1
vld_out_2=~empty_2
The write_enb_reg signal is used to generate write_enb signal for the write operation of the selected
FIFO.
There are 3 internal reset signals (soft_reset_0, soft_reset_1, soft_reset_2) for each of the FIFO
respectively.
The
respective
internal
reset
signals
goes
high
if
read_enb_X
(read_enb_0,read_out_1,read_out_2)
is
not
asserted
within
30
clock
cycles
of
the
vld_out_X(vld_out_0,vld_out_1 or vld_out_2) being asserted respectively.
66
ROUTER: FSM
STATE-DECODE_ADDRESS
Signal detect_add is asserted in this state which is used to detect an incoming packet. It is also used to
latch the first byte as a header byte.
STATE-LOAD_FIRST_DATA
Signal lfd_state is asserted in this state which is used to load the first data byte to the FIFO.
Signal busy is also asserted in this state so that header byte that is already latched doesnt update to a
new value for the current packet.
This state is changed to LAOD_DATA state unconditionally in the next clock cycle.
STATE-LOAD_DATA
In this state the signal ld_state is asserted which is used to load the payload data to the FIFO.
Signal busy is de asserted in this state, so that ROUTER can receive the new data from input source
every clock cycle,
Signal write_enb_reg is asserted in this state in order to write the Packet information
(Header+Payload+Parity) to the selected FIFO.
This state transits to LAOD_PARITY state when pkt_valid goes low and to FIFO_FULL_STATE
when FIFO is full.
STATE-LOAD_PARITY
In this state the last byte is latched which is the parity byte.
Signal busy is asserted so that ROUTER doesnt accepts any new data.
In this state laf_state signal is asserted which is used to latch the data after FIFO_FULL_STATE.
It checks for parity_done signal and if it is high, shows that LOAD_PARITY state has been detected
and it goes to the state DECODE_ADDRESS.
In this state rst_int_reg signal is generated, which is used to reset low_packet_valid signal.
This state changes to DECODE_ADDRESS when FIFO is not full and to FIFO_FULL_STATE when
FIFO is full.
67
ROUTER: Register
Functionality:
This module implements 4 internal registers in order to hold a header byte, FIFO full state byte, internal parity
and packet parity byte. All the registers in this module are latched on the rising edge of the clock.
If resetn is low then the signals (dout,err,parity_done and low_pkt_valid) are low.
When signal ld_state is high and signals (fifo_full and pkt_valid) are low.
When signals laf_state and low_pkt_valid both are high and the previous value of parity_done is low.
Signal low_pkt_valid is high when ld_state is high and pkt_valid is low. Low_packet_valid shows
that pkt_valid for current state has been deasserted.
First data byte i.e., header is latched inside an internal register when detect_add and pkt_valid signals
are high. This data is latched to the output dout when lfd_state goes high.
Then signal data_in i.e. Payload is latched to dout if ld_state signal is high and fifo_full is low.
Signal data_in is latched to an internal register when ld_state and fifo_full are high. This data is
latched to output dout when laf_state goes high.
Another internal register is used to store internal parity for parity matching. Internal parity is calculated
using the bit-wise xor operation between header byte, payload byte and previous parity values as shown
below:
parity_reg=parity_reg_previous^header_byte ---- t1 clock cycle
parity_reg=parity_reg_previous^header_byte ---- t1 clock cycle
parity_reg=parity_reg_previous^header_byte ---- t1 clock cycle
parity_reg=parity_reg_previous^header_byte ---- t1 clock cycle
Last payload byte
The err is calculated only after packet parity is loaded and goes high if the packet parity doesnt match
with the internal parity.
III.
SIMULATION RESULTS
Following components of router were synthesized and simulated, using Xilinx ISE software. And
Simulation results were observed. Following are the results obtained:
68
69
IV.
CONCLUSION
The Router1X3 is designed and verified successfully. Many coding bugs are debugged during the
verification.
Scenarios like packets with payload length
8 byte
14 byte
16 byte
17 byte
good packet
70
REFERENCES
[1].
[2].
[3].
[4].
[5].
71