CDA4203L Lab6-Loopback System using PicoBlaze Solved

30.00 $

Category:

Description

5/5 - (1 vote)

Objective:  To design and synthesize a loopback system using a PicoBlaze microcontroller, and to implement functionality using Assembly code.

Description:  Consider a simple “loopback” system as in Fig. 1. In such a setup, a PC can send a message which is returned (looped) back to PC by the processor. Such a loopback  test is helpful to test the processor is alive or not.

Fig. 1. A simple loopback system

Fig. 2. UART Transmit and Receive Blocks – High Level View

A PC (not shown) interfaces with PicoBlaze processor using an RS232 (serial) connection. Let us examine the case when the PC acts as a transmitter. In this case the data arrives serially on RS232 RX line. But we know that PicoBlaze accepts only byte-size data. So, we need to convert the serial data into parallel (8-bit) data. In such a case, a UART (Universal Asynchronous Receiver Transmitter) block can help (Figure 2). UART_RX does the serial-to-parallel conversion i.e., the data arriving on RS232_RX line is buffered in a 16-byte buffer. Whenever new data is presented on rx_data output, UART_RX will assert data_present i.e., data_present = 1 in other words data_ present validates rx_data. The Input Port Logic block consists of glue logic that connects UART_RX to the IN_PORT. After PicoBlaze reads the data, it can request the next data item by asserting read by uart signal.

Now, let us consider the case when PicoBlaze acts as a transmitter i.e., PC is the receiver. In this case, PicoBlaze puts out 8-bit data while PC is expecting serial data. Again, UART (UART_TX in Fig. 1) comes to our rescue! The output bus with id=3 is connected to UART_TX. Output Port Logic block interfaces PicoBlaze with leds and UART_TX. In this system, we can also manually provide 8-bit data via 8 switches (switches bus in Fig. 1). PicoBlaze can write 8-bit data to drive 8 leds (leds bus in Fig. 1). Recall that PicoBlaze can accept up to 256 input ports each of which can addressed by 8-bit PORT_ID bus. Similarly, it can drive up to 256 ports and the address of the port being driven appears on PORT_ID bus. In Fig. 1, for example, the id of the input port, switches, is 0.

  1. cold_start: Write code to output a message “Welcome to Loop-back!” to the serial port. You need to encode the message in ASCII format. CAUTION: UART_TX buffer size is only 16 bytes.
  2. led_echo: Write code to read switches and write the values, inverted, to the LEDs.
  3. rs232_echo: Write code to check if a byte has been received by UART_RX. If so, send it back to the PC via UART_TX.
  4. Behavior: The design must be able to perform all the above actions simultaneously.

Design Constraints:

  • The design must both function correctly in simulation and on the FPGA board.
  • The RESET button must provide a global reset functionality. This includes resetting the microprocessor.
  • The 100MHz Clock is used as the system clock.
  • Every time the design is initialized (reset) it runs cold start.
  • Until it is turned off or reset, it performs the following two actions continuously:
  • Echo inverted Switch values to LEDs.
  • Echo RS232 data back to PC.
  • It must do this indefinitely.

Lab 6 – Step by Step Instructions

It’s strongly recommended that you perform the steps in the given order below.

  1. Download and Unzip

(a) In your home directory, create a new folder ‘lab6’.

(b) Download the loopback.zip file from canvas into ‘lab6’.

(c) Unzip the file.

 

  1. Create ISE Project

(a) Create a new ISE project.

(b) Ensure that you are using the correct settings (Tutorial 1).

(c) Add copies of all Verilog source files and the UCF file from the loopback directory.

 

  1. Edit ‘loopback.v’

(a) Complete Worksheet 1 on loopback.v

(b) Open ‘loopback.v’ and fill in the blanks.

  1. Edit ‘loopback.UCF’’

(a) Complete Worksheet 2 on FPGA Pin Assignments.

(b) Open ‘loopback.UCF’’ and fill in the blanks.

 

  1. Write Assembly Code

(a) Open the “Assembler” folder in “loopback”.

(b) Open the ‘program.psm’ file with a text editor.

(c) Enter your assembly code for task 1. Note that the ASCII codes are already entered as constants. For example, if you want to load the ASCII code for ‘h’ then you can write:

LOAD sX, ascii h.

(d) To assemble the code, the syntax is: ./picoasm -i program.psm -t ROM form.v

(e) It will generate a file, ‘program.v’. Add a copy of this file to your project. It contains the assembled code for PicoBlaze.

 

  1. FPGA Synthesis and Implementation

(a) Synthesize and generate the lookup.bit file.

(b) Load the design onto the board.

 

  1. RS232 Cable Connection

(a) Connect the RS232 serial cable to the back of the C4 lab computer, as well as to

the XUP board.

 

  1. Connect to Serial Port

(a) To open the serial terminal, run ‘minicom’ from a terminal.

(b) Test the RS232 capabilities of your design (cold start, loopback).

(c) To exit, Press: ‘ctrl+A’ then ‘ctrl+z’ then ‘x’.

 

  1. Finish

(a) Write assembly code for led echo program. (Task 2)

(b) Write assembly code for rs232_echo program. (Task 3)

 

  1. (Optional) Create and load PROM file.

(a) Do this step only after you have finalized your design.

(b) The tutorial will be available on canvas.

(c) This allows the design to automatically be loaded when the board is powered on.

 

Worksheet 1

 

  1. What is the instruction bus width for the ROM?
    1. 18 bits

 

  1. For the UART 16x bit rate counter, the maximum baud count using the following formula:

max_baud_count = fclk/ (16*req_baud_rate)

 

If fclk = 100MHz and the required baud rate is 9600, what is the maximum baud count?

  1. 651

 

  1. Write the boolean expression for the write to uart
    1. assign write_to_uart = pb_write_strobe & (pb_port_id == 8’h03);
    2. assign write_to_leds = pb_write_strobe & (pb_port_id == 8’h01);

 

  1. Write the boolean expression for the write to leds

 

  1. What are the port_id values for the following input ports:

(a) switches:

(b) data_rx:

(c) data_present:

(d) buffer_full:

 

  1. Write the boolean expression for the read_from_uart signal.

 

  1. Continue with step 3 (b).

 

Worksheet 2

 

Fill in the pin locations for the following components/signals. Refer to the FPGA User Guide and master.ucf available on canvas.

 

  1. Clock (100MHz):
  2. Push Button Up (for reset signal):
  3. LED 0:
  4. LED 1:
  5. LED 2:
  6. LED 3:
  7. LED 4:
  8. LED 5:
  9. LED 6:
  10. LED 7:
  11. SW 0:
  12. SW 1:
  13. SW 2:
  14. SW 3:
  15. SW 4:
  16. SW 5:
  17. SW 6:
  18. SW 7:
  19. RS232 TX (FPGA_SERIAL1):
  20. RS232 RX (FPGA_SERIAL1):

 

Now continue with Step 4 (b).

 

Deliverables:

Submit a zipped archive consisting of: (a) A concise report that includes your PicoBlaze assembly code.  Include a README file. Organize your files in folders named Problem1, Problem2, and Problem 3.

 

Report Organization (A template is provided on canvas):

  • Cover sheet
  • Problem 1: Your design details, assembly code.
  • Problem 2: Your design details, assembly code
  • Problem 3: Your design details, assembly code
  • Problem 4: Pin Mapping file and synthesis report.
  • Feedback: Hours spent, Exercise difficulty (Easy, Medium, Hard)

 

Important:

  • Lab-6-Loopback-System-using-PicoBlaze-a7f5bv.zip