The MicroBlaze™ Processor Reference Guide provides information about the 32-bit soft
processor, MicroBlaze, which is included in Vivado. The document is intended as a guide to
the MicroBlaze hardware architecture.
Guide Contents
This guide contains the following chapters:
•Chapter 2, MicroBlaze Architecture contains an overview of MicroBlaze features as well
as information on Big-Endian and Little-Endian bit-reversed format, 32-bit general
purpose registers, cache software support, and AXI4-Stream interfaces.
Chapter 1
•Chapter 3, MicroBlaze Signal Interface Description describes the types of signal
interfaces that can be used to connect MicroBlaze.
•Chapter 4, MicroBlaze Application Binary Interface describes the Application Binary
Interface important for developing software in assembly language for the processor.
•Chapter 5, MicroBlaze Instruction Set Architecture provides notation, formats, and
instructions for the Instruction Set Architecture (ISA) of MicroBlaze.
•Appendix A, Performance and Resource Utilization contains maximum frequencies and
resource utilization numbers for different configurations and devices.
•Appendix B, Additional Resources and Legal Notices provides links to documentation
and additional resources.
MicroBlaze Processor Reference Guide6
UG984 (v2018.2) June 21, 2018www.xilinx.com
MicroBlaze Architecture
Bus
IF
I-Cache
Instruction
Buffer
Instruction
Buffer
Branch Target
Cache
Program
Counter
M_AXI_IC
Memory Management Unit (MMU)
ITLBDTLBUTLB
Bus
IF
D-Cache
M_AXI_DC
M_AXI_DP
DLMB
M0_AXIS ..
M15_AXIS
S0_AXIS ..
S15_AXIS
Special
Purpose
Registers
Instruction
Decode
Register File
32 x 32b
ALU
Shift
Barrel Shift
Multiplier
Divider
FPU
Instruction-side
Bus interface
Data-side
Bus interface
Optional MicroBlaze feature
M_AXI_IP
ILMB
M_ACE_DC
M_ACE_IC
X19738-090717
SendFeedback
Introduction
This chapter contains an overview of MicroBlaze™ features and detailed information on
MicroBlaze architecture including Big-Endian or Little-Endian bit-reversed format, 32-bit
general purpose registers, virtual-memory management, cache software support, and
AXI4-Stream interfaces.
Overview
The MicroBlaze embedded processor soft core is a reduced instruction set computer (RISC)
optimized for implementation in Xilinx® Field Programmable Gate Arrays (FPGAs). The
following figure shows a functional block diagram of the MicroBlaze core.
Chapter 2
X-Ref Target - Figure 2-1
MicroBlaze Processor Reference Guide7
UG984 (v2018.2) June 21, 2018www.xilinx.com
Figure 2-1: MicroBlaze Core Block Diagram
Chapter 2: MicroBlaze Architecture
SendFeedback
Features
The MicroBlaze soft core processor is highly configurable, allowing you to select a specific
set of features required by your design.
The fixed feature set of the processor includes:
•Thirty-two 32-bit general purpose registers
•32-bit instruction word with three operands and two addressing modes
•Default 32-bit address bus, extensible to 64 bits
•Single issue pipeline
In addition to these fixed features, the MicroBlaze processor is parameterized to allow
selective enabling of additional functionality. Older (deprecated) versions of MicroBlaze
support a subset of the optional features described in this manual. Only the latest
(preferred) version of MicroBlaze (v10.0) supports all options.
RECOMMENDED: Xilinx recommends that all new designs use the latest preferred version of the
MicroBlaze processor.
The following table provides an overview of the configurable features by MicroBlaze
versions.
Table 2-1: Configurable Feature Overview by MicroBlaze Version
Table 2-1: Configurable Feature Overview by MicroBlaze Version (Cont’d)
Feature
Disable hardware multiplier
Hardware debug readable ESR and
EAR
Processor Version Register (PVR)
Area or speed optimized
Hardware multiplier 64-bit result
LUT cache memory
Floating-point conversion and
square root instructions
Memory Management Unit (MMU)
Extended stream instructions
Use Cache Interface for All I-Cache
Memory Accesses
Use Cache Interface for All D-Cache
Memory Accesses
Use Write-back Caching Policy for
D-Cache
Branch Target Cache (BTC)
Streams for I-Cache
Victim handling for I-Cache
Victim handling for D-Cache
AXI4 (M_AXI_DP) data side interface
AXI4 (M_AXI_IP) instruction side
interface
AXI4 (M_AXI_DC) protocol for DCache
AXI4 (M_AXI_IC) protocol for ICache
AXI4 protocol for stream accesses
Fault tolerant features
Force distributed RAM for cache
tags
Configurable cache data widths
Count Leading Zeros instruction
Memory Barrier instruction
Stack overflow and underflow
detection
Allow stream instructions in user
mode
1
MicroBlaze versions
v9.2v9.3v9.4v9.5v9.6v10.0
optionoptionoptionoptionoptionoption
YesYesYesYesYesYes
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
YesYesYesYesYesYes
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
MicroBlaze Processor Reference Guide9
UG984 (v2018.2) June 21, 2018www.xilinx.com
Chapter 2: MicroBlaze Architecture
SendFeedback
Table 2-1: Configurable Feature Overview by MicroBlaze Version (Cont’d)
Feature
v9.2v9.3v9.4v9.5v9.6v10.0
Lockstep support
Configurable use of FPGA
primitives
Low-latency interrupt mode
Swap instructions
Sleep mode and sleep instruction
Relocatable base vectors
ACE (M_ACE_DC) protocol for DCache
ACE (M_ACE_IC) protocol for ICache
Extended debug: performance
monitoring, program trace, nonintrusive profiling
Reset mode: enter sleep or debug
halt at reset
Extended debug: external program
trace
Extended data addressing
Pipeline pause functionality
Hibernate and suspend instructions
Non-secure mode
Bit field instructions
2
Parallel debug interface
MMU Physical Address Extension
1. Used for saving DSP48E primitives.
2. Bit field instructions are available when C_USE_BARREL = 1.
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
YesYesYesYesYesYes
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoptionoption
optionoptionoptionoptionoption
optionoptionoptionoptionoption
MicroBlaze versions
optionoptionoptionoption
optionoption
YesYes
YesYes
YesYes
option
option
option
MicroBlaze Processor Reference Guide10
UG984 (v2018.2) June 21, 2018www.xilinx.com
Chapter 2: MicroBlaze Architecture
SendFeedback
Data Types and Endianness
The MicroBlaze processor uses Big-Endian or Little-Endian format to represent data,
depending on the selected endianness. The parameter
endian) by default.
The hardware supported data types for MicroBlaze are word, half word, and byte. When
using the reversed load and store instructions LHUR, LWR, SHR, and SWR, the bytes in the
data are reversed, as indicated by the byte-reversed order.
The following tables show the bit and byte organization for each type.
Table 2-2: Word Data Type
Big-Endian Byte Addressnn+1n+2n+3
Big-Endian Byte SignificanceMSByteLSByte
Big-Endian Byte Ordernn+1n+2n+3
Big-Endian Byte-Reversed Ordern+3n+2n+1n
Little-Endian Byte Addressn+3n+2n+1n
Little-Endian Byte SignificanceMSByteLSByte
Little-Endian Byte Ordern+3n+2n+1n
Little-Endian Byte-Reversed Ordernn+1n+2n+3
Bit Label031
Bit SignificanceMSBitLSBit
C_ENDIANNESS is set to 1 (little-
Table 2-3: Half Word Data Type
Big-Endian Byte Addressnn+1
Big-Endian Byte SignificanceMSByteLSByte
Big-Endian Byte Ordernn+1
Big-Endian Byte-Reversed Ordern+1n
Little-Endian Byte Addressn+1n
Little-Endian Byte SignificanceMSByteLSByte
Little-Endian Byte Ordern+1n
Little-Endian Byte-Reversed Ordernn+1
Bit Label0 15
Bit SignificanceMSBitLSBit
Table 2-4: Byte Data Type
Byte Addressn
Bit Label0 7
Bit SignificanceMSBitLSBit
MicroBlaze Processor Reference Guide11
UG984 (v2018.2) June 21, 2018www.xilinx.com
Instructions
SendFeedback
Instruction Summary
All MicroBlaze instructions are 32 bits and are defined as either Type A or Type B. Type A
instructions have up to two source register operands and one destination register operand.
Type B instructions have one source register and a 16-bit immediate operand (which can be
extended to 32 bits by preceding the Type B instruction with an imm instruction).
Type B instructions have a single destination register operand. Instructions are provided in
the following functional categories: arithmetic, logical, branch, load/store, and special. The
following table describes the instruction set nomenclature used in the semantics of each
instruction.
Instruction Set Architecture, for more information on these instructions.
Table 2-5: Instruction Set Nomenclature
SymbolDescription
Table 2-5 lists the MicroBlaze instruction set. See Chapter 5, MicroBlaze
Chapter 2: MicroBlaze Architecture
RaR0 - R31, General Purpose Register, source operand a
RbR0 - R31, General Purpose Register, source operand b
RdR0 - R31, General Purpose Register, destination operand
SPR[x]Special Purpose Register number x
MSRMachine Status Register = SPR[1]
ESRException Status Register = SPR[5]
EARException Address Register = SPR[3]
FSRFloating-point Unit Status Register = SPR[7]
PVRxProcessor Version Register, where x is the register number = SPR[8192 + x]
BTRBranch Target Register = SPR[11]
PCExecute stage Program Counter = SPR[0]
x[y]Bit y of register x
x[y:z]Bit range y to z of register x
xBit inverted value of register x
Imm16 bit immediate value
Immxx bit immediate value
FSLx4 bit AXI4-Stream port designator, where x is the port number
CCarry flag, MSR[29]
SaSpecial Purpose Register, source operand
SdSpecial Purpose Register, destination operand
s(x)Sign extend argument x to 32-bit value
MicroBlaze Processor Reference Guide12
UG984 (v2018.2) June 21, 2018www.xilinx.com
Table 2-5: Instruction Set Nomenclature (Cont’d)
SendFeedback
SymbolDescription
*AddrMemory contents at location Addr (data-size aligned)
:=Assignment operator
=Equality comparison
!=Inequality comparison
>Greater than comparison
>=Greater than or equal comparison
<Less than comparison
<=Less than or equal comparison
+Arithmetic add
*Arithmetic multiply
/Arithmetic divide
>> xBit shift right x bits
<< xBit shift left x bits
Chapter 2: MicroBlaze Architecture
andLogic AND
orLogic OR
xorLogic exclusive OR
op1 if cond else op2 Perform op1 if condition cond is true, else perform op2
&Concatenate. For example “0000100 & Imm7” is the concatenation of the fixed field
“0000100” and a 7 bit immediate value.
signedOperation performed on signed integer data type. All arithmetic operations are
performed on signed word operands, unless otherwise specified
unsignedOperation performed on unsigned integer data type
floatOperation performed on floating-point data type
clz(r)Count leading zeros
Table 2-6: MicroBlaze Instruction Set Summary
Type A0-56-1011-15 16-2021-31
Semantics
Type B0-56-1011-1516-31
ADD Rd,Ra,Rb000000RdRaRb00000000000 Rd := Rb + Ra
RSUB Rd,Ra,Rb000001RdRaRb00000000000 Rd := Rb + Ra + 1
ADDC Rd,Ra,Rb000010RdRaRb00000000000 Rd := Rb + Ra + C
RSUBC Rd,Ra,Rb000011RdRaRb00000000000 Rd := Rb + Ra + C
ADDK Rd,Ra,Rb000100RdRaRb00000000000 Rd := Rb + Ra
RSUBK Rd,Ra,Rb000101RdRaRb00000000000 Rd := Rb + Ra + 1
MicroBlaze Processor Reference Guide13
UG984 (v2018.2) June 21, 2018www.xilinx.com
Table 2-6: MicroBlaze Instruction Set Summary (Cont’d)
SendFeedback
Chapter 2: MicroBlaze Architecture
Type A0-56-1011-1516-2021-31
Semantics
Type B0-56-1011-1516-31
CMP Rd,Ra,Rb000101RdRaRb00000000001 Rd := Rb + Ra + 1
Rd[0] := 0 if (Rb >= Ra) else
Rd[0] := 1
CMPU Rd,Ra,Rb000101RdRaRb00000000011 Rd := Rb + Ra + 1 (unsigned)
BRLD Rd,Rb100110Rd10100Rb00000000000 PC := PC + Rb
Rd := PC
BRA Rb1001100000001000Rb00000000000 PC := Rb
BRAD Rb1001100000011000Rb00000000000 PC := Rb
BRALD Rd,Rb100110Rd11100Rb00000000000 PC := Rb
Rd := PC
MicroBlaze Processor Reference Guide18
UG984 (v2018.2) June 21, 2018www.xilinx.com
Table 2-6: MicroBlaze Instruction Set Summary (Cont’d)
SendFeedback
Chapter 2: MicroBlaze Architecture
Type A0-56-1011-1516-2021-31
Semantics
Type B0-56-1011-1516-31
BRK Rd,Rb100110Rd01100Rb00000000000 PC := Rb
Rd := PC
MSR[BIP] := 1
BEQ Ra,Rb10011100000RaRb00000000000 PC := PC + Rb if Ra = 0
BNE Ra,Rb10011100001RaRb00000000000 PC := PC + Rb if Ra != 0
BLT Ra,Rb10011100010RaRb00000000000 PC := PC + Rb if Ra < 0
BLE Ra,Rb10011100011RaRb00000000000 PC := PC + Rb if Ra <= 0
BGT Ra,Rb10011100100RaRb00000000000 PC := PC + Rb if Ra > 0
BGE Ra,Rb10011100101RaRb00000000000 PC := PC + Rb if Ra >= 0
BEQD Ra,Rb10011110000RaRb00000000000 PC := PC + Rb if Ra = 0
BNED Ra,Rb10011110001RaRb00000000000 PC := PC + Rb if Ra != 0
BLTD Ra,Rb10011110010RaRb00000000000 PC := PC + Rb if Ra < 0
BLED Ra,Rb10011110011RaRb00000000000 PC := PC + Rb if Ra <= 0
BGTD Ra,Rb10011110100RaRb00000000000 PC := PC + Rb if Ra > 0
BGED Ra,Rb10011110101RaRb00000000000 PC := PC + Rb if Ra >= 0
ORI Rd,Ra,Imm101000RdRaImmRd := Ra or s(Imm)
ANDI Rd,Ra,Imm101001RdRaImmRd := Ra and s(Imm)
XORI Rd,Ra,Imm101010RdRaImmRd := Ra xor s(Imm)
ANDNI Rd,Ra,Imm101011RdRaImmRd := Ra and s(Imm)
IMM Imm1011000000000000ImmImm[0:15] := Imm
RTSD Ra,Imm10110110000RaImmPC := Ra + s(Imm)
RTID Ra,Imm10110110001RaImmPC := Ra + s(Imm)
MSR[IE] := 1
RTBD Ra,Imm10110110010RaImmPC := Ra + s(Imm)
MSR[BIP] := 0
RTED Ra,Imm10110110100RaImmPC := Ra + s(Imm)
MSR[EE] := 1, MSR[EIP] := 0
ESR := 0
BRI Imm1011100000000000ImmPC := PC + s(Imm)
MBAR Imm101110Imm000100000000000000100PC := PC + 4; Wait for memory
accesses.
BRID Imm1011100000010000ImmPC := PC + s(Imm)
BRLID Rd,Imm101110Rd10100ImmPC := PC + s(Imm)
Rd := PC
BRAI Imm1011100000001000ImmPC := s(Imm)
MicroBlaze Processor Reference Guide19
UG984 (v2018.2) June 21, 2018www.xilinx.com
Table 2-6: MicroBlaze Instruction Set Summary (Cont’d)
SendFeedback
Chapter 2: MicroBlaze Architecture
Type A0-56-1011-1516-2021-31
Semantics
Type B0-56-1011-1516-31
BRAID Imm1011100000011000ImmPC := s(Imm)
BRALID Rd,Imm101110Rd11100ImmPC := s(Imm)
Rd := PC
BRKI Rd,Imm101110Rd01100ImmPC := s(Imm)
Rd := PC
MSR[BIP] := 1
BEQI Ra,Imm10111100000RaImmPC := PC + s(Imm) if Ra = 0
BNEI Ra,Imm10111100001RaImmPC := PC + s(Imm) if Ra != 0
BLTI Ra,Imm10111100010RaImmPC := PC + s(Imm) if Ra < 0
BLEI Ra,Imm10111100011RaImmPC := PC + s(Imm) if Ra <= 0
BGTI Ra,Imm10111100100RaImmPC := PC + s(Imm) if Ra > 0
BGEI Ra,Imm10111100101RaImmPC := PC + s(Imm) if Ra >= 0
BEQID Ra,Imm10111110000RaImmPC := PC + s(Imm) if Ra = 0
BNEID Ra,Imm10111110001RaImmPC := PC + s(Imm) if Ra != 0
BLTID Ra,Imm10111110010RaImmPC := PC + s(Imm) if Ra < 0
BLEID Ra,Imm10111110011RaImmPC := PC + s(Imm) if Ra <= 0
BGTID Ra,Imm10111110100RaImmPC := PC + s(Imm) if Ra > 0
BGEID Ra,Imm10111110101RaImmPC := PC + s(Imm) if Ra >= 0
LBU Rd,Ra,Rb
LBUR Rd,Ra,Rb
LBUEA Rd,Ra,Rb110000RdRaRb00010000000 Addr := Ra & Rb
LHU Rd,Ra,Rb
LHUR Rd,Ra,Rb
LHUEA Rd,Ra,Rb110001RdRaRb00010000000 Addr := Ra & Rb
LW Rd,Ra,Rb
LWR Rd,Ra,Rb
LWX Rd,Ra,Rb110010RdRaRb10000000000 Addr := Ra + Rb
110000RdRaRb00000000000
01000000000
110001RdRaRb00000000000
01000000000
110010RdRaRb00000000000
01000000000
Addr := Ra + Rb
Rd[0:23] := 0
Rd[24:31] := *Addr[0:7]
Rd[0:23] := 0
Rd[24:31] := *Addr[0:7]
Addr := Ra + Rb
Rd[0:15] := 0
Rd[16:31] := *Addr[0:15]
Rd[0:15] := 0
Rd[16:31] := *Addr[0:15]
Addr := Ra + Rb
Rd := *Addr
Rd := *Addr
Reservation := 1
MicroBlaze Processor Reference Guide20
UG984 (v2018.2) June 21, 2018www.xilinx.com
Table 2-6: MicroBlaze Instruction Set Summary (Cont’d)
SendFeedback
Chapter 2: MicroBlaze Architecture
Type A0-56-1011-1516-2021-31
Semantics
Type B0-56-1011-1516-31
LWEA Rd,Ra,Rb110010RdRaRb00010000000 Addr := Ra & Rb
Rd := *Addr
SB Rd,Ra,Rb
SBR Rd,Ra,Rb
SBEA Rd,Ra,Rb110100RdRaRb00010000000 Addr := Ra & Rb
SH Rd,Ra,Rb
SHR Rd,Ra,Rb
SHEA Rd,Ra,Rb110101RdRaRb00010000000 Addr := Ra & Rb
SW Rd,Ra,Rb
SWR Rd,Ra,Rb
SWX Rd,Ra,Rb110110RdRaRb10000000000 Addr := Ra + Rb
SWEA Rd,Ra,Rb110110RdRaRb00010000000 Addr := Ra & Rb
110100RdRaRb00000000000
01000000000
110101RdRaRb00000000000
01000000000
110110RdRaRb00000000000
01000000000
Addr := Ra + Rb
*Addr[0:8] := Rd[24:31]
*Addr[0:8] := Rd[24:31]
Addr := Ra + Rb
*Addr[0:16] := Rd[16:31]
*Addr[0:16] := Rd[16:31]
Addr := Ra + Rb
*Addr := Rd
*Addr := Rd if Reservation = 1
Reservation := 0
*Addr := Rd
LBUI Rd,Ra,Imm111000RdRaImmAddr := Ra + s(Imm)
Rd[0:23] := 0
Rd[24:31] := *Addr[0:7]
LHUI Rd,Ra,Imm111001RdRaImmAddr := Ra + s(Imm)
Rd[0:15] := 0
Rd[16:31] := *Addr[0:15]
LWI Rd,Ra,Imm111010RdRaImmAddr := Ra + s(Imm)
Rd := *Addr
SBI Rd,Ra,Imm111100RdRaImmAddr := Ra + s(Imm)
*Addr[0:7] := Rd[24:31]
SHI Rd,Ra,Imm111101RdRaImmAddr := Ra + s(Imm)
*Addr[0:15] := Rd[16:31]
SWI Rd,Ra,Imm111110RdRaImmAddr := Ra + s(Imm)
*Addr := Rd
1. Due to the many different corner cases involved in floating-point arithmetic, only the normal behavior is described. A full
description of the behavior can be found in Chapter 5, “MicroBlaze Instruction Set Architecture.”
MicroBlaze Processor Reference Guide21
UG984 (v2018.2) June 21, 2018www.xilinx.com
Chapter 2: MicroBlaze Architecture
SendFeedback
Semaphore Synchronization
The LWX and SWX instructions are used to implement common semaphore operations,
including test and set, compare and swap, exchange memory, and fetch and add. They are
also used to implement spinlocks.
These instructions are typically used by system programs and are called by application
programs as needed.
Generally, a program uses LWX to load a semaphore from memory, causing the reservation
to be set (the processor maintains the reservation internally). The program can compute a
result based on the semaphore value and conditionally store the result back to the same
memory location using the SWX instruction. The conditional store is performed based on
the existence of the reservation established by the preceding LWX instruction. If the
reservation exists when the store is executed, the store is performed and MSR[C] is cleared
to 0. If the reservation does not exist when the store is executed, the target memory
location is not modified and MSR[C] is set to 1.
If the store is successful, the sequence of instructions from the semaphore load to the
semaphore store appear to be executed atomically—no other device modified the
semaphore location between the read and the update. Other devices can read from the
semaphore location during the operation.
For a semaphore operation to work properly, the LWX instruction must be paired with an
SWX instruction, and both must specify identical addresses.
The reservation granularity in MicroBlaze is a word. For both instructions, the address must
be word aligned. No unaligned exceptions are generated for these instructions.
The conditional store is always attempted when a reservation exists, even if the store
address does not match the load address that set the reservation.
Only one reservation can be maintained at a time. The address associated with the
reservation can be changed by executing a subsequent LWX instruction.
The conditional store is performed based upon the reservation established by the last LWX
instruction executed. Executing an SWX instruction always clears a reservation held by the
processor, whether the address matches that established by the LWX or not.
Reset, interrupts, exceptions, and breaks (including the BRK and BRKI instructions) all clear
the reservation.
The following provides general guidelines for using the LWX and SWX instructions:
•The LWX and SWX instructions should be paired and use the same address.
MicroBlaze Processor Reference Guide22
UG984 (v2018.2) June 21, 2018www.xilinx.com
•An unpaired SWX instruction to an arbitrary address can be used to clear any
reservation held by the processor.
Chapter 2: MicroBlaze Architecture
SendFeedback
•A conditional sequence begins with an LWX instruction. It can be followed by memory
accesses and/or computations on the loaded value. The sequence ends with an SWX
instruction. In most cases, failure of the SWX instruction should cause a branch back to
the LWX for a repeated attempt.
•An LWX instruction can be left unpaired when executing certain synchronization
primitives if the value loaded by the LWX is not zero. An implementation of Test and Set
exemplifies this:
loop: lwx r5,r3,r0; load and reserve
bneir5,next; branch if not equal to zero
addik r5,r5,1; increment value
swxr5,r3,r0; try to store non-zero value
addic r5,r0,0; check reservation
bneir5,loop; loop if reservation lost
next:
•Performance can be improved by minimizing looping on an LWX instruction that fails to
return a desired value. Performance can also be improved by using an ordinary load
instruction to do the initial value check. An implementation of a spinlock exemplifies
this:
loop: lwr5,r3,r0; load the word
bneir5,loop; loop back if word not equal to 0
lwxr5,r3,r0; try reserving again
bneir5,loop; likely that no branch is needed
addik r5,r5,1; increment value
swxr5,r3,r0 ; try to store non-zero value
addic r5,r0,0; check reservation
bneir5,loop; loop if reservation lost
•Minimizing the looping on an LWX/SWX instruction pair increases the likelihood that
forward progress is made. The old value should be tested before attempting the store.
If the order is reversed (store before load), more SWX instructions are executed and
reservations are more likely to be lost between the LWX and SWX instructions.
Self-modifying Code
When using self-modifying code software must ensure that the modified instructions have
been written to memory prior to fetching them for execution. There are several aspects to
consider:
MicroBlaze Processor Reference Guide23
UG984 (v2018.2) June 21, 2018www.xilinx.com
Chapter 2: MicroBlaze Architecture
SendFeedback
•The instructions to be modified could already have been fetched prior to modification:
Into the instruction prefetch buffer
-
Into the instruction cache, if it is enabled
-
Into a stream buffer, if instruction cache stream buffers are used
-
Into the instruction cache, and then saved in a victim buffer, if victim buffers are
-
used.
To ensure that the modified code is always executed instead of the old unmodified
code, software must handle all these cases.
•If one or more of the instructions to be modified is a branch, and the branch target
cache is used, the branch target address might have been cached.
To avoid using the cached branch target address, software must ensure that the branch
target cache is cleared prior to executing the modified code.
•The modified instructions might not have been written to memory prior to execution:
They might be en-route to memory, in temporary storage in the interconnect or the
-
memory controller.
They might be stored in the data cache, if write-back cache is used.
-
They might be saved in a victim buffer, if write-back cache and victim buffers are
-
used.
Software must ensure that the modified instructions have been written to memory before
being fetched by the processor.
The annotated code below shows how each of the above issues can be addressed. This code
assumes that both instruction cache and write-back data cache is used. If not, the
corresponding instructions can be omitted.
The following code exemplifies storing a modified instruction:
swir5,r6,0 ; r5 = new instruction
; r6 = physical instruction address
wdc.flush r6,r0; flush write-back data cache line
mbar1; ensure new instruction is written to memory
wicr7,r0; invalidate line, empty stream & victim buffers
The physical and virtual addresses above are identical, unless MMU virtual mode is used. If
the MMU is enabled, the code sequences must be executed in real mode, because WIC and
WDC are privileged instructions. The first instruction after the code sequences above must
not be modified, because it might have been prefetched.
X-Ref Target - Figure 2-2
R0 – R31
031
X19739-091117
SendFeedback
Chapter 2: MicroBlaze Architecture
Registers
MicroBlaze has an orthogonal instruction set architecture. It has thirty-two 32-bit general
purpose registers and up to eighteen 32-bit special purpose registers, depending on
configured options.
General Purpose Registers
The thirty-two 32-bit General Purpose Registers are numbered R0 through R31. The register
file is reset on bit stream download (reset value is 0x00000000). The following figure is a
representation of a General Purpose Register and
register and the register reset value (if existing).
Note: The register file is not reset by the external reset inputs: Reset and Debug_Rst.
Table 2-7 provides a description of each
Figure 2-2: R0-R31
Table 2-7: General Purpose Registers (R0-R31)
BitsNameDescriptionReset Value
0:31R0Always has a value of zero. Anything written to R0 is
discarded
0:31R1 through R1332-bit general purpose registers-
0:31R1432-bit register used to store return addresses for
interrupts.
0:31R1532-bit general purpose register. Recommended for storing
return addresses for user vectors.
0:31R1632-bit register used to store return addresses for breaks.-
0:31R17If MicroBlaze is configured to support hardware
exceptions, this register is loaded with the address of the
instruction following the instruction causing the HW
exception, except for exceptions in delay slots that use BTR
instead (see
general purpose register.
0:31R18 through R31 R18 through R31 are 32-bit general purpose registers.-
Branch Target Register (BTR)); if not, it is a
0x00000000
-
-
-
See Table 4-2 for software conventions on general purpose register usage.
MicroBlaze Processor Reference Guide25
UG984 (v2018.2) June 21, 2018www.xilinx.com
X-Ref Target - Figure 2-3
31
PC
0
X19740-082517
31
RES
ReservedCC
0
3029282726252423222120191817
IECBIPFSLICEDZODCEEEEIPPVRUMUMSVMVMS
X19741-091117
SendFeedback
Chapter 2: MicroBlaze Architecture
Special Purpose Registers
Program Counter (PC)
The program counter (PC) is the 32-bit address of the execution instruction. It can be read
with an MFS instruction, but it cannot be written with an MTS instruction. When used with
the MFS instruction the PC register is specified by setting Sa = 0x0000. The following figure
illustrates the PC and
Table 2-8: Program Counter (PC)
BitsNameDescriptionReset Value
Table 2-8 provides a description and reset value.
Figure 2-3: PC
X-Ref Target - Figure 2-4
0:31PCProgram Counter
Address of executing instruction, that is, “mfs r2, 0” stores the
address of the mfs instruction itself in R2.
0x00000000
Machine Status Register (MSR)
The Machine Status Register contains control and status bits for the processor. It can be
read with an MFS instruction. When reading the MSR, bit 29 is replicated in bit 0 as the carry
copy. MSR can be written using either an
MSRCLR instructions.
When writing to the MSR using MSRSET or MSRCLR, the Carry bit takes effect immediately
and the remaining bits take effect one clock cycle later. When writing using MTS, all bits
take effect one clock cycle later. Any value written to bit 0 is discarded.
When used with an MTS or MFS instruction, the MSR is specified by setting Sx = 0x0001.
The following table illustrates the MSR register and
and reset values.
MTS instruction or the dedicated MSRSET and
Table 2-9 provides the bit description
MicroBlaze Processor Reference Guide26
UG984 (v2018.2) June 21, 2018www.xilinx.com
Figure 2-4: MSR
Chapter 2: MicroBlaze Architecture
SendFeedback
Table 2-9: Machine Status Register (MSR)
BitsNameDescriptionReset Value
0CCArithmetic Carry Copy
Copy of the Arithmetic Carry (bit 29). CC is always the same as bit C.
1:16Reserved
17VMSVirtual Protected Mode Save
Only available when configured with an MMU
(if C_USE_MMU > 1 and C_AREA_OPTIMIZED = 0 or 2)
Read/Write
18VMVirtual Protected Mode
0 = MMU address translation and access protection disabled, with
1 = User Mode, certain instructions are not allowed
Only available when configured with an MMU
(if C_USE_MMU > 0 and C_AREA_OPTIMIZED = 0 or 2)
Read/Write
21PVRProcessor Version Register exists
0 = No Processor Version Register
1 = Processor Version Register exists
Read only
22EIPException In Progress
0 = No hardware exception in progress
1 = Hardware exception in progress
Only available if configured with exception support
C_*_EXCEPTION or C_USE_MMU > 0)
(
Read/Write
0
Based on
parameter
C_PVR
0
MicroBlaze Processor Reference Guide27
UG984 (v2018.2) June 21, 2018www.xilinx.com
Chapter 2: MicroBlaze Architecture
SendFeedback
Table 2-9: Machine Status Register (MSR) (Cont’d)
BitsNameDescriptionReset Value
23EEException Enable
0 = Hardware exceptions disabled
1 = Hardware exceptions enabled
Only available if configured with exception support
C_*_EXCEPTION or C_USE_MMU > 0)
(
Read/Write
24DCEData Cache Enable
0 = Data Cache disabled
1 = Data Cache enabled
Only available if configured to use data cache (C_USE_DCACHE = 1)
Read/Write
25DZODivision by Zero or Division Overflow
0 = No division by zero or division overflow has occurred
1 = Division by zero or division overflow has occurred
Only available if configured to use hardware divider
(C_USE_DIV = 1)
Read/Write
26ICEInstruction Cache Enable
0 = Instruction Cache disabled
1 = Instruction Cache enabled
Only available if configured to use instruction cache
(C_USE_ICACHE = 1)
Read/Write
1
0
0
2
0
0
MicroBlaze Processor Reference Guide28
UG984 (v2018.2) June 21, 2018www.xilinx.com
27FSLAXI4-Stream Error
0 = get or getd had no error
1 = get or getd control type mismatch
This bit is sticky, that is it is set by a get or getd instruction when a
control bit mismatch occurs. To clear it an MTS or MSRCLR instruction
must be used.
Only available if configured to use stream links (C_FSL_LINKS > 0)
Read/Write
28BIPBreak in Progress
0 = No Break in Progress
1 = Break in Progress
Break Sources can be software break instruction or hardware break
Ext_Brk or Ext_NM_Brk pin.
from
Read/Write
0
0
Chapter 2: MicroBlaze Architecture
C_ADDR_SIZE - 1
EAR
0
X19742-082517
SendFeedback
Table 2-9: Machine Status Register (MSR) (Cont’d)
BitsNameDescriptionReset Value
29CArithmetic Carry
0 = No Carry (Borrow)
1 = Carry (No Borrow)
Read/Write
30IEInterrupt Enable
0 = Interrupts disabled
1 = Interrupts enabled
Read/Write
31-Reserved0
1. The MMU exceptions (Data Storage Exception, Instruction Storage Exception, Data TLB Miss Exception, Instruction
TLB Miss Exception) cannot be disabled, and are not affected by this bit.
2. This bit is only used for integer divide-by-zero or divide overflow signaling. There is a floating-point equivalent in
the FSR. The DZO-bit flags divide by zero or divide overflow conditions regardless if the processor is configured
with exception handling or not.
0
0
Exception Address Register (EAR)
The Exception Address Register stores the full load/store address that caused the exception
for the following:
•An unaligned access exception that specifies the unaligned access data address
X-Ref Target - Figure 2-5
•An
M_AXI_DP exception that specifies the failing AXI4 data access address
•A data storage exception that specifies the (virtual) effective address accessed
•An instruction storage exception that specifies the (virtual) effective address read
•A data TLB miss exception that specifies the (virtual) effective address accessed
•An instruction TLB miss exception that specifies the (virtual) effective address read
The contents of this register is undefined for all other exceptions. When read with the MFS
or MFSE instruction, the EAR is specified by setting Sa = 0x0003. The EAR register is
illustrated in the following figure and
Table 2-10 provides bit descriptions and reset values.
With extended data addressing is enabled (parameter C_ADDR_SIZE > 32), the 32 least
significant bits of the register are read with the MFS instruction, and the most significant
bits with the MFSE instruction.
Figure 2-5: EAR
MicroBlaze Processor Reference Guide29
UG984 (v2018.2) June 21, 2018www.xilinx.com
X-Ref Target - Figure 2-6
31
EC
19
Reserved
2726
20
ESS
DS
X19743-082517
SendFeedback
Chapter 2: MicroBlaze Architecture
Table 2-10: Exception Address Register (EAR)
BitsNameDescriptionReset Value
0:C_ADDR_SIZE-1EARException Address Register0
Exception Status Register (ESR)
The Exception Status Register contains status bits for the processor. When read with the
MFS instruction, the ESR is specified by setting Sa = 0x0005. The ESR register is illustrated
in the following figure,
provides the Exception Specific Status (ESS).
Table 2-11 provides bit descriptions and reset values, and Table 2-12
Figure 2-6: ESR
Table 2-11: Exception Status Register (ESR)
BitsNameDescriptionReset Value
0:18Reserved
19DSDelay Slot Exception.
0 = not caused by delay slot instruction
1 = caused by delay slot instruction
Read-only
20:26ESSException Specific Status
For details, see Table 2-12.
Read-only
Table 2-12
0
See
MicroBlaze Processor Reference Guide30
UG984 (v2018.2) June 21, 2018www.xilinx.com
Loading...
+ 286 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.