MicroBlaze
Microcontroller
Reference Design
User Guide v1.3.1
UG133 v1.3.1 January 7, 2005
R
Download from Www.Somanuals.com. All Manuals Search And Download.
MicroBlaze Microcontroller Ref Des User Guide
UG133 v1.3.1 January 7, 2005
The following table shows the revision history for this document.
Version
1.0
Revision
7/22/04
8/27/04
11/19/04
11/30/04
1/7/05
Initial Xilinx release.
1.1
Edited content; imported new images
1.2
Reconfigured book; added new chapter; incorporated edits
Reformatted book to consist of chapters for Overview and RefDes1
Made minor non-technical changes only.
1.3
1.3.1
UG133 v1.3.1 January 7, 2005
MicroBlaze Microcontroller Ref Des User Guide
Download from Www.Somanuals.com. All Manuals Search And Download.
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Guide Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Typographical. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Online Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
MicroBlaze Microcontroller
Reference Design Number 1
Reference Design Building Blocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Features: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Getting Started. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Downloading the Reference Designs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Downloading the Design and Launching XPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Updating and Generation Hardware Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Downloading Design Files to the FPGA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Loading the “Calculator_App” Software Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Running the Calculator_App program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Updating and Generation Hardware Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Additional MicroBlaze and EDK Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
UG133 January 7, 2005
MicroBlaze Microcontroller Ref Des User Guide
Download from Www.Somanuals.com. All Manuals Search And Download.
R
About This Guide
Introduction
This user guide contains information on how to integrate the stand-alone, prebuilt,
MicroBlaze Microcontroller reference design into an FPGA. Although this design is
targeted initially for the Xilinx Spartan-3 Starter Kit Board, the design may be modified
readily for any Xilinx or third party platform.
This guide is an aid in getting started and learning how to use the Xilinx Embedded
Development Kit (EDK) tools. It does this through examples, which show how multiple
software images can be run on a defined soft Microcontroller hardware configuration. This
guide show how an FPGA with a soft processor can be used the same way an engineer
would select an off the shelf microcontroller. This guide will provide examples of a
number of different microcontroller configurations from which an engineer can choose.
The soft microcontroller features and peripherals in the FPGA may be used without
modification, or may be modified and customized using the Xilinx EDK Platform Studio
tools. This guide will cover the flow where multiple software images are load on an
unmodified hardware configuration.
The MicroBaze Microcontroller is an integrated solution intended for implementation of
an embedded controller in FPGA by a user without extensive knowledge of the Xilinx
Embedded Development Kit (EDK) and the Xilinx Platform Studio (XPS). The solution
offered in this document is a minimal implementation that can be expanded easily to
include other peripherals and application software for different usage.
All the necessary documentation, references, HDL code, sample codes, software drivers
and application software are included in the tools or provided with this design.
Guide Contents
This manual contains the following sections:
MicroBlaze Microcontroller Ref Des User Guide
1
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Additional Resources
Additional Resources
of the resources available from this website. You can also directly access these resources
using the provided URLs.
Resource
Tutorials
Description/URL
Tutorials covering Xilinx design flows, from design entry to
verification and debugging
Answer Browser
Database of Xilinx solution records
Application Notes Descriptions of device-specific design techniques and approaches
Data Sheets
Device-specific information on Xilinx device characteristics,
including readback, boundary scan, configuration, length count,
and debugging
Problem Solvers
Tech Tips
Interactive tools that allow you to troubleshoot your design issues
Latest news, design tips, and patch information for the Xilinx
design environment
Conventions
This document uses the following conventions. An example illustrates each convention.
Typographical
The following typographical conventions are used in this document:
Convention
Meaning or Use
Example
Messages, prompts, and
program files that the system speed grade: - 100
Courier font
displays
Literal commands that you
ngdbuild design_name
enter in a syntactical statement
Courier bold
Commands that you select
File → Open
from a menu
Helvetica bold
Keyboard shortcuts
Ctrl+C
MicroBlaze Microcontroller Ref Des User Guide
2
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Conventions
Convention
Meaning or Use
Example
Variables in a syntax
statement for which you must ngdbuild design_name
supply values
See the Development System
Reference Guide for more
information.
Italic font
References to other manuals
Emphasis in text
If a wire is drawn so that it
overlaps the pin of a symbol,
the two nets are not connected.
An optional entry or
parameter. However, in bus
specifications, such as
ngdbuild [option_name]
design_name
Square brackets [ ]
Braces { }
bus[7:0], they are required.
A list of items from which you
must choose one or more
lowpwr ={on|off}
lowpwr ={on|off}
Separates items in a list of
choices
Vertical bar
|
IOB #1: Name = QOUT’
IOB #2: Name = CLKIN’
.
.
.
Vertical ellipsis
.
.
.
Repetitive material that has
been omitted
Repetitive material that has
been omitted
allowblock block_name
loc1 loc2 ... locn;
Horizontal ellipsis . . .
Online Document
The following navigation conventions are used in this document:
Convention
Meaning or Use
Example
See the section “Additional
Resources” for details.
Cross-reference link to a
location in the current
document
Blue text
Refer to “Title Formats” in
Chapter 1 for details.
Cross-reference link to a
location in another document Handbook.
See Figure 2-5 in the Virtex-II
Red text
Go to http://www.xilinx.com
for the latest speed files.
Blue, underlined text
Hyperlink to a website (URL)
MicroBlaze Microcontroller Ref Des User Guide
3
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Microcontroller Reference Design
Overview
Introduction
When selecting an embedded microcontroller, typically an engineer will list the required
features and then select a stand alone, off the shelf microcontroller or processor that has
those features. In most cases there are additional features or peripherals that are not need,
but are included non-the less. When using a Soft Processor in an FPGA an engineer has an
opportunity to select from pre-created microcontroller hardware images, or modify and
customize the features and peripherals.
This guide is provided as an aid in getting started and learning how to use the Xilinx
Embedded Development Kit (EDK) tools. It does this through examples, which show how
multiple software images can run on a defined soft microcontroller hardware
configuration. This guide show how an FPGA with a soft processor can be used the same
way an engineer would select an off the shelf microcontroller. This guide will provide
examples of a number of different microcontroller configurations from which an engineer
can choose. The soft microcontroller features and peripherals in the FPGA may be used
without modification, or may be modified and customized using the Xilinx EDK Platform
Studio tools. This guide will cover the flow where multiple software images are loaded on
an unmodified hardware configuration.
MicroBlaze Microcontroller Ref Des User Guide
1
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Reference Design Building Blocks
MicroBlaze Microcontroller
Reference Design Number 1
Reference Design Building Blocks
The block diagram of the MicroBlaze Microcontroller used in this MicroBlaze
Microcontroller Reference Design is shown in Figure 2-1. The design includes an Internal
Block RAM memory, an RS232 UART, 4 GPIO blocks, and a JTAG_UART used for software
debugging. This configuration utilizes approximately 50% of a Spartan-3™ XC3S200
device.
Figure Top x-ref 2-1
Clock
MicroBlaze DOPB
CPU
Core
OPB
Reset
Interrupt
ILMB
DLMB
4X
GPIO
JTAG_UART
UART
JTAG Ports
A
B
Dual Ported
BlockRAM
(BRAM)
xip312
Figure 2-1: MicroBlaze Microcontroller Block Diagram
Application
Some applications for the MicroBlaze processor include:
•
•
•
•
Industrial Controller
Consumer Application
Office Automation
Data Communication
MicroBlaze Microcontroller Ref Des User Guide
2
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Features:
Features:
•
•
MicroBlaze Microprocessor
♦
50 MHz on the Spartan-3 Starter Kit Board, derived from the 50 MHz crystal on
board
♦
♦
♦
♦
Instruction cache and data cache options disabled
32 32-bit general purpose registers with 32-bit address and 32-bit data buses
Single cycle execution
Direct access to the register file using Fast Simplex Link (FSL)
Unified instruction and data BRAM into single memory for both instruction and data
segments
♦
♦
Dual port 16 KB internal blockRAM memory structure
2-cycle read access from BRAM via the Local Memory Bus (LMB)
•
•
RS232 UART Controller
Pre-configured for 57600 baud rate
General purpose input/output ports (GPIO)
♦
♦
♦
♦
♦
8-bit GPIO configured as output ports to drive LED
12-bit GPIO configured as output ports to drive the 7-segment LEDs on the board
8-bit GPIO configured as input ports to read onboard dip switches
3-bit GPIO configured as input ports to read push buttons
•
JTAG_UART core with Xilinx Microprocessor Debugger (XMD) and GDB debugger to
provide application/software debugging capabilities
♦
♦
♦
XMD uses a JTAG_UART to communicate with xmdstub on the board
xmdstub is an executable software loaded into local system memory at startup
Supports run time control, such as Run, Single Step, Breakpoint, View Registers,
and View Memory, as well as debug parameters
Note: Interrupts are not used in this design. For an example on how to use interrupts, see
the Microblaze design using an OPB interrupt controller and an OPB microprocessor
debug module (MDM) reference design available on the Embedded Design Kit web site at
For documentation on interrupts, see the MicroBlaze Processor Reference Guide in the EDK
documentation.
MicroBlaze Microcontroller Ref Des User Guide
3
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Getting Started
Getting Started
System Requirements
The following software must be installed on your PC to utilize this reference design:
•
•
•
Windows 2000 SP2/Windows XP
EDK 6.3 or later (Must be the same version as ISE)
ISE 6.3i or later
To download the completed reference design, the following hardware is required:
•
Xilinx Spartan-3 Evaluation Board. For information on the evaluation board, see
•
•
Xilinx Parallel Cable used to program and debug the device
Serial Cable for connection to the RS232 UART via HyperTerminal
The next sections of this document will discuss:
•
•
Downloading the reference design and test application
Launching Xilinx Platform Studios (XPS)
Downloading the Reference Designs
Download the reference design, starting with the MB_MCU_RefDes1.zip archive.
Downloading the Design and Launching XPS
download the “MB_MCU_RefDes1.zip” archive.
2. On the target drive, unzip “MB_MCU_RefDes1.zip”. This will automatically create a
subdirectory for the project “MB_MCU_RefDes1.zip”. Assuming that the Xilinx
Platform Studio (XPS) has been installed, launch XPS at this time using
Start>Programs>Xilinx Platform Studio>Xilinx Platform Studio
3. Once in XPS, select the menu option File>Open Project
4. Using the browser, navigate to where the project exists and double-click on
System.xmp.
The system showing the prebuilt MicroBlaze Microcontroller Reference System
MicroBlaze Microcontroller Ref Des User Guide
4
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Downloading the Design and Launching XPS
Figure Top x-ref 2-2
Figure 2-2: Xilinx Platform Studio (XPS)
Updating and Generation Hardware Files
At this point XPS is open with the selected hardware application. No modifications are
needed to run this design. All the hardware features and peripherals have been pre-loaded
and pre-set. The Hardware Application can run any number of Software Applications.
When the Base System Wizard is used to create a Hardware System, it also will create a
simple Software Application to test the selected Hardware features and peripherals
To be sure that all the Hardware files have been created, in XPS, please select
“Tools>Update Bitstream”. This will run any of the programs needed to generate the
Hardware Application for this reference design.
The message panel should read:
...
Memory Initialization completed successfully.
Done.
MicroBlaze Microcontroller Ref Des User Guide
5
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Downloading the Design and Launching XPS
or, if all files are up to date, then it will say:
...
make: Nothing to be done for `init_bram'.
Done.
Downloading Design Files to the FPGA
The following two sections illustrate two methods of downloading a Software Application
into the FPGA. The first method is when the Software Application can be incorporated into
the FPGA bitstream. The second method illustrates loading a selected application into the
FPGA using the GDB debugger for software development and debugging.
Selecting a Software Application to Run When the FPGA is Configured
In this step the Software Application that will be loaded when the FPGA is initially loaded
with a new bitstream will be selected. Please select the XPS Software Application tab.
There are 3 options that can be selected when choosing the Software Application. This first
example will show how a Software Application can be initially added to the FPGA
bitstream. This will configure the MicroBlaze Microcontroller program and Data memory
with the software application already pre-loaded. This means that as soon as the FPGA has
been successfully configured, the MicroBlaze Microcontroller Software Application will
already be running on the MicroBlaze Microcontroller Hardware Application.
In this case, although multiple software applications could overlap in the Bram, only one
software application can be selected at one time. To select the desired application, perform
the following steps:
1. Select the Application tab the XPS window.
2. Right click on Project: Calculator_App.
3. Set “Mark to Initialize BRAMs”. The Project: Calculator_App will have a small green
arrow appear to the left of the text.
4. Confirm that “Mark to Initialize BRAMs” is not checked for the other projects and
default applications. The Graphic to the left of each other application should appear as
a green arrow with a red ‘X’ over it. Verify that this is the case for
‘microblaze_0_bootloop’, ‘microblaze_0_xmdstub’, and ‘Project: TestApp’. If any are
set, please Right click and confirm that “Mark to Initialize BRAMs” is not checked. If
checked, click to deselect it. The green arrow should then appear with a red “X”.
MicroBlaze Microcontroller Ref Des User Guide
6
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Downloading the Design and Launching XPS
Figure 2-3: Software Selection when FPGA is Configured
Loading the “Calculator_App” Software Application
To configure the hardware system and to load the software application into the Spartan-3
Evaluation Board using the Digilent JTAG3 cable, perform the following steps:
1. Connect the Digilent JTAG3 cable to the J7 header on the Spartan-3 Evaluation Board
and connect the other end to the parallel port of the PC. If using the Parallel Cable IV,
make sure that the ‘status’ light is lit on the cable.
2. Connect the Serial cable to J2 on the Spartan-3 Evaluation Board and to the serial port
of the PC. On the PC, using hyperterminal, make certain that the bit rate is set for 57600
bps on the serial port.
3. Turn on the power on to the Spartan-3 Evaluation Board.
4. In XPS, to make sure that the ELF file is up to date, use “Tools>Update Bitstream”.
There may be a warning “Processor microblaze_0 has XMDSTUB-mode application,
but xmdstub.elf is not marked for download, do you want to continue?” Click ‘YES’
5. In XPS, select “Tools>Download” to download the new bitstream into the FPGA. The
xmd-stub warning will appear again. Please click ‘YES’.
Note: Close all other XMD and GDB windows prior to downloading a configuration
bits.
Running the Calculator_App program
After the Calculator_App has been loaded, the hyperterminal should show:
Simple Calculator App for Spartan-3 Starter Kit
Push button to start math operation...
MicroBlaze Microcontroller Ref Des User Guide
7
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Selecting a Software Application to be Loaded with a BOOT Loader after the FPGA is
The Calculator_App is a simple 3 function calculator. The 3 right most push button
switches are Add (BTN0), Sub (BTN1), Mult (BTN2). The left most push button switch
(BTN3) is a program reset, which will clear the calculator program. If the reset is pushed at
this time, then the FPGA will need to be re-loaded.
The eight toggle switches directly under the 7-Segment display are divided into two 4 bit
words. When the Add, Sub, or Mult push button switches are pushed, the selected
calculator operation will be performed on the value of the toggle switches. If the toggle
switches are set to:
Sw7=off, Sw6=off, Sw5=off, Sw4=off, Sw3=off, Sw2=off, Sw1=off, Sw0=off
Where Word 1 is 0 and Word 0 is 0
Add: 0+0=0
Sub: 0-0=0
Mult 0*0=0
If the toggle switches are set to:
Sw7=off, Sw6=off, Sw5=off, Sw4=ON, Sw3=off, Sw2=off, Sw1=ON, Sw0=ON
Where Word 1 is 1 and Word 0 is 3
Add: 3+1=4
Sub: 3-1=2
Mult 3*1=3
Each time one of the Push Button switches is pressed, the result should be displayed in
‘decimal’ on the 7-Seg display, and it will also be sent to the hyperterminal through the
UART. The hyperterminal display should show:
3 + 1 = 4
Push button to start math operation...
3 - 1 = 2
Push button to start math operation...
3 * 1 = 3
Push button to start math operation...
The next section will show how to load this same program after the FPGA has been
configured.
Selecting a Software Application to be Loaded with a BOOT
Loader after the FPGA is Configured and the Processor is Running
This step will show an example of how a Hardware Application can be initially loaded
with a “Stub” program. This will configure the MicroBlaze Microcontroller where it is
waiting to be loaded with the actual Software Application.
Updating and Generation Hardware Files
Please select the XPS software Application tab. There are 3 options that can be selected
when choosing the Software Application. This example will show how a Software
Application can be loaded after the FPGA is configured. A Software Applications can be
MicroBlaze Microcontroller Ref Des User Guide
8
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Selecting a Software Application to be Loaded with a BOOT Loader after the FPGA is
loaded and run, and then a different Software Application can be loaded and run. In this
example the MicroBlaze processor must be loaded with a Software Application through
the use of a stub program.
To select the stub application, perform the following steps:
1. Select the Application tab the XPS window.
2. Right click on Default: microblaze_0_xmdstub.
3. Set “Mark to Initialize BRAMs”. The Default: microblaze_0_xmdstub will have a little
Green Arrow appear to the left of the text.
4. Confirm that “Mark to Initialize BRAMs” is not checked for the other projects and
default applications. The Graphic to the left of each other application should appear as
a green arrow with a red ‘X’ over it. Verify that this is the case for
‘microblaze_0_bootloop’, ‘Project: TestApp’ and Project: Calculator_App. If any are
set, please Right click and confirm that “Mark to Initialize BRAMs” is not checked. If
checked, click to deselect it. The little green arrow should then appear with a red “X”.
Figure 2-4: Software Selection with a BOOT loader
Loading the “microblaze_0_xmdstub” Software Application
To configure the hardware system and to load the software application into the Spartan-3
Evaluation Board using the Digilent JTAG3 cable, perform the following steps:
1. Connect the Digilent JTAG3 cable to the J7 header on the Spartan-3 Evaluation Board
and connect the other end to the parallel port of the PC. If using the Parallel Cable IV,
make sure that the ‘status’ light is lit on the cable.
2. Connect the Serial cable to J2 on the Spartan-3 Evaluation Board and to the serial port
of the PC. On the PC, using hyperterminal, make certain that the bit rate is set for 57600
bps on the serial port.
3. Turn on the power on to the Spartan-3 Evaluation Board.
MicroBlaze Microcontroller Ref Des User Guide
9
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Selecting a Software Application to be Loaded with a BOOT Loader after the FPGA is
4. In XPS, to make sure that the ELF file is up to date, please “Tools>Update Bitstream”.
Note: Close all other XMD and GDB windows prior to downloading a configuration
bits.
5. In XPS, select “Tools>Download” to download the hardware configuration and load
xmdstub into the BRAM memory.
Note: Close all other XMD and GDB windows prior to downloading a configuration
bits.
6. In XPS, select “Tools>XMD” to open an XMD utility.
XMD is a JTAG utility that can be used to download and debug software. XMD is also
a server for GDB, the GNU debugging utility.
Loading the “TestApp” Software Application with XMD_STUB
1. In XPS, select “Tools>Software Debugger” to open the GDB interface (Source
Window).
2. Choose TestApp from the User Application window.
3. In GDB, select the “File>Target Settings” to display the Target Selection dialog box as
5. In Source Window>Run, click RUN, This will download the executable.elf file located
at TestApp directory into the device.
6. In Source Window, the user can select Continue, Single Step, Set Break Point, and view
source code, registers and memory contents.
7. From Control Tag, select “Continue”.
If the Spartan-3 Evaluation Board executes the application test program properly, you
will see flashing LEDs on the board in the Hyper Terminal (57600bps, 8N1).
Note: Begin from step 2 to configure the device prior to loading a new application program and
debugging. Make certain to close all XMD and GDB windows.
Figure Top x-ref 2-3
Figure 2-5: Target Selection for Software Debugger
MicroBlaze Microcontroller Ref Des User Guide
10
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
R
Additional MicroBlaze and EDK Information
Loading the “Calculator_App” Software Application with XMD_STUB
To download and execute the Calculator_App demonstration program, repeat the
procedure in section ‘Loading the “TestApp” Software Application with XMD_STUB’ Start
with step 1 and choose Calculator_App in step 5 instead of TestApp. See Running the
Calculator_App program
Additional MicroBlaze and EDK Information
Congratulations, you have successfully integrated a MicroBlaze Microcontroller into an
FPGA and executed software code.
For additional information on MicroBlaze and the EDK tools, go to
MicroBlaze Microcontroller Ref Des User Guide
11
UG133 January 7, 2005
Download from Www.Somanuals.com. All Manuals Search And Download.
|