Chap 5
Chap 5
Chap 5
1 Design Overview
The project entitled Implementation of multi-channel UART controller based on FIFO technique using Spartan3 FPGA is under taken to establish a simultaneous and asynchronous data transmission and reception between a host system and a sub system or between any two sub systems. The multi channel UART controller block consists of multiple UART blocks or UART channels, in which these channels transmit and receive the data serially at different clock domains also called baud rates. The data bytes which need to be transmitted are initially stored in a RAM memory block, which we call it as transmit FIFO. This is applicable to all the UART channels. Then the buffered data bytes are read one by one from the transmit FIFO. The first byte read from transmit FIFO is temporarily stored in transmit shift register present in the transmit circuit. The transmit shift register now refers to the particular baud clock assigned to it for transmitting the data bit by bit serially. This data is initially provided with the start bit (active low) and a stop bit (active high) before transmitting. The transmitted data serially over a long distance (in case if the host system and the sub system are at larger distance) is received serially by the respective receive shift register of the other UART channel present at the sub system. The receive shift register receives data serially along with start bit and stop bit at a baud rate similar to that assigned for the transmitter circuit on the host system. The received 8 bit data from the receive shift register is now buffered to another RAM memory called receive FIFO. This received data can be make used of by the sub system.
Similarly the UART transmit circuit of the sub system can at the same time be transmitting while receiving because of the asynchronous property of the UART, that too at same or at different baud rates.
Steps related to working of entire multichannel UART controller are listed below
Step1: initialize all the input and output parameters Step2: Wait for host system to provide data inputs to the transmit FIFOs Step3: If the data_in_rdy signal is set to 1, then write that data of all UART channels to their respective transmit FIFO memory using write signal. Step4: Now upon a read signal going high, the first input data from the transmit FIFOs are read to the transmit shift registers respectively for all UART channels. Step5: This 8-bit input data which is read is padded with start and stop bit before transmitting serially. Step6: The 8-bit data becomes a 10 bit data and is transmitted serially with the first bit as start bit. This indicates the receive block that a new 8-bit data is being transmitted serially. Step7: The start bit is followed by 8 data bits and then a stop bit. This stop bit is used to indicate the correct operation. Step8: The receiver after receiving 8 bit data and fails to receive a stop bit, by default this 8-bit data is rejected and will not be considered as a valid data byte. Step9: Upon receiving the stop bit, the 8 bit received data is buffered to receive FIFO memory block by initiating a write signal of receive FIFO. Step10: This completes the transmit and reception of one 8-bit data. Step11: Simultaneously the transmit circuits and receive circuits of all 4 UARTs can work asynchronously or simultaneously i.e., by performing the transmit and receive
operation without interruption of any data values.
Step12: This process is repeated continuously by going back to step2 The datas are transmitted and received using different baud rates that are assigned to particular UART channels.
A flowchart is diagrammatic representation of our design, showing the steps as boxes of various kinds, and their order by connecting these with arrows. Flowcharts are used in analyzing, designing, documenting or managing a process or program in various fields. Here each block in a multi channel UART controller is represented in terms of flow chart. Firstly we represent the top level design module that is the entire multi channel UART controller, then the sub modules or blocks consisting of FIFO blocks, Baud rate generator blocks, transmitter blocks and receiver blocks.
Start
Load the input data values namely data_in1, data_in2, data_in3, data_in4
Is
Yes
Write all the input data to respective transmit FIFOs Write11=1, Write21=1, Write31=1, Write41=1
Read data values from respective transmit FIFOs to transmit shift registers Xmit_dataH1, Xmit_dataH2, Xmit_dataH3, Xmit_dataH4
F A
Assign baud clocks to all the UART blocks for transmission and reception
Y
Transmit the data present in transmit shift registers (at the desired baud rate that has been assigned) serially i.e., bit by bit Tx1_data, Tx2_data, Tx3_data, Tx4_data
No
Yes
Receive the serial transmitted data to respective receive shift registers Rec_dataH1, Rec_dataH2, Rec_dataH3, Rec_dataH34
No
Yes B Fig. 5.2: Flow chart of entire top level module (contd.)
Write the received data from receive shift registers to respective receive FIFOs. Write 12=1, Write 22=1, Write 32=1, Write 42=1
E
Read the data from receive FIFOs (host system makes use of this data as an information received from subsystems) Rx1_data, Rx2_data, Rx3_data, Rx4_data
No
Yes
Increments write and read pointers for transmitting and receiving the next data byte serially (from the host system to several subsystems or between the subsystems)
blocks. This process repeats continuously, till the new data values keep appearing at the input sides which are written into FIFO blocks.
Start
Load the values of crystal frequency and desired baud rates to calculate the baud count
Is Baud_sel
00 BAUD= Baud_count1
01 BAUD= Baud_count2
10 BAUD= Baud_count3
11 BAUD= Baud_count4
Value =BAUD
Clk_div = Clk_div+1
Is Clk_div= = Value
No
Clear Clk_div
The Baud rate generator block is mainly used to generate different Baud clock signals to UART transmit and receive circuits. Here the system crystal oscillator frequency is making used to calculate Baud_clk, which is the output signal of Baud rate generator block. Baud_count is calculated using equation Baud_cunt=(crystal frequency)/ Baud_clk_val. Baud_sel is used as a select input line for selecting different Baud rate values as shown in Fig. 5.4. Here Clk_div is used as a counter which increments and is compared with the calculated Baud_count. Once Clk_div equals the Baud_count, the output signal Baud_clk is inverted. This process repeats continuously their by generating a Baud clock signal, which is going to be used by the transmit and receive circuits.
Start
No
Yes Is reset = =1 No
Yes
Is
No
data_in_rdy ? Yes
Write the data into FIFO memory and increment write pointer
Is Read = =1
No
Is Write = =1
No
Yes Finish or not ? Yes End Fig. 5.7: Flow chart of FIFO memory blocks (contd.) No
Yes
Start
Initialization of all data values T Read the data to be transmitted from transmit FIFO to transmit shift register xmit_dataH
Delay of T/2 to sample start bit, data bits & stop bit Shift out the data bits serially Increment bit counter
Is bit counter<8 8
Yes
Start
Initialization all data values Q Receive the serially transmitted data with the desired band rate
No
No
Sample the remaining data bits and shift the receive shift register data each time when a bit is received
Is stop bit detected after 8 data bits? Discard the received data since, error in transmission
No
Yes
Buffer or store the received data to receive FIFO Set rxd_readyH flag and start detecting for next start bit
R
Fig. 5.10: Flow chart of UART receiver blocks (contd.)