In this practical we will cover two main topics:
  1. First, you will learn what the Virtual Lab is, and how to use it to perform your work remotely.
  2. You will learn to write embedded C code for the Microblaze in the EDI pack.

The Virtual Lab

The Virtual Lab provides students and researchers with round-the-clock network access to a cluster of FPGA boards. The Lab allows you to work from home on exercises and the EDI assessment, useful for when deadlines are approaching! You are not required to make use of the Virtual Lab in any way, but it might prove to be useful.

An introduction to the Virtual Lab and download links for its client software can be found here. The EDI Virtual Lab Manual explains how to use the software.

Task: Test the VLAB software using the example bitfiles and any of your own bitfiles that you have built so far. Your designs will operate on the Virtual Lab exactly as they do in the actual lab, as the hardware is identical. This is very useful for reliable debugging. Ensure that you have tested at least one bitfile remotely before moving on.

The Microblaze

The Microblaze is a 32-bit microcontroller core written by Xilinx for implementation on FPGAs. Its instruction set is a fully-supported target of GCC (as the microblaze-elf architecture) and has even been merged into the mainline Linux Kernel source tree. You will write software in C, and pass it through a GCC cross compiler to produce ELF executables. These are then taken by Xilinx tools to be inserted into the bitfiles of your system. This means the following important things are the case:
  • Whereas you have to resynthesise (run ./ implement) every time you change your Handel-C component, you do not have to resynthesise if you only change your software.
  • If you only run ./ implement your bitfile will have no code in it. You must also program the bitfile with your software, as described below.

To compile software, you use the script:
./ program
The program option will compile the software in the EDI pack, and invoke iMPACT to program the FPGA with the resulting bitfile. If you do not want to program the FPGA (for if you are using the Virtual Lab) then you can use:
./ compile
This will only compile your software and insert it into the bitfile. The final bitfile to send to the Virtual Lab is system-programmed.bit in the root directory of the pack.

Developing software

Software development, how to access devices, and how to communicate with Handel-C devices is detailed in the EDI Microblaze interface. You will need to refer to this page frequently during the following exercises.


Download a fresh copy of the EDI Pack and extract it. Observe that software/microblaze_0.c is the main entry point of the code and that it currently contains a small test program that prints "Hello world!" to the console. It is this file we will edit. If you want to use extra source files, remember to add them to the script as described in the EDI Microblaze interface documentation.

Important note: In these tasks we are going to use simple VGA graphics output to get used to using the Microblaze to write to peripherals and RAM. The graphics output is not enabled by default because it would take up valuable space in your designs. To enable it, enter:
./ vgaon
./ implement
It can be disabled with ./ vgaoff.

The documentation for the VGA graphics core is here and will be essential for the exercises.

Task 1

The graphics driver will do nothing until you first set its base frame address. Set this address to a location in DDR memory (refer to the architecture on this page for the address map) and observe that the graphics will show a corrupted mess. This is because the RAM is uninitialised. Initialise the frame by clearing it all to a solid colour.

Task 2

As you can see from its documentation, the graphics core is palette-based. Create a Microblaze program which prints out the palette of the graphics core in a useful manner, like the palette image on the documentation page (don't worry about text labels unless you are feeling adventurous!). This will involve precise manipulation of memory from the Microblaze to set up the frame.

Task 3

Implement a very simple turtle drawing program that allows the user to draw using the UART. It should understand the following commands:
Clear the screen to the given colour. Move the cursor to (0,0)

Draw mode (movements leave a trail)

Stop drawing (movements do not leave a trail)
Set pen colour
Move <distance> pixels up, leave a trail if in draw mode
Move <distance> pixels down, leave a trail if in draw mode
Move <distance> pixels left, leave a trail if in draw mode
Move <distance> pixels right, leave a trail if in draw mode
It is up to you how you accept the arguments. Don't get too complex. For example you can only support a few fixed colours, or accept arguments always as 2 hex digits or similar.