Embedded System Design Lab 1Stephen A. EdwardsDue August 2, 2005AbstractWrite a C program that counts in decimal on the DigilentSpartan-3 starter board. Learn how to compile and run a pro-gram, program the FPGA, and use serial communication for de-bugging.1 IntroductionThe Digilent Spartan-3 Starter Board consists of a XilinxSpartan-3 XC3S400 FPGA, which has roughly 400 000 rawgates that can be user-programmed into any configuration. Forthis lab, you will use a project we have provided for you, con-sisting of the Microblaze 32-bit microprocessor, a UART, anda soft peripheral that controls the seven-segment LEDs on theboard.2 Hello WorldFirst, get familar with the tools by compiling and running thesample project supplied by Xilinx.1. The boards have a serial port on them and the sam-ple project includes a UART (Universal AsynchronousReceiver Transmitter) that can be used to communicatethrough a modem cable to the workstation. We will usethis for debugging since it provides a way to print thingsfrom the C program.Start Hyperterminal and set it to use COM1 at 9600 baud,no parity, one stop bit.2. Unzip the lab1 source file (on the class home page,http://www1.cs.columbia.edu/˜sedwards/classes/2005/emsys-summer/) in the directoryC:\edk_user_repository. It should create adirectory there named lab1.3. Start Xilinx Platform Studio by clicking on thesystem.xmp file in the directory you just unzipped.14. Start the compilation process and download the programto the board by clicking on the “download” button inthe platform studio application. It’s on the second rowof icons, roughly in the middle. You can also use theTools→Download menu item.This takes a long time and generates lots of harmless mes-sages and over a thousand temporary files, but will even-tually compile the project into a .bit file suitable for theFPGA on the board and finally download it.5. If all goes well, the project will be compiled, downloaded,and run on the board. The LEDs should glow for a whileand finally a series of things should appear in Hypertermi-nal and the LEDs should start walking.If something goes wrong, make sure your board is con-nected properly (it should have a power connection fromthe external power supply, a connection through a parallelcable, and a connection through a serial cable) and pow-ered on. An LED near the power connector lights wheneverpower is applied to the board.If you can’t get things to work, pester someone for help.3 What is going on?A lot. The Xilinx Platform Studio tool is assembling and com-piling a small computer system that is then downloaded to theFPGA. Platform Studio also compiles a small C program anddownloads it into memory on the FPGA. Finally, it runs the pro-gram, which prints things to the serial port and blinks the LEDs.There are two interesting tabs in Platform Studio: “System,”which describes the hardware and peripherals, and “Applica-tions,” which describes the software that runs on this hardware.The demo project is centered around a single CPU, “microb-laze0.” The Microblaze is Xilinx’s own soft processor corespecifically designed to be placed on an FPGA. It is a 32-bitRISC-style processor. Fortunately, the C compiler for it is goodenough so that you do not have to know Microblaze assemblylanguage to build an interesting project.Under the CPU are three busses: mb opb, which is the periph-eral bus, ilmb, which is the instruction bus, and dlmb, which isthe data bus (the Microblaze uses a Harvard architecture). Con-nected to these busses are various bus controllers (dlmb cntlr,ilmb cntlr), an on-chip shared instruction and data memoryblock (lmb bram), a serial controller (RS232), a driver for therow of LEDs (LEDs8Bit), a controller for the off-chip SRAM(SRAM256Kx32 util bus split 0), as well as a timer and inter-rupt controller.The system.mhs file lists how the hardware should be as-sembled to create the project. For example, it lists the LED andserial connections, the Microblaze processor, the UART, and theperipheral that controls the LEDs.The system.mss file describes how the software should beassembled for the system, and is less interesting than .mhs file.It says to include the UART driver and to connect stdin and std-out of the program to the driver.The testApp.c file (under Applications/Project:TestApp/Sources) contains the main() function that isrun when the system is downloaded. You will modify this forthis lab.The data\system.ucf lists to what pins on the FPGAinternal signals should be connected. These pin numbers camefrom the Digilent board documentation, which lists the role(s)of each pin.Finally, etc\bitgen spartan3.ut sets some optionsfor generating the final bitstream.4 The AssignmentModify the testApp.c file to count in decimal from 0 to 99 onthe LEDs. Make sure the numbers from 0–9 don’t display aleading 0.Show your working counter to a TA, have him sign a printoutof your solution (i.e., testApp.c), and hand that in.Shorter, elegant, and readable solutions will be scored higherthan ones that merely
View Full Document