CSE467 Laboratory Assignment 2: XCV1000 and Verilog UART
Distributed: January 11, 2005
Due start of next lab session


In Part I of this laboratory assignment you get to know the technique for creating and running a verilog program for the XCV1000.

In Part II we will implement an RS-232 interface between your lab PC and the XCV1000. You will implement a UART in verilog, and echo the serial data back to your PC.

In Part III you will add a buffer for a string of serial data.

Part I. Compiling and Programming for XCV1000bg560

Create a workspace


Figure 1






Modify the program

Editing the Pin Constraints

Check off: demonstrate your two-three pattern to the TA.

Part II. Serial Interface in verilog

Serial Echo Project

There are two basic pieces to this project.  The first is the SerialUart.v, which is the module that we will provide to you.  The second is the SerialCtrl.v module, which is the module you will be required to modify.  All this project does is read characters that are typed into hyperterminal and echo the characters back to hyper-terminal one at a time.

SerialUart Module

This module uses the serial uart modules from opencores.org.  We wrote this module as a wrapper to combine all the modules that are needed for the uart to function like a standard serial uart.  The data goes into and comes out of this module through transmit and receiver FIFOs.

Here is a short description of each i/o port:

Clk: The standard 50 MHz global clock input.

Reset: The standard active-high reset input.

RX: The receive input from the RS-232 chip.  This pin needs to be included in the ucf file.

TX: The transmit output to the RS-232 chip.  This pin needs to be included in the ucf file.

Read_RX_FIFO: Control signal input that should be set high to read from the fifo.

Write_TX_FIFO: Control signal input that should be set high to write into the fifo.

TX_Buffer_Full: Transmit fifo status signal which means you can’t write a value into the fifo.

RX_Data_Present: Receive fifo status signal which tells you when data has been received.

TX_Data: The 8-bit data input which you write to when sending data.

RX_Data: The 8-bit data output which you read data from when receiving.

The serial uart has one receive and one send fifo.  Each of them is a four-deep fifo.

A few things to note about timing: First, both the Read_RX_FIFO and Write_TX_FIFO control signals should only be set high for one clock cycle.  If they are held high for longer than that, they will read or write multiple values.  When transmitting data, the register which the TX_Data is wired to needs to have its value present before Write_TX_FIFO is pulsed high because the SerialUart module latches the data in TX_Data when Write_TX_FIFO goes high.  When receiving data, it is okay to latch the data from RX_Data as soon as the RX_Data_Present signal goes high. 

SerialCtrl Module

This module instantiates the SerialUart module and goes into a listen state.  When the RX_Data_Present signal goes high, it latches the data from RX_Data, writes it into a send register, which is wired to the TX_Data, and then drives the Write_TX_FIFO high for one clock-cycle.  There is not really a need to check the TX_Buffer_Full signal before writing because it’s receiving data at the same rate that it is writing data. We have provided a simple versionof the module; you must modify and improve this module to complete this section of the lab.

To do:

First, wire your RS-232 interface according to this schematic:

Hint: place this circuit at the UPPER END OF THE PROTO AREA, CLOSEST TO THE POWER CONNECTIONS. You will need the space for next week's lab.

You will find the correct pins to connect RX and TX in the serialecho.ucf file below.

Next, create a new workspace in ActiveHDL as in part I above, and add the following files to it:


serial_cntl.v is the module you must modify. You must change the state machine to detect a carraige return (ENTER key) and send a carraige return/line feed pair to hyperterminal. Hint: You may need to add a state to the state machine. (see serial_cntl2.v below for hints on detecting a carraige return.)

The ucf file is similar to the Generic_Pin_List.ucf file in part I, and should be used in an identical manner. Follow the procedures in Part I to compile and load your verilog. Plug your DB9M into the com1 serial cable from your lab PC, and use hyperterminal for testing. To run hyperterminal, go " Start -> Accessories-> Communications -> hyperterminal".

The baudrate needs to be set to 57600 bits/sec and the flow control should be set to none.

Check off: demonstrate your improved character-echo to the TA.

Part III. Serial String buffering in verilog

Serial String Project

Create a new workspace in ActiveHDL as in part I above, and add the following files to it:


This project has all of the same components as the serial echo project.  The functionality of the SerialCtrl2 module is slightly different.  Rather than reading and writing one character at a time, a whole string of characters are read in from hyper-terminal and then written back when the ‘ENTER’ key is pressed. 

To accommodate this, there is an internal memory which data is written into as it is read from the uart.  Each time a new character is read, the serial controller checks to see if it is the ‘ENTER’ character.  If it’s not, the new value is written to serial_buffer and the memory pointer is incremented.  If it does match the ‘Enter’ character, the memory pointer is reset to 0 and all the values stored in serial_buffer are transmitted back to the hyper-terminal.  Since, it is possible to write characters faster than they can be transmitted, it is important to check the TX_Buffer_Full signal before writing to the TX fifo.

The SerialCtrl2 module has the same problem that SerialCntl had.. Your job is to improve it in a similar manner to part II above, so that it adds a line feed when an ENTER (carraige return) is detected. Hint: You may need to add a state to the state machine.

Check off: demonstrate your improved buffered character-echo to the TA.