Xps Tutorial
Xps Tutorial
[email protected]
[email protected]
March 17, 2011
This tutorial intends to show you how to create a simple and very basic sys-
tem. Starting with Xilinx Platform Studio (XPS) version 6.1 this has been
significantly simplified due to the Base System Builder wizard (the current XPS
version is 12.2).
note To save disk space you can remove temporary files from the project by
Project→Clean All Generated Files.
note A tutorial movie showing you how to use the BSB wizard is available at
http://fileadmin.cs.lth.se/cs/Education/EDA385/HT10/videos/create1PsystemISE12.avi
1
• In the first wizard dialog, specify the project location and name1 . XPS will
create a lot of files in the project directory, so create a new empty directory.
You will also need some configuration files for the Digilent FPGA-board.
The files can be downloaded from the course web page (under assignments
klick on Support files for the Digilent board ). Unpack the zip file. In the
XPS dialog check the Set Project Peripheral Repositories box and write in
the path to the directory called lib from the unpacked zip-file. Click OK.
• In the new dialog select “I would like to create a new design”, Click Next.
• Now you must select the location of your software and the mapping of
STDIN/OUT. Keep the RS232 (UART) for your STDIN and STDOUT
(for the C I/O functions, i.e. printf() and scanf()). Make sure all the
applications have their data and instructions mapped into local on-chip
memories (accessed through ilmb ctrl and dlmb ctrl respectively).
• Now you are done, click next in the remaining dialogs, and Finish. After
this you will want to “Start using Platform Studio”.
You have created your initial system. All you need to do now is compile and
run logic synthesis, as will be explained later. Now is a good time to ex-
plore XPS a bit. Lets start by looking into the hardware architecture gen-
erated for you. It can be visualized by selecting Project→ Generate and
View Block Diagram. A block diagram will appear in the frame to the
rightDo not worry if you do not get all the abbreviations. Here is a partial list:
LMB Local Memory Bus CPU ↔ memory bus (point to point bus)
PLB Processor Local Bus CPU ↔ peripheral bus (shared bus)
GPIO General Purpose IO glue logic for the buttons/leds on the board
RS232 serial port used for text input/output of your application
An extended view which also contains more information about the components
is created by selecting Project→Generate and View Design Report.
1 The path cannot contain spaces. We recommend you use the local C:/Temp/yourdir for
2
There are three main frames in the XPS window. Let’s start with the left
frame. It contains three tabs Project, Applications, and IP Catalog. In the
Project tab you find general system files as well as log files, in the Application
tab you find the software parts of your system, and finally in the IP Catalog you
find a tree containing all the IP components you can use to build your system.
Select the Application tab. There are two projects, one for memory test and
one for peripheral test. The projects which are not active (downloaded) have
a red cross in their icon. Right click on a project and select Mark to Initialize
BRAMs to activate it. By right clicking you can also compile (build) individual
software projects. There can only be one main function for every processor, so
do not activate several projects that contain a main function.
The frame to the right in the XPS window is used for viewing and editing
documents. This is where you opened the block diagram earlier. Select the
System Assembly tab (the tabs are in the bottom of the frame). This view
contains a list/tree of your system components and their connections. There
are three busses. The two blue are LMBs connecting the processor and the
memory controller, one is used for instruction fetch (ilmb) and the other is
used for data read/write (dlmb). The red lines are not buses, but illustrate the
connection between the memory controller and the memory block(s). Finally the
gold line is a PLB connecting the processor and the peripherals. All peripherals
are memory mapped, thus they can be addressed through read/write to memory
addresses (see the Addresses tab). To connect/disconnect a component to/from
a bus click on the circles. Double click on a component to get a dialog in which
you can change its parameters.
3
Hardware
Software
Flow
Flow
Generate Generate
Bitstream Libraries
Build User
Application
Device
Configuration
Update
Bitstream
Download Configuration
printf requires huge libraries, which will not fit in the small on-chip memory.
Instead use print, or xil printf functions to output text. xil printf is sim-
ilar to printf, but much smaller and lacks some of the formatting, i.e. floating
point support. If you want to discover more about the software settings, have
a look at Software→Software Platform Settings. . . . Now compile your
programs by selecting Software→Build All User Applications.
Let’s move on to the hardware. Hardware synthesis is done in several steps
(create the logic circuit (netlist), create the FPGA configuration (bitmap)), but
you do not need to worry about this just yet. Simply select Hardware→
Generate Bitstream and everything will be generated automatically for you.
This might take a long time, in the range of 10 minutes or even more, depending
on whether your hardware was already synthesized or not. Fortunately the
hardware is independent of the software, so whenever you change your C files,
this step will not rerun. During the hardware synthesis, the tools use a User
Constraint File (UCF), which can be found in the left frame in the Project tab.
This file binds external ports in your design to physical pins on the FPGA. It
is important that the names in the design are the same as in this file, so do
not rename the external ports. Also if you add or remove external pins this file
must be edited, i.e. removing a GPIO peripheral.
The last step before dowloading the configuration to the FPGA is to merge
software binaries and the bit stream from the hardware synthesis, run Device
Configuration→ Update Bitstream. This places the executable in the on-
chip memory, making the configuration file ready to be downloaded on the
FPGA.
4
nal start→ all programs→ accessories→ communications→ hyperter-
minal. Give the new connection a new name and chose com1 in the Connect
using frame. Use port settings according to the uart parameters:
Bits per second 9600
Data bits 8
Parity None
Stop bits 1
Flow control None
This must be the same as the configuration of the RS232 peripheral. Feel free
to change the speed of the UART, but beware, if you change the peripheral
parameters you must run hardware synthesis again.
Now you are about to run the system and you need a FPGA board, connect
it (both the USB and the RS232 cables) and switch the power on. The Digilent
boards can be configured with the system you just synthesized using a specific
program, found in start→ all programs→ Xilinx ISE Design Suite 12.2→
Adept (Digilent)→ Adept. At this point you should have a new window
called Digilent Adept. You should be able to see two devices - one being the
FPGA, xc3s1200e, and one being the ROM device for the boot configuration
xcf04s. (If this does not happen, check your USB connection again). We will
only configure the FPGA directly, so click Browse button for the FPGA and
select the download.bit configuration file from your project directory home,
under implementation/. Finally, click the Program button to download the
configuration to the FPGA.
The system should start to run directly. Depending on the application you
selected for BRAM Initialization, you may see some LEDs blinking and text
messages in the hyperterminal (this assumes you are running the peripheral test
application). Press the button labelled BTN0 on the FPGA board to restart
the program (will give a new printout).
XPS keeps track of most dependencies among the source files, so if you
change anything, selecting a download to the FPGA will rebuild all parts that
are affected. You can force XPS to rerun a step by choosing Software→Clean
Software and Hardware→ Clean Hardware. This removes all generated
files, thus it also saves disk space.
5
4 Power and energy consumption
Once you have your system hardware and software, you can estimate its power
and energy consumption. In embedded systems (and not only) power and energy
are very important since they determine the cooling, power supply and battery
lifetime. To get a rough estimate of your system’s power you can use the XPower
Analyzer tool that comes with Xilinx ISE, found in start→ all programs→
Xilinx ISE Design Suite 12.2→ ISE Design Tools→ Tools→ XPower
Analyzer. Once XPower starts, choose File→ Open Design to specify the
design you want to examine. In the dialog that appears, the design file is
necessary, and it is the system.ncd file located in the your project directory, in
implementation subdirectory. This file is the result of hardware synthesis, so it
will only be present if you went through the synthesis step already. You should
at least specify the Physical Constraints File, system.pcf, present in the same
directory2 . Choose OK to start the analysis, and pay attention to the output
comments. Also inspect the tables produced in the main window, since these
gather the power figures for your design.
Once you have the total power for the design, you may multiply this with
the time it takes to execute any of your applications (you will need to use a
timer core and instrument the program to record the number of clock cycles
used - this is detailed later) in order to obtain the energy consumption for that
program.
A tutorial movie showing you how to use the XPower Analyzer is accessible at
http://fileadmin.cs.lth.se/cs/Education/EDA385/HT10/videos/startingXPowerISE12.avi.
5 Dual-processor systems
Let’s continue by creating a dual processor system, that will be needed in lab
3. You may either extend the uni-processor system you are currently using,
or extend a dual-processor system created with the wizard you used before.
The first solution focuses on using FIFOs to communicate between processors,
while the second uses shared memory/mutexes or mailboxes to the same end.
These mechanisms do not exclude each other and can be used at the same time,
granted your system contains the hardware support. Finally by the end of this
section you should be able to have three different ways of sending data between
two processors:
1. FIFOs (Fast Simplex Link)
2. mutex/shared memory (xps mutex and Micron RAM)
6
see how the memory and CPU are connected (CPU↔ LMB↔ LMB controller↔
memory block). Notice that MicroBlaze uses a Harvard architecture, where data
and instructions have separate pathways. On the other hand, the memory blocks
are dual ported, meaning that you can connect both the instruction and data
bus to the same memory block. To add IP components to your design, select
the IP from the IP Catalog tab in the left XPS frame, and double-click on it.
The newly added IP should appear in the System Assembly tab, where you can
also rename the instance. Now add the following:
• one Processor→microblaze,
• one Memory Block→bram block,
• two Memory Controllers→lmb bram if ctrl,
• two Buses→lmb v10,
7
Figure 2: Dual MicroBlaze system view
Finally you also need a program to run on the second processor. In the left
frame, select the Applications tab. You should have two projects. Lets run one
on each processor. To select the target processor for a project open its tree
structure (click on the + to the left), right click on Processor:. . . and select the
target processor. Make sure both projects areMark to Initialize BRAMs (if not
right click on Project:. . . ).
Thats all you need to do. Run hardware synthesis, software compilation,
and configure (download to) the FPGA.
8
Figure 3: Ports Connection
9
MicroBlaze 0: MicroBlaze 1:
#include <mb_interface.h>
#include <mb_interface.h>
#include <xutil.h>
#include <xutil.h>
int main(void){
int main(void){
int i;
int i = 0;
while(1){
while(i<10){
getfsl(i, 0);
putfsl(i, 0);
i++;
getfsl(i, 0);
xil_printf("ping %d\n\r", i);
xil_printf("pong %d\n\r", i);
putfsl(i, 0);
}
}
}
}
10