NOTICEOFDISCLAIMER:Xilinxis providing this design, code, or information "as is." By providing the design, code, or information as one
possible implementation of this feature, application, or standard, Xilinx makes no representation that this implementation is free from any
claims of infringement. You are responsible for obtaining any rights you may require for your implementation. Xilinx expressly disclaims any
warranty whatsoever with respect to the adequacy of the implementation, including but not limited to any warranties or representations that
this implementation is free from claims of infringement and any implied warranties of merchantability or fitness for a particular purpose.
MicroBlaze Processor Reference Guidewww.xilinx.comUG081 (v6.0) June 1, 2006
1-800-255-7778
MicroBlaze Processor Reference Guide
UG081 (v6.0) June 1, 2006
The following table shows the revision history for this document.
UG081 (v6.0) June 1, 2006www.xilinx.comMicroBlaze Processor Reference Guide
1-800-255-7778
R
About This Guide
Welcome to the MicroBlaze Processor Reference Guide. This document provides
information about the 32-bit soft processor MicroBlaze, which is part of the Embedded
Processor Development Kit (EDK). The document is intended as a guide to the MicroBlaze
hardware architecture.
Manual Contents
This manual discusses the following topics specific to MicroBlaze soft processor:
•Core Architecture
•Bus Interfaces and Endianness
•Application Binary Interface
•Instruction Set Architecture
Preface
Additional Resources
For additional information, go to http://support.xilinx.com. The following table lists
some of the resources you can access from this web-site. You can also directly access these
resources using the provided URLs.
ResourceDescription/URL
TutorialsTutorials covering Xilinx design flows, from design entry to
Answer BrowserDatabase of Xilinx solution records
Application NotesDescriptions of device-specific design techniques and approaches
Data BookPages from The Programmable Logic Data Book, which contains
The MicroBlaze embedded processor soft core is a reduced instruction set computer (RISC)
optimized for implementation in Xilinx field programmable gate arrays (FPGAs).
Figure 1-1 shows a functional block diagram of the MicroBlaze core.
Chapter 1
IXCL_M
IXCL_S
Features
bus interfacebus interface
I-Cache
IOPB
ILMB
Bus
IF
Optional MicroBlaze feature
Program
Counter
Instruction
Special
Purpose
Registers
Buffer
Instruction
Decode
ALU
Shift
Barrel Shift
Multiplier
Divider
FPU
Register File
32 X 32b
Figure 1-1:MicroBlaze Core Block Diagram
Data-sideInstruction-side
D-Cache
Bus
IF
DXCL_M
DXCL_S
DOPB
DLMB
MFSL 0..7
SFSL 0..7
The MicroBlaze soft core processor is highly configurable, allowing users to select a
specific set of features required by their design.
The processor’s fixed feature set includes:
•Thirty-two 32-bit general purpose registers
•32-bit instruction word with three operands and two addressing modes
In addition to these fixed features the MicroBlaze processor is parametrized 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 (active)
version of MicroBlaze (v5.00a) supports all options.
Xilinx recommends that all new designs use the latest active version of the MicroBlaze
processor.
Table 1-1:Configurable Feature Overview by MicroBlaze Version
MicroBlaze Versions
Feature
v2.10av3.00av4.00av5.00a
Version Statusdeprecateddeprecateddeprecatedactive
Processor pipeline depth3335
On-chip Peripheral Bus (OPB) data side interfaceoptionoptionoptionoption
On-chip Peripheral Bus (OPB) instruction side interfaceoptionoptionoptionoption
Local Memory Bus (LMB) data side interfaceoptionoptionoptionoption
Local Memory Bus (LMB) instruction side interfaceoptionoptionoptionoption
Hardware barrel shifteroptionoptionoptionoption
Hardware divideroptionoptionoptionoption
Hardware debug logicoptionoptionoptionoption
Fast Simplex Link (FSL) interfaces0-70-70-70-7
Machine status set and clear instructionsoptionoptionoptionYes
Instruction cache over IOPB interfaceoptionoptionoptionNo
Data cache over IOPB interfaceoptionoptionoptionNo
Instruction cache over CacheLink (IXCL) interface-optionoptionoption
Data cache over CacheLink (DXCL) interface-optionoptionoption
4 or 8-word cache line on XCL-44option
Hardware exception support-optionoptionoption
Pattern compare instructions--optionYes
Floating point unit (FPU)--optionoption
Disable hardware multiplier
1
--optionoption
Hardware debug readable ESR and EAR--YesYes
Processor Version Register (PVR)---option
1. Used in Virtex-II and subsequent families, for saving MUL18 and DSP48 primitives
MicroBlaze uses Big-Endian, bit-reversed format to represent data. The hardware
supported data types for MicroBlaze are word, half word, and byte. The bit and byte
organization for each type is shown in the following tables.
Table 1-2:Word Data Type
R
Byte addressnn+1n+2n+3
Byte label0123
Byte
significance
Bit label031
Bit significanceMSBitLSBit
Table 1-3:Half Word Data Type
Byte addressnn+1
Byte label01
Byte
significance
Bit label015
Bit significanceMSBitLSBit
Table 1-4:Byte Data Type
Byte addressn
Bit label07
MSByteLSByte
MSByteLSByte
Bit significanceMSBitLSBit
Instructions
All MicroBlaze instructions are 32 bits and are defined as either Type A or TypeB. Type A
instructions have up to two source register operands and one destination register operand.
TypeB instructions have one sourceregister 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.
Table 1-6 lists the MicroBlaze instruction set. Refer to Chapter 4, “MicroBlaze Instruction
Set Architecture”, for more information on these instructions. Table 1-5 describes the
instruction set nomenclature used in the semantics of each instruction.
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
FSLx3 bit Fast Simplex Link (FSL) 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
*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
andLogic AND
orLogic OR
xorLogic exclusive OR
op1 if cond else op2Perform op1 if condition cond is true, else perform op2
&Concatenate. E.g. “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
R
Table 1-6:MicroBlaze Instruction Set Summary
Type A0-56-1011-15 16-2021-31
Semantics
Type B0-56-1011-1516-31
ADD Rd,Ra,Rb000000RdRaRb00000000000Rd := Rb + Ra
RSUB Rd,Ra,Rb000001RdRaRb00000000000Rd := Rb + Ra + 1
ADDC Rd,Ra,Rb000010RdRaRb00000000000Rd := Rb + Ra + C
RSUBC Rd,Ra,Rb000011RdRaRb00000000000Rd := Rb + Ra + C
ADDK Rd,Ra,Rb000100RdRaRb00000000000Rd := Rb + Ra
RSUBK Rd,Ra,Rb000101RdRaRb00000000000Rd := Rb + Ra + 1
ADDKC Rd,Ra,Rb000110RdRaRb00000000000Rd := Rb + Ra + C
RSUBKC Rd,Ra,Rb000111RdRaRb00000000000Rd := Rb + Ra + C
CMP Rd,Ra,Rb000101RdRaRb00000000001Rd := Rb + Ra + 1
Rd[0] := 0 if (Rb >= Ra) else
Rd[0] := 1
CMPU Rd,Ra,Rb000101RdRaRb00000000011Rd := Rb + Ra + 1 (unsigned)
Rd[0] := 0 if (Rb >= Ra, unsigned) else
Rd[0] := 1
ADDI Rd,Ra,Imm001000RdRaImmRd := s(Imm) + Ra
RSUBI Rd,Ra,Imm001001RdRaImmRd := s(Imm) + Ra + 1
ADDIC Rd,Ra,Imm001010RdRaImmRd := s(Imm) + Ra + C
RSUBIC Rd,Ra,Imm001011RdRaImmRd := s(Imm) + Ra + C
ADDIK Rd,Ra,Imm001100RdRaImmRd := s(Imm) + Ra
RSUBIK Rd,Ra,Imm001101RdRaImmRd := s(Imm) + Ra + 1
Table 1-6:MicroBlaze Instruction Set Summary (Continued)
Type A0-56-1011-15 16-2021-31
Type B0-56-1011-1516-31
R
Semantics
PUT Ra,FSLx01101100000Ra1000000000000 &
FSLx := Ra (blocking data write)
FSLx
NGET Rd,FSLx011011Rd000000100000000000 &
FSLx
Rd := FSLx (non-blocking data read)
MSR[FSL] := 1 if (FSLx_S_Control = 1)
MSR[C] := not FSLx_S_Exists
NPUT Ra,FSLx01101100000Ra1100000000000 &
FSLx
CGET Rd,FSLx011011Rd000000010000000000 &
FSLx
CPUT Ra,FSLx01101100000Ra1010000000000 &
FSLx := Ra (non-blocking data write)
MSR[C] := FSLx_M_Full
Rd := FSLx (blocking control read)
MSR[FSL] := 1 if (FSLx_S_Control = 0)
FSLx := Ra (blocking control write)
FSLx
NCGET Rd,FSLx011011Rd000000110000000000 &
FSLx
Rd := FSLx (non-blocking control read)
MSR[FSL] := 1 if (FSLx_S_Control = 0)
MSR[C] := not FSLx_S_Exists
NCPUT Ra,FSLx01101100000Ra1110000000000 &
FSLx
FSLx := Ra (non-blocking control write)
MSR[C] := FSLx_M_Full
OR Rd,Ra,Rb100000RdRaRb00000000000Rd := Ra or Rb
AND Rd,Ra,Rb100001RdRaRb00000000000Rd := Ra and Rb
XOR Rd,Ra,Rb100010RdRaRb00000000000Rd := Ra xor Rb
ANDN Rd,Ra,Rb100011RdRaRb00000000000Rd := Ra and
Rb
PCMPBF Rd,Ra,Rb100000RdRaRb10000000000Rd := 1 if (Rb[0:7] = Ra[0:7]) else
MSR := MSR or Imm14
BR Rb1001100000000000Rb00000000000PC := PC + Rb
BRD Rb1001100000010000Rb00000000000PC := PC + Rb
BRLD Rd,Rb100110Rd10100Rb00000000000PC := PC + Rb
Rd := PC
BRA Rb1001100000001000Rb00000000000PC := Rb
BRAD Rb1001100000011000Rb00000000000PC := Rb
BRALD Rd,Rb100110Rd11100Rb00000000000PC := Rb
Rd := PC
BRK Rd,Rb100110Rd01100Rb00000000000PC := Rb
Rd := PC
MSR[BIP] := 1
BEQ Ra,Rb10011100000RaRb00000000000PC := PC + Rb if Ra = 0
BNE Ra,Rb10011100001RaRb00000000000PC := PC + Rb if Ra != 0
BLT Ra,Rb10011100010RaRb00000000000PC := PC + Rb if Ra < 0
BLE Ra,Rb10011100011RaRb00000000000PC := PC + Rb if Ra <= 0
BGT Ra,Rb10011100100RaRb00000000000PC := PC + Rb if Ra > 0
BGE Ra,Rb10011100101RaRb00000000000PC := PC + Rb if Ra >= 0
BEQD Ra,Rb10011110000RaRb00000000000PC := PC + Rb if Ra = 0
BNED Ra,Rb10011110001RaRb00000000000PC := PC + Rb if Ra != 0
BLTD Ra,Rb10011110010RaRb00000000000PC := PC + Rb if Ra < 0
BLED Ra,Rb10011110011RaRb00000000000PC := PC + Rb if Ra <= 0
Table 1-6:MicroBlaze Instruction Set Summary (Continued)
Type A0-56-1011-15 16-2021-31
Semantics
Type B0-56-1011-1516-31
BGTD Ra,Rb10011110100RaRb00000000000PC := PC + Rb if Ra > 0
BGED Ra,Rb10011110101RaRb00000000000PC := 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)
R
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)
BRID Imm1011100000010000ImmPC := PC + s(Imm)
BRLID Rd,Imm101110Rd10100ImmPC := PC + s(Imm)
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
Table 1-6:MicroBlaze Instruction Set Summary (Continued)
Type A0-56-1011-15 16-2021-31
Semantics
Type B0-56-1011-1516-31
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,Rb110000RdRaRb00000000000Addr := Ra + Rb
Rd[0:23] := 0
Rd[24:31] := *Addr[0:7]
LHU Rd,Ra,Rb110001RdRaRb00000000000Addr := Ra + Rb
Rd[0:15] := 0
Rd[16:31] := *Addr[0:15]
LW Rd,Ra,Rb110010RdRaRb00000000000Addr := Ra + Rb
Rd := *Addr
SB Rd,Ra,Rb110100RdRaRb00000000000Addr := Ra + Rb
*Addr[0:8] := Rd[24:31]
SH Rd,Ra,Rb110101RdRaRb00000000000Addr := Ra + Rb
*Addr[0:16] := Rd[16:31]
SW Rd,Ra,Rb110110RdRaRb00000000000Addr := Ra + Rb
*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 differentcorner cases involved in floating point arithmetic, only the normal behavior is described. A full description
of the behavior can be found in: Chapter 4, “MicroBlaze Instruction Set Architecture,”
Registers
MicroBlaze has an orthogonal instruction set architecture. It has thirty-two 32-bit general
purpose registers and up to seven 32-bit special purpose registers, depending on
configured options.
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).
Note: The register file is not reset by the external reset inputs: reset and debug_rst.
031
↑
R0-R31
Figure 1-2:R0-R31
Table 1-7:General Purpose Registers (R0-R31)
BitsNameDescriptionReset Value
R
0:31R0R0 is defined to always have thevalue
0x00000000
of zero. Anything written to R0 is
discarded.
0:31R1 through R13R1 through R13 are 32-bit general
-
purpose registers
0:31R1432-bit used to store return addresses
-
for interrupts
0:31R1532-bit general purpose register0:31R1632-bit used to store return addresses
-
for breaks
0:31R17
0:31R18 through R31R18 through R31 are 32-bit general
If MicroBlaze is configured to support
hardware exceptions, this register is
loaded with HW exception return
address (see also “Branch Target
Register (BTR)”); if not it is a general
purpose register
-
-
purpose registers.
Please refer to Table 3-2 for software conventions on general purpose register usage.
Special Purpose Registers
Program Counter (PC)
The Program Counter is the 32-bit address of the execution instruction. It can be read with
an MFS instruction, but it can not be written to using an MTS instruction. When used with
the MFS instruction the PC register is specified by setting Sa = 0x0000.
Address of executing instruction,
i.e. “mfs r2 0” will store the address
of the mfs instruction itself in R2
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 MTS instruction or the dedicated MSRSET
and MSRCLR instructions.
When writing to the MSR, some of the bits will takes effect immediately (e.g Carry) and the
remaining 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.
021 22 23 24 25 26 27 28 29 30 31
↑↑↑↑↑↑ ↑↑↑↑↑↑↑
CCRESERVEDPVR EIP EE DCE DZ ICE FSL BIP C IE BE
Figure 1-4:MSR
Table 1-9:Machine Status Register (MSR)
BitsNameDescriptionReset Value
0CC
Arithmetic Carry Copy
0
Copy of the Arithmetic Carry (bit 29).
CC is always the same as bit C.
1:20Reserved
21PVR
Table 1-9:Machine Status Register (MSR) (Continued)
BitsNameDescriptionReset Value
29C
Arithmetic Carry
0
0 No Carry (Borrow)
1 Carry (No Borrow)
Read/Write
30IE
Interrupt Enable
0
0 Interrupts disabled
1 Interrupts enabled
Read/Write
31BE
Buslock Enable
2
0
0 Buslock disabled on data-side OPB
1 Buslock enabled on data-side OPB
Buslock Enable does not affect
operation of IXCL, DXCL, ILMB,
DLMB, or IOPB.
Read/Write
1. This bit is only used for integer divide-by-zero signaling. There is a floating point equivalent
in the FSR. The DZ-bit will flag divide by zero conditions regardless if the processor is
configured with exception handling or not.
2. For a details on the OPB protocol, please refer to the IBM CoreConnect specification: 64-BitOn-Chip Peripheral Bus, Architectural Specifications, Version 2.0.
Exception Address Register (EAR)
The Exception Address Register stores the full load/store address that caused the
exception. For an unaligned access exception that means the unaligned access address,and
for an DOPB exception, the failing OPB data access address. The contents of this register is
undefined for all other exceptions. When read with the MFS instruction the EAR is
specified by setting Sa = 0x0003.
The Exception Status Register contains status bits for the processor. When read with the
MFS instruction the ESR is specified by setting Sa = 0x0005.
19 2026 2731
↑↑↑↑
RESERVED
Figure 1-6:ESR
Table 1-11:Exception Status Register (ESR)
BitsNameDescriptionReset Value
0:18Reserved
DS
ESSEC
R
19DS
20:26ESS
27:31EC
Exception in delay slot.
0 not caused by delay slot instruction
1 caused by delay slot instruction
Read-only
Exception Specific Status
For details refer to Table 1-12.
Read-only
Exception Cause
00001 = Unaligned data access exception
00010 = Illegal op-code exception
00011 = Instruction bus error exception
00100 = Data bus error exception
00101 = Divide by zero exception
00110 = Floating point unit exception
0 unaligned halfword access
1 unaligned word access
21SStore Access Exception
0 unaligned load access
1 unaligned store access
22:26Rx
Source/Destination Register
General purpose register used
as source (Store) or destination
(Load) in unaligned access
20:26Reserved0
20:26Reserved0
20:26Reserved0
20:26Reserved0
20:26Reserved0
0
0
0
Branch Target Register (BTR)
The Branch Target Register only exists if the MicroBlaze processor is configured to use
exceptions. The register stores the branch target address for all delay slot branch
instructions executed while MSR[EIP] = 0. If an exception is caused by an instruction in a
delay slot (i.e. ESR[DS]=1) then the exception handler should return execution to the
address stored in BTR instead of the normal exception return address stored in r17. When
read with the MFS instruction the BTR is specified by setting Sa = 0x000B.
0x00000000
when returning from an exception
caused by an instruction in a delay slot
Read-only
Floating Point Status Register (FSR)
The Floating Point Status Register contains status bits for the floating point unit. It can be
read with an MFS, and written with an MTS instruction. When read or written, the register
is specified by setting Sa = 0x0007.
The Processor Version Register is controlled by the C_PVR configuration option on
MicroBlaze. When C_PVR is set to 0 the processor does not implement any PVR and
MSR[PVR]=0. If C_PVR is set to 1 then MicroBlaze implements only the first register:
PVR0, and if set to 2 all 12 PVR registers (PVR0 to PVR11) are implemented.
When read with the MFS instruction the PVR is specified by setting Sa = 0x200x, with x
being the register number between 0x0 and 0xB.
1=full
1BSUse barrel shifterC_USE_BARREL
2DIVUse dividerC_USE_DIV
3MULUse hardware multiplierC_USE_HW_MUL
4FPUUse FPUC_USE_FPU
5EXCUse any type of exceptionsBased on C_*_EXCEPTION
6ICUUse instruction cacheC_USE_ICACHE
7DCUUse data cacheC_USE_DCACHE
8:15Reserved0
16:23MBVMicroBlaze release version code
Release Specific
0x1 = v5.00.a
24:31USR1User configured value 1C_PVR_USER1
Table 1-16:Processor Version Register 1 (PVR1)
BitsNameDescriptionValue
0:31USR2User configured value 2C_PVR_USER2
Table 1-17:Processor Version Register 2 (PVR2)
BitsNameDescriptionValue
0DOPBData side OPB in useC_D_OPB
1DLMBData side LMB in useC_D_LMB
2IOPBInstruction side OPB in useC_I_OPB
3IOPBInstruction side OPB in useC_I_LMB
4IRQEDGEInterrupt is edge triggeredC_INTERRUPT_IS_EDGE
5IRQPOSInterrupt edge is positiveC_EDGE_IS_POSITIVE
6:16Reserved
17BSUse barrel shifterC_USE_BARREL
18DIVUse dividerC_USE_DIV
19MULUse hardware multiplierC_USE_HW_MUL
20FPUUse FPUC_USE_FPU
21:24Reserved
0:20DOReset value for MSR0
21:31RSTMSRReset value for MSRC_RESET_MSR
Pipeline Architecture
MicroBlaze instruction execution is pipelined. The pipeline is divided into five stages:
Fetch (IF), Decode (OF), Execute (EX), Access Memory (MEM), and Writeback (WB).
For most instructions, each stage takes one clock cycle to complete. Consequently, it takes
five clock cycles for a specific instruction to complete, and one instruction is completed on
every cycle. A few instructions require multiple clock cycles in the execute stage to
complete. This is achieved by stalling the pipeline.
When executing from slower memory, instruction fetches may take multiple cycles. This
additional latency will directly affect the efficiency of the pipeline. MicroBlaze implements
an instruction prefetch buffer that reduces the impact of such multi-cycle instruction
memory latency. While the pipeline is stalled by a multi-cycle instruction in the execution
stage the prefetch buffer continues to load sequential instructions. Once the pipeline
resumes execution the fetch stage can load new instructions directly from the prefetch
buffer rather than having to wait for the instruction memory access to complete.
Normally the instructions in the fetch and decode stages (as well as prefetch buffer) are
flushed when executing a taken branch. The fetch pipeline stage is then reloaded with a
new instruction from the calculated branch address. A taken branch in MicroBlaze takes
three clock cycles to execute, two of which are required for refilling the pipeline. To reduce
this latency overhead, MicroBlaze supports branches with delay slots.
When executing a taken branch with delay slot, only the fetch pipeline stage in MicroBlaze
is flushed. The instruction in the decode stage (branch delay slot) is allowed to complete.
This technique effectively reduces the branch penalty from two clock cycles to one. Branch
instructions with delay slots have a D appended to the instruction mnemonic. For
example, the BNE instruction will not execute the subsequent instruction (does not have a
delay slot), whereas BNED will execute the next instruction before control is transferred to
the branch location.
A delay slot must not contain the following instructions: IMM, branch, or break. Interrupts
and external hardware breaks are deferred until after the delay slot branch has been
completed.
Instructions that could cause recoverable exceptions (e.g. unaligned word or halfword
load and store) are allowed in the delay slot. If an exception is caused in a delay slot the
ESR[DS] bit will be set, and the exception handler is responsible for returning the
execution to the branch target (stored in the special purpose register BTR) rather than the
sequential return address stored in R17.
Memory Architecture
MicroBlaze is implemented with a Harvard memory architecture, i.e. instruction and data
accesses are done in separate address spaces. Each address space has a 32 bit range (i.e.
handles up to 4 GByte of instructions and data memory respectively). The instruction and
data memory ranges can be made to overlap by mapping them both to the same physical
memory. The latter is useful e.g. for software debugging.
Both instruction and data interfaces of MicroBlaze are 32 bit wide and use big endian, bitreversed format. MicroBlaze supports word, halfword, and byte accesses to data memory.
Data accesses must be aligned (i.e. word accesses must be on word boundaries, halfword
on halfword bounders), unless the processor is configured to support unaligned
exceptions. All instruction accesses must be word aligned.
MicroBlaze does not separate between data accesses to I/O and memory (i.e. it uses
memory mapped I/O). The processor has up to three interfaces for memory accesses: Local
Memory Bus (LMB), On-Chip Peripheral Bus (OPB), and Xilinx CacheLink (XCL). The
LMB memory address range must not overlap with OPB or XCL ranges.
MicroBlaze has a single cycle latency for accesses to local memory (LMB) and for cache
read hits. A data cache write normally has two cycles of latency (more if the posted-write
buffer in the memory controller is full).
For details on the different memory interfaces please refer to Chapter 2, “MicroBlaze
MicroBlaze supports reset, interrupt, user exception, break, and hardware exceptions. The
following section describes the execution flow associated with each of these events.
The relative priority starting with the highest is:
1.Reset
2.Hardware Exception
3.Non-maskable Break
4.Break
5.Interrupt
6.User Vector (Exception)
Table 1-27 defines the memory address locations of the associated vectors and the
hardware enforced register file locations for return address. Each vector allocates two
addresses to allow full address range branching (requires an IMM followed by a BRAI
instruction). The address range 0x28 to 0x4F is reserved for future software support by
Xilinx. Allocating these addresses for user applications is likely to conflict with future
releases of EDK support software.
R
Table 1-27:Vectors and Return Address Register File Location
When a Reset or Debug_Rst
instructions from the reset vector (address 0x0). Both external reset signals are active high, and
should be asserted for a minimum of 16 cycles.
Equivalent Pseudocode
PC ← 0x00000000
MSR
← C_RESET_MSR (see “MicroBlaze Core Configurability” in Chapter 2)
EAR
← 0
ESR
← 0
FSR
← 0
Hardware Exceptions
MicroBlaze can be configured to trap the following internal error conditions: illegal
instruction, instruction and data bus error, and unaligned access. The divide by zero
exception can only be enabled if the processor is configured with a hardware divider
(C_USE_DIV=1). When configured with a hardwarefloating point unit (C_USE_FPU=1), it
can also trap the following floating point specific exceptions: underflow, overflow, float
division-by-zero, invalid operation, and denormalized operand error.
A hardware exception will cause MicroBlaze to flush the pipeline and branch to the
hardware exception vector (address 0x20). The exception will also load the decode stage
program counter value into the general purpose register R17. The execution stage
instruction in the exception cycle is not executed. If the exception is caused by an
instruction in a branch delay slot, then the ESR[DS] bit will be set. In this case the exception
handler should resume execution from the branch target address, stored in BTR.
(1)
occurs, MicroBlaze will flush the pipeline and start fetching
The EE and EIP bits in MSR are automatically reverted when executing the RTED
instruction.
Exception Causes
•Instruction Bus Exception
The instruction On-chip Peripheral Bus exception is caused by an active error signal
from the slave (IOPB_errAck) or timeout signal from the arbiter (IOPB_timeout). The
instructions side local memory (ILMB) and CacheLink (IXCL) interfaces can not cause
instruction bus exceptions.
•Illegal Opcode Exception
The illegal opcode exception is caused by an instruction with an invalid major opcode
(bits 0 through 5 of instruction). Bits 6 through 31 of the instruction are not checked.
Optional processor instructions are detected as illegal if not enabled.
•Data Bus Exception
The data On-chip Peripheral Bus exception is caused by an active error signal from the
slave (DOPB_errAck) or timeout signal from the arbiter (DOPB_timeout). The data
side local memory (DLMB) and CacheLink (DXCL) interfaces can not cause data bus
exceptions.
1. Reset input controlled by the XMD debugger via MDM
The unaligned exception is caused by a word access where the address to the data bus
has bits 30 or 31 set, or a half-word access with bit 31 set.
•Divide by Zero Exception
The divide-by-zero exception is causes by an integer division (idiv or idivu) where the
divisor is zero.
•FPU Exception
An FPU exception is caused by an underflow, overflow, divide-by-zero, illegal
operation, or denormalized operand occurring with a floating point instruction.
♦Underflow occurs when the result is denormalized.
♦Overflow occurs when the result is not-a-number (NaN).
♦The divide-by-zero FPU exception is caused by the rA operand to fdiv being zero
when rB is not infinite.
♦Illegal operation is caused by a signaling NaN operand or by illegal infinite or
zero operand combinations.
Equivalent Pseudocode
R
Breaks
Hardware Breaks
r17 ← PC
PC
← 0x00000020
MSR[EE]
MSR[EIP]
ESR[DS]
ESR[EC]
ESR[ESS]
EAR
FSR
← 0
← 1
← exception in delay slot
← exception specific value
← exception specific value
← exception specific value
← exception specific value
There are two kinds of breaks:
•Hardware (external) breaks
•Software (internal) breaks
Hardware breaks are performed by asserting the external break signal (i.e. the Ext_BRK
and Ext_NM_BRK input ports). On a break the instruction in the execution stage will
complete, while the instruction in the decode stage is replaced by a branch to the break
vector (address 0x18). The break return address (the PC associated with the instruction in
the decode stage at the time of the break) is automatically loaded into general purpose
register R16. MicroBlaze also sets the Break In Progress (BIP) flag in the Machine Status
Register (MSR).
A normal hardware break (i.e the Ext_BRK input port) is only handled when there is no
break in progress (i.e MSR[BIP] is set to 0). The Break In Progress flag disables interrupts.
A non-maskable break (i.e the Ext_NM_BRK input port) will always be handled
immediately.
The BIP bit in the MSR is automatically cleared when executing the RTBD instruction.
To perform a software break, use the brk and brki instructions. Refer to Chapter 4,
“MicroBlaze Instruction Set Architecture” for detailed information on software breaks.
The time it will take MicroBlaze to enter a break service routine from the time the break
occurs, depends on the instruction currently in the execution stage and the latency to the
memory storing the break vector.
r16 ← PC
PC
← 0x00000018
MSR[BIP]
MicroBlaze supports one external interrupt source (connecting to the Interrupt input
port). The processor will only react to interrupts if the Interrupt Enable (IE) bit in the
Machine Status Register (MSR) is set to 1. On an interrupt the instruction in the execution
stage will complete, while the instruction in the decode stage is replaced by a branch to the
interrupt vector (address 0x10). The interrupt return address (the PC associated with the
instruction in the decode stage at the time of the interrupt) is automatically loaded into
general purpose register R14. In addition, the processor also disables future interrupts by
clearing the IE bit in the MSR. The IE bit is automatically set again when executing the
RTID instruction.
← 1
Interrupts are ignored by the processor if either of the break in progress (BIP) or exception
in progress (EIP) bits in the MSR are set to 1.
Latency
The time it will take MicroBlaze to enter an Interrupt Service Routine (ISR) from the time
an interrupt occurs depends on the configuration of the processor and the latency of the
memory controller storing the interrupt vectors. If MicroBlaze is configured to have a
hardware divider, the largest latency will happen when an interrupt occurs during the
execution of a division instruction.
Equivalent Pseudocode
r14 ← PC
PC
← 0x00000010
MSR[IE]
← 0
User Vector (Exception)
The user exception vector is located at address 0x8. A user exception is caused by inserting
a ‘BRALID Rx,0x8’ instruction in the software flow. Although Rx could be any general
purpose register Xilinx recommends using R15 for storing the user exception return
address, and to use the RTSD instruction to return from the user exception handler.
MicroBlaze may be used with an optional instruction cache for improved performance
when executing code that resides outside the LMB address range.
The instruction cache has the following features:
•Direct mapped (1-way associative)
•User selectable cacheable memory address range
•Configurable cache and tag size
•Caching over CacheLink (XCL) interface
•Option to use 4 or 8 word cache-line
•Cache on and off controlled using a bit in the MSR
•Optional WIC instruction to invalidate instruction cache lines
R
General Instruction Cache Functionality
When the instruction cache is used, the memory address space in split into two segments:
a cacheable segment and a non-cacheable segment. The cacheable segment is determined
by two parameters: C_ICACHE_BASEADDR and C_ICACHE_HIGHADDR. All
addresses within this range correspond to the cacheable address segment. All other
addresses are non-cacheable.
Instruction Address Bits
03031
Tag Address
Line Addr
Word Addr
Tag
BRAM
Instruction
BRAM
Tag
Valid (word and line)
Cache Address
=
Cache_instruction_data
-
Cache_Hit
-
Figure 1-9:Instruction Cache Organization
The cacheable instruction address consists of two parts: the cache address, and the tag
address. The MicroBlaze instruction cache can be configured from 2kB to 64 kB. This
correspondsto a cache address of between 11and 16 bits. The tag addresstogether with the
cache address should match the full address of cacheable memory.
For example: in a MicroBlaze configured with C_ICACHE_BASEADDR= 0x00300000,
C_ICACHE_HIGHADDR=0x0030ffff, C_CACHE_BYTE_SIZE=4096, and
C_ICACHE_LINELEN=8; the cacheable memory of 64 kB uses 16 bits of byte address, and
the 4 kB cache uses 12 bits of byte address, thus the required address tag width is: 16-12=4
bits. The total number of block RAM primitives required in this configuration is: 2
RAMB16 for storing the 1024 instruction words, and 1 RAMB16 for 128 cache line entries,
each consisting of: 4 bits of tag, 8 word-valid bits, 1 line-valid bit. In total 3 RAMB16
primitives.
Instruction Cache Operation
For every instruction fetched, the instruction cache detects if the instruction address
belongs to the cacheable segment. If the address is non-cacheable, the cache controller
ignores the instruction and lets the OPB or LMB complete the request. If the address is
cacheable, a lookup is performed on the tag memory to check if the requested address is
currently cached. The lookup is successful if: the word and line valid bits are set, and the
tag address matches the instruction address tag segment. On a cache miss, the cache
controllerwill requestthe new instruction over the instruction CacheLink (IXCL) interface,
and wait for the memory controller to return the associated cache line.
Chapter 1: MicroBlaze Architecture
Instruction Cache Software Support
Data Cache
Overview
MSR Bit
The ICE bit in the MSR provides software control to enable and disable caches.
The contents of the cache are preserved by default when the cache is disabled. The user can
invalidate cache lines using the WIC instruction or using the hardware debug logic of
MicroBlaze.
WIC Instruction
The optional WIC instruction (C_ALLOW_ICACHE_WR=1) is used to invalidate cache
lines in the instruction cache from an application. For a detailed description, please refer to
Chapter 4, “MicroBlaze Instruction Set Architecture”. The cache must be disabled
(MSR[ICE]=0) when the instruction is executed.
MicroBlaze may be used with an optional data cache for improved performance. The
cached memory range must not include addresses in the LMB address range.
•Cache on and off controlled using a bit in the MSR
•Optional WDC instruction to invalidate data cache lines
General Data Cache Functionality
When the data cache is used, the memory address space in split into two segments: a
cacheable segment and a non-cacheable segment. The cacheable area is determined by two
parameters: C_DCACHE_BASEADDR and C_DCACHE_HIGHADDR. All addresses
within this range correspond to the cacheable address space. All other addresses are noncacheable.
03031
Tag Address
Data Address Bits
Cache Word Address
R
-
-
Addr
Tag
BRAM
Tag
Valid
=
Cache_Hit
Load_Instruction
Addr
Data
Cache_data
BRAM
Figure 1-10:Data Cache Organization
The cacheable data address consists of two parts: the cache address, and the tag address.
The MicroBlaze data cache can be configured from 2kB to 64 kB. This corresponds to a
cache address of between 11 and 16 bits. The tag address together with the cache address
should match the full address of cacheable memory.
For example: in a MicroBlaze configured with C_ICACHE_BASEADDR= 0x00400000,
C_ICACHE_HIGHADDR=0x00403fff, C_CACHE_BYTE_SIZE=2048, and
C_ICACHE_LINELEN=4; the cacheable memory of 16 kB uses 14 bits of byte address, and
the 2 kB cache uses 11bits of byte address, thus the required address tag width is: 14-11=3
bits. The total number of block RAM primitives required in this configuration is: 1
RAMB16 for storing the 512 instruction words, and 1 RAMB16 for 128 cache line entries,
each consisting of: 3 bits of tag, 4 word-valid bits, 1 line-valid bit. In total 2 RAMB16
primitives.
Data Cache Operation
The MicroBlaze data cache implements a write-through protocol. A store to an address
within the cacheable range will, provided that the cache is enabled, generate an equivalent
byte, halfword, or word write over the data CacheLink (DXCL) to external memory. The
write will also update the cached data if the target address word is in the cache (i.e. the
write is a cache-hit). A write cache-miss does not load the associated cache line into the
cache.
A load from an address within the cacheable range will, provided that the cache is enabled,
trigger a check to determine if the requested data is currently cached. If it is (i.e. on a cachehit) the requested data is retrieved from the cache. If not (i.e. on a cache-miss) the address
is requested over data CacheLink (DXCL), and the processor pipeline will stall until the
cache line associated to the requested address is returned from the external memory
controller.
Data Cache Software Support
MSR Bit
The DCE bit in the MSR controls whether or not the cache is enabled. When disabling
caches the user must ensure that all the prior writes within the cacheable range has been
completed in external memory before reading back over OPB. This can be done by writing
to a semaphore immediately before turning off caches, and then in a loop poll the
semaphore until it has been written.
The contents of the cache is preserved when the cache is disabled.
WDC Instruction
Chapter 1: MicroBlaze Architecture
The optional WDC instruction (C_ALLOW_DCACHE_WR=1) is used to invalidate cache
lines in the data cache from an application. For a detailed description, please refer to
Chapter 4, “MicroBlaze Instruction Set Architecture”.
Floating Point Unit (FPU)
Overview
The MicroBlaze floating point unit is based on the IEEE 754 standard:
•Uses IEEE 754 single precision floating point format, including definitions for infinity,
not-a-number (NaN), and zero
•Supports addition, subtraction, multiplication, division, and comparison instructions
•Implements round-to-nearest mode
•Generates sticky status bits for: underflow, overflow, and invalid operation
For improved performance, the following non-standard simplifications are made:
•Denormalized
a denormalized number will return a quiet NaN and set the denormalized operand
error bit in FSR; see "Floating Point Status Register (FSR)" on page 27
•A denormalized result is stored as a signed 0 with the underflow bit set in FSR. This
method is commonly referred to as Flush-to-Zero (FTZ)
•An operation on a quiet NaN will return the fixed NaN: 0xFFC00000, rather than one
of the NaN operands
•Overflow as a result of a floating point operation will always return signed ∞, even
when the exception is trapped.
(1)
operands are not supported. A hardware floating point operation on
1. Numbers that are so close to 0, that they cannot be represented with full precision, i.e. any number n that falls
in the following ranges: ( 1.17549*10
An IEEE 754 single precision floating point number is composed of the following three
fields:
1.1-bit sign
2.8-bit biased exponent
3.23-bit fraction (a.k.a. mantissa or significand)
The fields are stored in a 32 bit word as defined in Figure 1-11:
01931
↑↑↑
signexponentfraction
Figure 1-11:IEEE 754 Single Precision format
The value of a floating point number v in MicroBlaze has the following interpretation:
1.If exponent = 255 and fraction <> 0, then v= NaN, regardless of the sign bit
2.If exponent = 255 and fraction = 0, then v= (-1)
3.If 0 < exponent < 255, then v = (-1)
sign
* 2
4.If exponent = 0 and fraction <> 0, then v = (-1)
5.If exponent = 0 and fraction = 0, then v = (-1)
sign
* ∞
(exponent-127)
sign
* 2
sign
* 0
* (1.fraction)
-126
* (0.fraction)
R
For practical purposes only 3 and 5 are really useful, while the others all representeither an
error or numbers that can no longer be represented with full precision in a 32 bit format.
Rounding
The MicroBlaze FPU only implements the default rounding mode, “Round-to-nearest”,
specified in IEEE 754. By definition, the result of any floating point operation should return
the nearest single precision value to the infinitely precise result. If the two nearest
representable values are equally near, then the one with its least significant bit zero is
returned.
Operations
All MicroBlaze FPU operations use the processors general purpose registers rather than a
dedicated floating point register file, see “General Purpose Registers”.
Arithmetic
The FPU implements the following floating point operations:
The FPU implements the following floating point comparisons:
•compare less-than, fcmp.lt
•compare equal, fcmp.eq
•compare less-or-equal, fcmp.le
•compare greater-than, fcmp.gt
•compare not-equal, fcmp.ne
•compare greater-or-equal, fcmp.ge
•compare unordered, fcmp.un (used for NaN)
Exceptions
The floating point unit uses the regular hardware exception mechanism in MicroBlaze.
When enabled, exceptions are thrown for all the IEEE standard conditions: underflow,
overflow, divide-by-zero, and illegal operation, as well as for the MicroBlaze specific
exception: denormalized operand error.
A floating point exception will inhibit the write to the destination register (Rd). This allows
a floating point exception handler to operate on the uncorrupted register file.
Chapter 1: MicroBlaze Architecture
Fast Simplex Link (FSL)
MicroBlaze can be configured with up to eight Fast Simplex Link (FSL) interfaces, each
consisting of one input and one output port. The FSL channels are dedicated unidirectional point-to-point data streaming interfaces. For detailed information on the FSL
interface, please refer to the FSL Bus data sheet (DS449).
The FSL interfaces on MicroBlaze are 32 bits wide. A separate bit indicates whether the
sent/received word is of control or data type. The get instruction in the MicroBlaze ISA is
used to transfer information from an FSL port to a general purpose register. The put
instruction is used to transfer data in the opposite direction. Both instructions come in 4
flavours: blocking data, non-blocking data, blocking control, and non-blocking control.For
a detailed description of the get and put instructions please refer to Chapter 4,
“MicroBlaze Instruction Set Architecture”.
Hardware Acceleration using FSL
Each FSL provides a low latency dedicated interface to the processor pipeline. Thus they
areideal for extending the processorsexecution unit with custom hardwareaccelerators. A
simple example is illustrated in Figure 1-12.
put Ra, RFSLx // op 1
put Rb, RFSLx // op 2
// Load result
get Rt, RFSLx
This method is similar to extending the ISA with custom instructions, but has the benefit of
not making the overall speed of the processor pipeline dependent on the custom function.
Also, there are no additional requirements on the software tool chain associated with this
type of functional extension.
Debug and Trace
Debug Overview
MicroBlaze features a debug interface to support JTAG based software debugging tools
(commonly known as BDM or Background Debug Mode debuggers) like the Xilinx
Microprocessor Debug (XMD) tool. The debug interface is designed to be connected to the
Xilinx Microprocessor Debug Module (MDM) core, which interfaces with the JTAG port of
Xilinx FPGAs. Multiple MicroBlaze instances can be interfaced with a single MDM to
enable multiprocessor debugging. The debugging features include:
Register
File
FSLx
Figure 1-12:FSL used with HW accelerated function f
ConfigReg
ResultReg
f
x
x
•Configurable number of hardware breakpoints and watchpoints and unlimited
software breakpoints
•External processor control enables debug tools to stop, reset, and single step
MicroBlaze
•Read from and write to: memory, general purpose registers, and special purpose
register, except ESR and EAR which can only be read
•Support for multiple processors
•Write to instruction and data caches
Trace Overview
The MicroBlaze trace interface exports a number of internal state signals for performance
monitoring and analysis. Xilinx recommends that users only use the trace interface
through Xilinx developed analysis cores. This interface is not guaranteed to be backward
compatible in future releases of MicroBlaze.
The MicroBlaze core is organized as a Harvard architecture with separate bus interface
units for data accesses and instruction accesses. The following three memory interfaces are
supported: Local Memory Bus (LMB), IBM’s On-chip Peripheral Bus (OPB), and Xilinx
CacheLink (XCL). The LMB provides single-cycle access to on-chip dual-port block RAM.
The OPB interface provides a connection to both on-chip and off-chip peripherals and
memory. The CacheLink interface is intended for use with specialized external memory
controllers. MicroBlaze also supports up to 8 Fast Simplex Link (FSL) ports, each with one
master and one slave FSL interface.
Features
The MicroBlaze can be configured with the following bus interfaces:
•A 32-bit version of the OPB V2.0 bus interface (see IBM’s 64-Bit On-Chip Peripheral
Bus, Architectural Specifications, Version 2.0)
•LMB provides simple synchronous protocol for efficient block RAM transfers
•FSL provides a fast non-arbitrated streaming communication mechanism
•XCL provides a fast slave-side arbitrated streaming interface between caches and
external memory controllers
•Debug interface for use with the Microprocessor Debug Module (MDM) core
•Trace interface for performance analysis
MicroBlaze I/O Overview
The core interfaces shown in Figure 2-1 and the following Table 2-1 are defined as follows:
DOPB:Data interface, On-chip Peripheral Bus
DLMB:Data interface, Local Memory Bus (BRAM only)
IOPB:Instruction interface, On-chip Peripheral Bus
ILMB:Instruction interface, Local Memory Bus (BRAM only)
MFSL 0..7:FSL master interfaces
SFSL 0..7:FSL slave interfaces
IXCL:Instruction side Xilinx CacheLink interface (FSL master/slave pair)
DXCL:Data side Xilinx CacheLink interface (FSL master/slave pair)
Core:Miscellaneous signals for: clock, reset, debug, and trace
Table 2-1:Summary of MicroBlaze Core I/O (Continued)
R
SignalInterfaceI/ODescription
IM_BE[0:3]IOPBOInstruction interface OPB byte enables
IM_busLockIOPBOInstruction interface OPB bus lock
IM_DBus[0:31]IOPBOInstructioninterface OPB write data bus
(always 0x00000000)
IM_requestIOPBOInstruction interface OPB bus request
IM_RNWIOPBOInstructioninterface OPBread,not write
Chapter 2: MicroBlaze Signal Interface Description
Table 2-1:Summary of MicroBlaze Core I/O (Continued)
SignalInterfaceI/ODescription
ICache_FSL_out...IXCL_MIOInstruction side CacheLink FSL master
interface
DCache_FSL_in...DXCL_SIOData side CacheLink FSL slave interface
DCache_FSL_out...DXCL_MIOData side CacheLink FSL master
interface
InterruptCoreIInterrupt
ResetCoreICore reset, active high. Should be held
for at least 16 cycles
ClkCoreIClock
Debug_RstCoreIReset signal from OPB JTAG UART,
activehigh. Should beheld for atleast 16
cycles
Ext_BRKCoreIBreak signal from OPB JTAG UART
Ext_NM_BRKCoreINon-maskable break signal from OPB
JTAG UART
Dbg_...CoreIODebug signals from OPB MDM
Valid_InstrCoreOTrace: Valid instruction in EX stage
PC_ExCoreOTrace: Address for EX stage instruction
Reg_WriteCoreOTrace: EX stage instruction writes to the
register file
Reg_AddrCoreOTrace: Destination register
MSR_RegCoreOTrace: Current MSR register value
New_Reg_ValueCoreOTrace: Destination register write data
Pipe_RunningCoreOTrace: Processor pipeline to advance
Interrup_TakenCoreOTrace: Unmasked interrupt has occurred
Jump_TakenCoreOTrace: Branch instruction evaluated true
Prefetch_AddrCoreOTrace: OF stage pointer into prefetch
buffer
MB_HaltedCoreOTrace: Pipeline is halted
Trace_...CoreOTrace signals for real time HW analysis
On-Chip Peripheral Bus (OPB) Interface Description
The MicroBlaze OPB interfaces are implemented as byte-enable capable masters. Please
refer to the Xilinx OPB design document: “OPB Usage in Xilinx FPGA” for details.
The LMB is a synchronous bus used primarily to access on-chip block RAM. It uses a
minimum number of control signals and a simple protocol to ensure that local block RAM
areaccessed in a single clock cycle. LMB signals and definitions are shown in the following
table. All LMB signals are active high.
LMB Signal Interface
Table 2-2:LMB Bus Signals
SignalData Interface
Addr[0:31]Data_Addr[0:31]Instr_Addr[0:31]OAddress bus
Byte_Enable[0:3]Byte_Enable[0:3]not usedOByte enables
Data_Write[0:31]Data_Write[0:31]not usedOWrite data bus
ASD_ASI_ASOAddress strobe
Instruction
Interface
R
TypeDescription
Read_StrobeRead_StrobeIFetchORead in progress
Write_StrobeWrite_Strobenot usedOWrite in progress
Data_Read[0:31]Data_Read[0:31]Instr[0:31]IRead data bus
ReadyDReadyIReadyIReady for next transfer
ClkClkClkIBus clock
Addr[0:31]
The address bus is an output from the core and indicates the memory address that is being
accessed by the current transfer. It is valid only when AS is high. In multicycle accesses
(accesses requiring more than one clock cycle to complete), Addr[0:31] is valid only in the
first clock cycle of the transfer.
Byte_Enable[0:3]
The byte enable signals are outputs from the core and indicate which byte lanes of the data
bus contain valid data. Byte_Enable[0:3] is valid only when AS is high. In multicycle
accesses (accesses requiring more than one clock cycle to complete), Byte_Enable[0:3] is
valid only in the first clock cycle of the transfer. Valid values for Byte_Enable[0:3] are
shown in the following table:
The write data bus is an output from the core and contains the data that is written to
memory. It becomes valid when AS is high and goes invalid in the clock cycle after Ready
is sampled high. Only the byte lanes specified by Byte_Enable[0:3] contain valid data.
AS
The address strobe is an output from the core and indicates the start of a transfer and
qualifies the address bus and the byte enables. It is high only in the first clock cycle of the
transfer, after which it goes low and remains low until the start of the next transfer.
Chapter 2: MicroBlaze Signal Interface Description
The read strobe is an output from the core and indicates that a read transfer is in progress.
This signal goes high in the first clock cycle of the transfer,and remains high until the clock
cycle after Ready is sampled high. If a new read transfer is started in the clock cycle after
Ready is high, then Read_Strobe remains high.
Write_Strobe
The write strobe is an output from the core and indicates that a write transfer is in progress.
This signal goes high in the first clock cycle of the transfer,and remains high until the clock
cycle after Ready is sampled high. If a new write transfer is started in the clock cycle after
Ready is high, then Write_Strobe remains high.
Data_Read[0:31]
The read data bus is an input to the core and contains data read from memory.
Data_Read[0:31] is valid on the rising edge of the clock when Ready is high.
Ready
The Ready signal is an input to the core and indicates completion of the current transfer
and that the next transfer can begin in the following clock cycle. It is sampled on the rising
edge of the clock. For reads, this signal indicates the Data_Read[0:31] bus is valid, and for
writes it indicates that the Data_Write[0:31] bus has been written to local memory.
Clk
All operations on the LMB are synchronous to the MicroBlaze core clock.
The MicroBlaze data-side bus interface performs the read steering and write steering
required to support the following transfers:
•byte, halfword, and word transfers to word devices
•byte and halfword transfers to halfword devices
•byte transfers to byte devices
MicroBlaze does not support transfers that are larger than the addressed device. These
types of transfers require dynamic bus sizing and conversion cycles that are not supported
by the MicroBlaze bus interface. Data steering for read cycles is shown in Table 2-4, and
data steering for write cycles is shown in Table 2-5
Table 2-4:Read Data Steering (load to Register rD)
Note that other OPB masters may have more restrictive requirements for byte lane
placement than those allowed by MicroBlaze. OPB slave devices are typically attached
“left-justified” with byte devices attached to the most-significant byte lane, and halfword
devices attached to the most significant halfword lane. The MicroBlaze steering logic fully
supports this attachment method.
Chapter 2: MicroBlaze Signal Interface Description
Fast Simplex Link (FSL) Interface Description
The Fast Simplex Link bus provides a point-to-point communication channel between an
output FIFO and an input FIFO. For details on the generic FSL protocol please refer to the
“Fast Simplex Link (FSL) bus” data sheet (DS449).
Master FSL Signal Interface
MicroBlaze may contain up to 8 master FSL interfaces. The master signals are depicted in
Table 2-6.
Table 2-6: Master FSL signals
Signal NameDescriptionVHDL TypeDirection
FSLn_M_ClkClockstd_logicinput
FSLn_M_WriteWrite enable signal
FSLn_M_DataData value written to the
FSLn_M_ControlControl bit value written to
FSLn_M_FullFull Bit indicating output
Slave FSL Signal Interface
MicroBlaze may contain up to 8 slave FSL interfaces. The slave FSL interface signals are
depicted in Table 2-7.
Table 2-7: Slave FSL signals
Signal NameDescriptionVHDL TypeDirection
FSLn_S_ClkClockstd_logicinput
FSLn_S_ReadRead acknowledge signal
std_logicoutput
indicating that data is being
written to the output FSL
std_logic_vectoroutput
output FSL
std_logicoutput
the output FSL
std_logicinput
FSL FIFO is full when set
std_logicoutput
indicating that data has been
read from the input FSL
A write to the FSL bus is performed by MicroBlaze using one of the flavors of the put
instruction. A write operations transfers the register contents to an output FSL bus. The
transfer is completed in a single clock cycle for blocking mode writes to the FSL (put and
cput instructions) as long as the FSL FIFO does not become full. If the FSL FIFO is full, the
processor stalls until the FSL full flag is lowered. The non-blocking instructions: nput and
ncput, will always complete in a single clock cycle even if the FSL was full. If the FSL was
full, the write is inhibited and the carry bit is set in the MSR.
FSL BUS Read Operation
A read from the FSL bus is performed by MicroBlaze using one of the flavors of the get
instruction. A read operations transfers the contents of an input FSL to a general purpose
register. The transfer is typically completed in 2 clock cycles for blocking mode reads from
the FSL (get and cget instructions) as long as data exists in the FSL FIFO. If the FSL FIFO is
empty, the processor stalls at this instruction until the FSL exists flag is set. In the nonblocking mode (nget and ncget instructions), the transfer is completed in two clock cycles
irrespective of whether or not the FSL was empty. In the case the FSL was empty, the
transfer of data does not take place and the carry bit is set in the MSR.
R
Xilinx CacheLink (XCL) Interface Description
Xilinx CacheLink (XCL) is a high performance solution for external memory accesses. The
MicroBlaze CacheLink interface is designed to connect directly to a memory controller
with integrated FSL buffers, e.g. the MCH_OPB_SDRAM. This method has the lowest
latency and minimal number of instantiations (see Figure 2-7).
Schematic
Memory
Controller
FSL
MicroBlaze
FSL
Example MHS code
BEGIN microblaze
...
BUS_INTERFACE IXCL = myIXCL
...
END
BEGIN mch_opb_sdram
...
BUS_INTERFACE MCH0 = myIXCL
...
END
Figure 2-7:CacheLink connection with integrated FSL buffers (only Instruction
The MicroBlaze CacheLink interface can also connect to an Fast Simplex Link (FSL)
interfaced memory controller via explicitly instantiated FSL master/slave pair, however
this topology is considered deprecated and is not recommended for new designs.
The interface is only available on MicroBlaze when caches are enabled. It is legal to use a
CacheLink cache on the instruction side or the data side without caching the other.
Memory locations outside the cacheable range are accessed over OPB or LMB. Cached
memory range is accessed over OPB whenever the caches are software disabled (i.e.
MSR[DCE]=0 or MSR[ICE]=0).
The CacheLink cache controllers handle 4 or 8-word cache lines with critical word first. At
the same time the separation from the OPB bus reduces contention for non-cached
memory accesses.
CacheLink Signal Interface
The CacheLink signals on MicroBlaze are listed in Table 2-8
Table 2-8:MicroBlaze Cache Link signals
Signal NameDescriptionVHDL TypeDirection
Chapter 2: MicroBlaze Signal Interface Description
ICACHE_FSL_IN_ClkClock output to I-side
return read data FSL
ICACHE_FSL_IN_ReadRead signal to I-side
return read data FSL.
ICACHE_FSL_IN_DataRead data from I-side
return read data FSL
ICACHE_FSL_IN_ControlFSL control-bit from I-
side return read data FSL.
Reserved for future use
The CacheLink solution uses one incoming (slave) and one outgoing (master) FSL per
cache controller. The outgoing FSL is used to send access requests, while the incoming FSL
is used for receiving the requested cache lines. CacheLink also uses a specific encoding of
the transaction information over the FSL data and control signals.
The cache lines used for reads in the CacheLink protocol are 4 words long. Each cache line
is expected to start with the critical word first. I.e. if an access to address 0x348 is a miss,
then the returned cache line should have the following address sequence: 0x348, 0x34c,
0x340, 0x344. The cache controller will forward the first word to the execution unit as well
as store it in the cache memory. This allows execution to resume as soon as the first word is
back. The cache controller then follows through by filling up the cache line with the
remaining 3 words as they are received.
All write operations to the data cache are single-word write-through.
Instruction Cache Read Miss
On a read miss the cache controller will perform the following sequence:
1.Write the word aligned
control bit set low (ICACHE_FSL_OUT_Control = 0) to indicate a read access
2.Wait until ICACHE_FSL_IN_Exists goes high to indicate that data is available
3.Store the word from ICACHE_FSL_IN_Data to the cache
4.Forward the critical word to the execution unit in order to resume execution
5.Repeat 3 and 4 for the subsequent 3 words in the cache line
Chapter 2: MicroBlaze Signal Interface Description
(1)
missed address to ICACHE_FSL_OUT_Data, with the
Data Cache Read Miss
On a read miss the cache controller will perform the following sequence:
1.If DCACHE_FSL_OUT_Full = 1 then stall until it goes low
2.Write the word aligned1 missed address to DCACHE_FSL_OUT_Data, with the
control bit set low (DCACHE_FSL_OUT_Control = 0) to indicate a read access
3.Wait until DCACHE_FSL_IN_Exists goes high to indicate that data is available
4.Store the word from DCACHE_FSL_IN_Data to the cache
5.Forward the critical word to the execution unit in order to resume execution
6.Repeat 3 and 4 for the subsequent 3 words in the cache line
Data Cache Write
Note that writes to the data cache always are write-through, and thus there will be a write
over the CacheLink regardless of whether there was a hit or miss in the cache. On a write
the cache controller will perform the following sequence:
1.If DCACHE_FSL_OUT_Full = 1 then stall until it goes low
2.Write the missed address to DCACHE_FSL_OUT_Data, with the control bit set high
(DCACHE_FSL_OUT_Control = 1) to indicate a write access. The two least-significant
bits (30:31) of the address are used to encode byte and half-word enables: 0b00=byte0,
1. Byte and halfword read misses are naturally expected to return complete words, the cache controller then
provides the execution unit with the correct bytes.
0b01=byte1 or halfword0, 0x10=byte2, and 0x11=byte3 or halfword1. The selection of
half-word or byte access is based on the control bit for the data word in step 4.
3.If DCACHE_FSL_OUT_Full = 1 then stall until it goes low
4.Write the data to be stored to DCACHE_FSL_OUT_Data. For byte and halfword
accesses the data is mirrored accordingly onto byte-lanes. The control bit should be
low (DCACHE_FSL_OUT_Control = 0) for a word or halfword access, and high for a
byte access.
Debug Interface Description
The debug interface on MicroBlaze is designed to work with the Xilinx Microprocessor
Debug Module (MDM) IP core. The MDM is controlled by the Xilinx Microprocessor
Debugger (XMD) through the JTAG port of the FPGA. The MDM can control multiple
MicroBlaze processors at the same time. The debug signals on MicroBlaze are listed in
Table 2-9.
Table 2-9:MicroBlaze Debug signals
Signal NameDescriptionVHDL TypeDirection
Dbg_ClkJTAG clock from MDMstd_logicinput
R
Dbg_TDIJTAG TDI from MDMstd_logicinput
Dbg_TDOJTAG TDO to MDMstd_logicoutput
Dbg_Reg_EnDebug register enable from
Dbg_CaptureJTAG BSCAN capture signal
Dbg_UpdateJTAG BSCAN update signal
Trace Interface Description
The MicroBlaze core exports a number of internal signals for trace purposes. This signal
interface is not standardized and new revisions of the processor may not be backward
compatible for signal selection or functionality. Users are recommended not to design
custom logic for these signals, but rather to use them via Xilinx provided analysis IP. The
current set of trace signals were last updated for MicroBlaze v5.00.a and are listed in
Execution stage
Trace_MEM_PipeRunPipeline advance for
std_logicoutput
Memory stage
1. Valid only when Trace_Valid_Instr = 1
Table 2-11:Type of Trace Exception
Trace_Exception_Kind [0:3]Description
0001Unaligned execption
0010Illegal Opcode exception
0011Instruction Bus exception
0100Data Bus exception
0101Div by Zero exception
0110FPU exception
1001Debug exception
1010Interrupt
1011External non maskable break
1100External maskable break
MicroBlaze Core Configurability
The MicroBlaze core has been developed to support a high degree of user configurability.
This allows tailoring of the processor to meet specific cost/performance requirements.
Configuration is done via parameters that typically: enable, size, or select certain processor
features. E.g. the instruction cache is enabled by setting the C_USE_ICACHE parameter.
The size of the instruction cache, and the cacheable memory range, are all configurable
using: C_CACHE_BYTE_SIZE, C_ICACHE_BASEADDR, and C_ICACHE_HIGHADDR
respectively.
Parameters valid for MicroBlaze v5.00a are listed in Table 2-12. Note that not all of these
are recognized by older versions of MicroBlaze, however the configurability is fully
backward compatibility.
Table 2-12:MPD Parameters
Chapter 2: MicroBlaze Signal Interface Description
This document describes MicroBlaze Application Binary Interface (ABI), which is
important for developing software in assembly language for the soft processor. The
MicroBlazeGNU compiler follows the conventions described in this document. Hence any
code written by assembly programmers should also follow the same conventions to be
compatible with the compiler generated code. Interrupt and Exception handling is also
explained briefly in the document.
Chapter 3
Data Types
The data types used by MicroBlaze assembly programs are shown in Table 3-1. Data types
such as data8, data16, and data32 are used in place of the usual byte, half-word, and
word.r egister
Table 3-1:Data types in MicroBlaze assembly programs
The register usage convention for MicroBlaze is given in Table 3-2.
Table 3-2:Register usage conventions
RegisterTypeEnforcementPurpose
R0DedicatedHWValue 0
R1DedicatedSWStack Pointer
R2DedicatedSWRead-only small data area anchor
R3-R4VolatileSWReturn Values/Temporaries
R5-R10VolatileSWPassing parameters/Temporaries
R11-R12VolatileSWTemporaries
R13DedicatedSWRead-write small data area anchor
R14DedicatedHWReturn address for Interrupt
R15DedicatedSWReturn address for Sub-routine
R16DedicatedHWReturn address for Trap (Debugger)
Return Address for Exceptions
to support HW
exceptions, else
SW
R18DedicatedSWReserved for Assembler
R19-R31Non-volatileSWMust be saved across function calls.
Callee-save
RPCSpecialHWProgram counter
RMSRSpecialHWMachine Status Register
REARSpecialHWException Address Register
RESRSpecialHWException Status Register
RFSRSpecialHWFloating Point Status Register
RBTRSpecialHWBranch Target Register
RPVR0-
SpecialHWProcessor Version Register 0 thru 11
RPVR11
The architecture for MicroBlaze defines 32 general purpose registers (GPRs). These
registers are classified as volatile, non-volatile, and dedicated.
•The volatile registers (a.k.a caller-save) are used as temporaries and do not retain
values across the function calls. Registers R3 through R12 are volatile, of which R3
and R4 are used for returning values to the caller function, if any. Registers R5
through R10 are used for passing parameters between sub-routines.
•Registers R19 through R31 retain their contents across function calls and are hence
termed as non-volatile registers (a.k.a callee-save). The callee function is expected to
save those non-volatile registers, which are being used. These are typically saved to
the stack during the prologue and then reloaded during the epilogue.
•Certain registers are used as dedicated registers and programmers are not expected to
use them for any other purpose.
♦Registers R14 through R17 are used for storing the return address from interrupts,
sub-routines, traps, and exceptions in that order. Sub-routines are called using the
branch and link instruction, which saves the current Program Counter (PC) onto
register R15.
♦Small data area pointers are used for accessing certain memory locations with 16
bit immediate value. These areas are discussed in the memory model section of
this document. The read only small data area (SDA) anchor R2 (Read-Only) is
used to access the constants such as literals. The other SDA anchor R13 (ReadWrite) is used for accessing the values in the small data read-write section.
♦Register R1 stores the value of the stack pointer and is updated on entry and exit
from functions.
♦Register R18 is used as a temporary register for assembler operations.
•MicroBlaze includes special purpose registers such as: program counter (rpc),
machine status register (rmsr), exception status register (resr), exception address
register (rear), and floating point status register (rfsr). These registers are not mapped
directly to the register file and hence the usage of these registers is different from the
general purpose registers. The value of a special purpose registers can be transferred
to a general purpose register by using mts and mfs instructions (For more details
refer to the “MicroBlaze Application Binary Interface” chapter).
Stack Convention
The stack conventions used by MicroBlaze are detailed in Figure 3-1
The shaded area in Figure 3-1 denotes a part of the caller function’s stack frame, while the
unshaded area indicates the callee function’s frame. The ABI conventions of the stack
frame define the protocol for passing parameters, preserving non-volatile register values
and allocating space for the local variables in a function. Functions which contain calls to
other sub-routines are called as non-leaf functions, These non-leaf functions have to create
a new stack frame area for its own use. When the program starts executing, the stack
pointer will have the maximum value. As functions are called, the stack pointer is
decremented by the number of words required by every function for its stack frame. The
stack pointer of a caller function will always have a higher value as compared to the callee
function.
Functional Parameters (Arg n .. Arg 1)
(Optional: Maximum number of arguments
required for any called procedure from the
current procedure)
New Stack
Pointer
Low Address
Consider an example where Func1 calls Func2, which in turn calls Func3. The stack
representation at differentinstances is depicted in Figure 3-2. After the call from Func 1 to
Func 2, the value of the stack pointer (SP) is decremented. This value of SP is again
decremented to accommodate the stack frame for Func3. On return from Func 3 the value
of the stack pointer is increased to its original value in the function, Func 2.
Details of how the stack is maintained are shown in Figure 3-2.
The caller function passes parameters to the callee function using either the registers (R5
through R10) or on its own stack frame. The callee uses the caller’s stack area to store the
parameters passed to the callee.
Refer to Figure 3-2. The parameters for Func 2 are stored either in the registers R5 through
R10 or on the stack frame allocated for Func 1.
The memory model for MicroBlaze classifies the data into four different parts:
Global initialized variables which are small in size are stored in this area. The threshold for
deciding the size of the variable to be stored in the small data area is set to 8 bytes in the
MicroBlaze C compiler (mb-gcc), but this can be changed by giving a command line option
to the compiler. Details about this option are discussed in the GNU Compiler Tools chapter.
64K bytes of memory is allocated for the small data areas. The small data area is accessed
using the read-write small data area anchor (R13) and a 16-bit offset. Allocating small
variables to this area reduces the requirement of adding Imm instructions to the code for
accessing global variables. Any variable in the small data area can also be accessed using
an absolute address.
Data area
Comparatively large initialized variables are allocated to the data area, which can either be
accessed using the read-write SDA anchor R13 or using the absolute address, depending
on the command line option given to the compiler.
Common un-initialized area
Un-initialized global variables are allocated in the common area and can be accessed either
using the absolute address or using the read-write small data area anchor R13.
Literals or constants
Constants are placed into the read-only small data area and are accessed using the readonly small data area anchor R2.
The compiler generates appropriate global pointers to act as base pointers. The actual
values of the SDA anchors are decided by the linker, in the final linking stages. For more
information on the various sections of the memory please refer to the Address Management
chapter. The compiler generates appropriate sections, depending on the command line
options. Please refer to the GNU Compiler Tools chapter for more information about these
options.
MicroBlaze assumes certain address locations for handling interrupts and exceptions as
indicated in Table 3-3. At these locations, code is written to jump to the appropriate
handlers.
Table 3-3:Interrupt and Exception Handling
OnHardware jumps toSoftware Labels
Start / Reset0x0_start
User exception0x8_exception_handler
Interrupt0x10_interrupt_handler
Break (HW/SW)0x18Hardware exception0x20_hw_exception_handler
The code expected at these locations is as shown in Figure 3-3. For programs compiled
without the -xl-mode-xmdstub compiler option, the crt0.o initialization file is passed by
the mb-gcc compiler to the mb-ld linker for linking. This file sets the appropriate addresses
of the exception handlers.
For programs compiled with the -xl-mode-xmdstub compiler option, the crt1.o
initialization file is linked to the output program. This program has to be run with the
xmdstub already loaded in the memory at address location 0x0. Hence at run-time, the
initialization code in crt1.o writes the appropriateinstructions to location 0x8 through0x14
depending on the address of the exception and interrupt handlers.
Figure 3-3:Code for passing control to exception and interrupt handlers
0x00:bri _start1
0x04:nop
0x08:immhigh bits of address (user exception handler)
0x0c:bri _exception_handler
0x10:immhigh bits of address (interrupt handler)
0x14:bri _interrupt_handler
0x20:immhigh bits of address (HW exception handler)
0x24:bri _hw_exception_handler
MicroBlaze allows exception and interrupt handler routines to be located at any address
location addressable using 32 bits. The user exception handler code starts with the label
_exception_handler, the hardware exception handler starts with _hw_exception_handler,
while the interrupt handler code starts with the label _interrupt_handler.
In the current MicroBlaze system, there are dummy routines for interrupt and exception
handling, which you can change. In order to override these routines and link your
interrupt and exception handlers, you must define the interrupt handler code with an
attribute interrupt_handler. For more details about the use and syntax of the interrupt
handler attribute, please refer to the GNU Compiler Tools chapter in the document: UG111Embedded System Tools Reference Manual.
Type B is used for register-immediate instructions. It contains the opcode, one destination
and one source registers, and a source 16-bit immediate value.
OpcodeDestination Reg Source Reg AImmediate Value
06111631
Instructions
MicroBlazeinstructions are described next. Instructions are listed in alphabetical order.For
each instruction Xilinx provides the mnemonic, encoding, a description of it, pseudocode
of its semantics, and a list of registers that it modifies.
rD, rA, rBAdd
rD, rA, rBAdd with Carry
rD, rA, rBAdd and Keep Carry
rD, rA, rBAdd with Carry and Keep Carry
Description
The sum of the contents of registers rA and rB, is placed into register rD.
Bit 3 of the instruction (labeled as K in the figure) is set to a one for the mnemonic addk. Bit
4 of the instruction (labeled as C in the figure) is set to a one for the mnemonic addc. Both
bits are set to a one for the mnemonic addkc.
When an add instruction has bit 3 set (addk, addkc), the carry flag will Keep its previous
value regardless of the outcome of the execution of the instruction. If bit 3 is cleared (add,
addc), then the carry flag will be affected by the execution of the instruction.
When bit 4 of the instruction is set to a one (addc, addkc), the content of the carry flag
(MSR[C]) affects the execution of the instruction. When bit 4 is cleared (add, addk), the
content of the carry flag does not affect the execution of the instruction (providing a normal
addition).
Pseudocode
if C = 0 then
(rD) ← (rA) + (rB)
else
(rD) ← (rA) + (rB) + MSR[C]
if K = 0 then
MSR[C] ← CarryOut
Registers Altered
•rD
•MSR[C]
Latency
1 cycle
Note
The C bit in the instruction opcode is not the same as the carry bit in the MSR.
The “add r0, r0, r0” (= 0x00000000) instruction is never used by the compiler and usually
indicates uninitialized memory.If you are using illegal instruction exceptions you can trap
these instructions by setting the MicroBlaze option C_OPCODE_0x0_ILLEGAL=1
Chapter 4: MicroBlaze Instruction Set Architecture
addi
0 01 K C 0rDrAIMM
06111631
Arithmetic Add Immediate
addi
addic
addik
addikc
rD, rA, IMMAdd Immediate
rD, rA, IMMAdd Immediate with Carry
rD, rA, IMMAdd Immediate and Keep Carry
rD, rA, IMMAdd Immediate with Carryand Keep Carry
Description
The sum of the contents of registers rA and the value in the IMM field, sign-extended to 32
bits, is placed into register rD. Bit 3 of the instruction (labeled as K in the figure) is set to a
one for the mnemonic addik. Bit 4 of the instruction (labeled as C in the figure) is set to a
one for the mnemonic addic. Both bits are set to a one for the mnemonic addikc.
When an addi instruction has bit 3 set (addik, addikc), the carry flag will Keep its previous
value regardless of the outcome of the execution of the instruction. If bit 3 is cleared (addi,
addic), then the carry flag will be affected by the execution of the instruction.
When bit 4 of the instruction is set to a one (addic, addikc), the content of the carry flag
(MSR[C]) affects the execution of the instruction. When bit 4 is cleared (addi, addik), the
content of the carry flag does not affect the execution of the instruction (providing a normal
addition).
Pseudocode
if C = 0 then
(rD) ← (rA) + sext(IMM)
else
(rD) ← (rA) + sext(IMM) + MSR[C]
if K = 0 then
MSR[C] ← CarryOut
Registers Altered
•rD
•MSR[C]
Latency
1 cycle
Notes
The C bit in the instruction opcode is not the same as the carry bit in the MSR.
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
Chapter 4: MicroBlaze Instruction Set Architecture
andi
1 01 00 1rDrAIMM
06111631
Logial AND with Immediate
andirD, rA, IMM
Description
The contents of registerrA are ANDed with the value of the IMM field, sign-extended to 32
bits; the result is placed into register rD.
Pseudocode
(rD) ← (rA) ∧ sext(IMM)
Registers Altered
•rD
Latency
1 cycle
Note
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an IMM instruction. See the imm instruction for details on using
32-bit immediate values.
Chapter 4: MicroBlaze Instruction Set Architecture
andni
1 01 01 1rDrAIMM
06111631
Logical AND NOT with Immediate
andnirD, rA, IMM
Description
The IMM field is sign-extended to 32 bits. The contents of register rA are ANDed with the
logical complement of the extended IMM field; the result is placed into register rD.
Pseudocode
(rD) ← (rA) ∧ (sext(IMM))
Registers Altered
•rD
Latency
1 cycle
Note
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
beqrA, rBBranch if Equal
beqdrA, rBBranch if Equal with Delay
Description
Branch if rA is equal to 0, to the instruction located in the offset value of rB. The target of
the branch will be the instruction at address PC + rB.
The mnemonic beqd will set the D bit. The D bit determines whether there is a branch
delay slot or not. If the D bit is set, it means that there is a delay slot and the instruction
following the branch (i.e. in the branch delay slot) is allowed to complete execution before
executing the target instruction. If the D bit is not set, it means that there is no delay slot, so
the instruction to be executed after the branch is the target instruction.
Pseudocode
If rA = 0 then
PC
← PC + rB
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
Chapter 4: MicroBlaze Instruction Set Architecture
beqi
1 01 11 1 D 0 0 0 0rAIMM
06111631
Branch Immediate if Equal
beqirA, IMMBranch Immediate if Equal
beqidrA, IMMBranch Immediate if Equal with Delay
Description
Branch if rA is equal to 0, to the instruction located in the offset value of IMM. The target
of the branch will be the instruction at address PC + IMM.
The mnemonic beqid will set the D bit. The D bit determines whether there is a branch
delay slot or not. If the D bit is set, it means that there is a delay slot and the instruction
following the branch (i.e. in the branch delay slot) is allowed to complete execution before
executing the target instruction. If the D bit is not set, it means that there is no delay slot, so
the instruction to be executed after the branch is the target instruction.
Pseudocode
If rA = 0 then
PC
← PC + sext(IMM)
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
bgerA, rBBranch if Greater or Equal
bgedrA, rBBranch if Greater or Equal with Delay
Description
Branch if rA is greater or equal to 0, to the instruction located in the offset value of rB. The
target of the branch will be the instruction at address PC + rB.
The mnemonic bged will set the D bit. The D bit determines whether there is a branch
delay slot or not. If the D bit is set, it means that there is a delay slot and the instruction
following the branch (i.e. in the branch delay slot) is allowed to complete execution before
executing the target instruction. If the D bit is not set, it means that there is no delay slot, so
the instruction to be executed after the branch is the target instruction.
Pseudocode
If rA >= 0 then
PC
← PC + rB
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
Chapter 4: MicroBlaze Instruction Set Architecture
bgei
1 01 11 1 D 0 1 0 1rAIMM
06111631
Branch Immediate if Greater or Equal
bgeirA, IMMBranch Immediate if Greater or Equal
bgeidrA, IMMBranch Immediate if Greater or Equal with Delay
Description
Branch if rA is greater or equal to 0, to the instruction located in the offset value of IMM.
The target of the branch will be the instruction at address PC + IMM.
The mnemonic bgeid will set the D bit. The D bit determines whether there is a branch
delay slot or not. If the D bit is set, it means that there is a delay slot and the instruction
following the branch (i.e. in the branch delay slot) is allowed to complete execution before
executing the target instruction. If the D bit is not set, it means that there is no delay slot, so
the instruction to be executed after the branch is the target instruction.
Pseudocode
If rA >= 0 then
PC
← PC + sext(IMM)
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
bgtrA, rBBranch if Greater Than
bgtdrA, rBBranch if Greater Than with Delay
Description
Branch if rA is greater than 0, to the instruction located in the offset value of rB. The target
of the branch will be the instruction at address PC + rB.
The mnemonic bgtd will set the D bit. The D bit determines whether there is a branch delay
slot or not. If the D bit is set, it means that there is a delay slot and the instruction following
the branch (i.e. in the branch delay slot) is allowed to complete execution before executing
the target instruction. If the D bit is not set, it means that there is no delay slot, so the
instruction to be executed after the branch is the target instruction.
Pseudocode
If rA > 0 then
PC
← PC + rB
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
Chapter 4: MicroBlaze Instruction Set Architecture
bgti
1 01 11 1 D 0 1 0 0rAIMM
06111631
Branch Immediate if Greater Than
bgtirA, IMMBranch Immediate if Greater Than
bgtidrA, IMMBranch Immediate if Greater Than with Delay
Description
Branch if rA is greater than 0, to the instruction located in the offset value of IMM. The
target of the branch will be the instruction at address PC + IMM.
The mnemonic bgtid will set the D bit. The D bit determines whether there is a branch
delay slot or not. If the D bit is set, it means that there is a delay slot and the instruction
following the branch (i.e. in the branch delay slot) is allowed to complete execution before
executing the target instruction. If the D bit is not set, it means that there is no delay slot, so
the instruction to be executed after the branch is the target instruction.
Pseudocode
If rA > 0 then
PC
← PC + sext(IMM)
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
blerA, rBBranch if Less or Equal
bledrA, rBBranch if Less or Equal with Delay
Description
Branch if rA is less or equal to 0, to the instruction located in the offset value of rB. The
target of the branch will be the instruction at address PC + rB.
The mnemonic bled will set the D bit. The D bit determines whether there is a branch delay
slot or not. If the D bit is set, it means that there is a delay slot and the instruction following
the branch (i.e. in the branch delay slot) is allowed to complete execution before executing
the target instruction. If the D bit is not set, it means that there is no delay slot, so the
instruction to be executed after the branch is the target instruction.
Pseudocode
If rA <= 0 then
PC
← PC + rB
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
Chapter 4: MicroBlaze Instruction Set Architecture
blei
1 01 11 1 D 0 0 1 1rAIMM
06111631
Branch Immediate if Less or Equal
bleirA, IMMBranch Immediate if Less or Equal
bleidrA, IMMBranch Immediate if Less or Equal with Delay
Description
Branch if rA is less or equal to 0, to the instruction located in the offset value of IMM. The
target of the branch will be the instruction at address PC + IMM.
The mnemonic bleid will set the D bit. The D bit determines whether there is a branch
delay slot or not. If the D bit is set, it means that there is a delay slot and the instruction
following the branch (i.e. in the branch delay slot) is allowed to complete execution before
executing the target instruction. If the D bit is not set, it means that there is no delay slot, so
the instruction to be executed after the branch is the target instruction.
Pseudocode
If rA <= 0 then
PC
← PC + sext(IMM)
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
bltrA, rBBranch if Less Than
bltdrA, rBBranch if Less Than with Delay
Description
Branch if rA is less than 0, to the instruction located in the offset value of rB. The target of
the branch will be the instruction at address PC + rB.
The mnemonic bltd will set the D bit. The D bit determines whether there is a branch delay
slot or not. If the D bit is set, it means that there is a delay slot and the instruction following
the branch (i.e. in the branch delay slot) is allowed to complete execution before executing
the target instruction. If the D bit is not set, it means that there is no delay slot, so the
instruction to be executed after the branch is the target instruction.
Pseudocode
If rA < 0 then
PC
← PC + rB
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
Chapter 4: MicroBlaze Instruction Set Architecture
blti
1 01 11 1 D 0 0 1 0rAIMM
06111631
Branch Immediate if Less Than
bltirA, IMMBranch Immediate if Less Than
bltidrA, IMMBranch Immediate if Less Than with Delay
Description
Branch if rA is less than 0, to the instruction located in the offset value of IMM. The target
of the branch will be the instruction at address PC + IMM.
The mnemonic bltid will set the D bit. The D bit determines whether there is a branch delay
slot or not. If the D bit is set, it means that there is a delay slot and the instruction following
the branch (i.e. in the branch delay slot) is allowed to complete execution before executing
the target instruction. If the D bit is not set, it means that there is no delay slot, so the
instruction to be executed after the branch is the target instruction.
Pseudocode
If rA < 0 then
PC
← PC + sext(IMM)
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
bnerA, rBBranch if Not Equal
bnedrA, rBBranch if Not Equal with Delay
Description
Branch if rA not equal to 0, to the instruction located in the offset value of rB. The target of
the branch will be the instruction at address PC + rB.
The mnemonic bned will set the D bit. The D bit determines whether there is a branch
delay slot or not. If the D bit is set, it means that there is a delay slot and the instruction
following the branch (i.e. in the branch delay slot) is allowed to complete execution before
executing the target instruction. If the D bit is not set, it means that there is no delay slot, so
the instruction to be executed after the branch is the target instruction.
Pseudocode
If rA ≠ 0 then
PC
← PC + rB
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
Chapter 4: MicroBlaze Instruction Set Architecture
bnei
1 01 11 1 D 0 0 0 1rAIMM
06111631
Branch Immediate if Not Equal
bneirA, IMMBranch Immediate if Not Equal
bneidrA, IMMBranch Immediate if Not Equal with Delay
Description
Branch if rA not equal to 0, to the instruction located in the offset value of IMM. The target
of the branch will be the instruction at address PC + IMM.
The mnemonic bneid will set the D bit. The D bit determines whether there is a branch
delay slot or not. If the D bit is set, it means that there is a delay slot and the instruction
following the branch (i.e. in the branch delay slot) is allowed to complete execution before
executing the target instruction. If the D bit is not set, it means that there is no delay slot, so
the instruction to be executed after the branch is the target instruction.
Pseudocode
If rA ≠ 0 then
PC
← PC + sext(IMM)
else
PC
← PC + 4
if D = 1 then
allow following instruction to complete execution
Registers Altered
•PC
Latency
1 cycle (if branch is not taken)
2 cycles (if branch is taken and the D bit is set)
3 cycles (if branch is taken and the D bit is not set)
Note
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
brrBBranch
brarBBranch Absolute
brdrBBranch with Delay
bradrBBranch Absolute with Delay
brldrD, rBBranch and Link with Delay
braldrD, rBBranch Absolute and Link with Delay
1 00 11 0rDD A L 0 0rB0 0 00 00 00 00 0
0611162131
Description
Branch to the instruction located at address determined by rB.
The mnemonics brld and brald will set the L bit. If the L bit is set, linking will be
performed. The current value of PC will be stored in rD.
The mnemonics bra, brad and brald will set the A bit. If the A bit is set, it means that the
branch is to an absolute value and the target is the value in rB, otherwise, it is a relative
branch and the target will be PC + rB.
The mnemonics brd, brad, brld and brald will set the D bit. The D bit determines whether
there is a branch delay slot or not. If the D bit is set, it means that there is a delay slot and
the instruction following the branch (i.e. in the branch delay slot) is allowed to complete
execution before executing the target instruction. If the D bit is not set, it means that there
is no delay slot, so the instruction to be executed after the branch is the target instruction.
Pseudocode
if L = 1 then
(rD)
← PC
if A = 1 then
PC
← (rB)
else
PC
← PC + (rB)
if D = 1 then
allow following instruction to complete execution
Registers Altered
•rD
•PC
Latency
2 cycles (if the D bit is set)
3 cycles (if the D bit is not set)
Chapter 4: MicroBlaze Instruction Set Architecture
Note
The instructions brl and bral are not available.
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
briIMMBranch Immediate
braiIMMBranch Absolute Immediate
bridIMMBranch Immediate with Delay
braidIMMBranch Absolute Immediate with Delay
brlidrD, IMMBranch and Link Immediate with Delay
bralidrD, IMMBranch Absolute and Link Immediate with Delay
1 01 11 0rDD A L 0 0IMM
06111631
Description
Branch to the instruction located at address determined by IMM, sign-extended to 32 bits.
The mnemonics brlid and bralid will set the L bit. If the L bit is set, linking will be
performed. The current value of PC will be stored in rD.
The mnemonics brai, braid and bralid will set the A bit. If the A bit is set, it means that the
branch is to an absolute value and the target is the value in IMM, otherwise, it is a relative
branch and the target will be PC + IMM.
The mnemonics brid, braid, brlid and bralid will set the D bit. The D bit determines
whether there is a branch delay slot or not. If the D bit is set, it means that there is a delay
slot and the instruction following the branch (i.e. in the branch delay slot) is allowed to
complete execution before executing the target instruction. If the D bit is not set, it means
that there is no delay slot, so the instruction to be executed after the branch is the target
instruction.
Pseudocode
if L = 1 then
(rD)
← PC
if A = 1 then
PC
← (IMM)
else
PC
← PC + (IMM)
if D = 1 then
allow following instruction to complete execution
Registers Altered
•rD
•PC
Latency
2 cycles (if the D bit is set)
3 cycles (if the D bit is not set)
Chapter 4: MicroBlaze Instruction Set Architecture
Notes
The instructions brli and brali are not available.
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
A delay slot must not be used by the following: IMM, branch, or break instructions. This
also applies to instructions causing recoverable exceptions (e.g. unalignement), when
hardware exceptions are enabled. Interrupts and external hardware breaks are deferred
until after the delay slot branch has been completed.
Chapter 4: MicroBlaze Instruction Set Architecture
brki
1 01 11 0rD0 11 00IMM
06111631
Break Immediate
brkirD, IMM
Description
Branch and link to the instruction located at address value in IMM, sign-extended to 32
bits. The current value of PC will be stored in rD. The BIP flag in the MSR will be set.
Pseudocode
(rD) ← PC
PC ← sext(IMM)
MSR[BIP] ← 1
Registers Altered
•rD
•PC
•MSR[BIP]
Latency
3 cycles
Note
By default, Type B Instructions will take the 16-bit IMM field value and sign extend it to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
bsrlrD, rA, rBBarrel Shift Right Logical
bsrarD, rA, rBBarrel Shift Right Arithmetical
bsllrD, rA, rBBarrel Shift Left Logical
0 10 00 1rDrArBS T 00 0 00 00 00
0611162131
Description
Shifts the contents of register rA by the amount specified in register rB and puts the result
in register rD.
The mnemonic bsll sets the S bit (Side bit). If the S bit is set, the barrel shift is done to the
left. The mnemonics bsrl and bsra clear the S bit and the shift is done to the right.
The mnemonic bsra will set the T bit (Type bit). If the T bit is set, the barrel shift performed
is Arithmetical. The mnemonics bsrl and bsll clear the T bit and the shift performed is
Logical.
Chapter 4: MicroBlaze Instruction Set Architecture
bsi
Barrel Shift Immediate
bsrlirD, rA, IMMBarrel Shift Right Logical Immediate
bsrairD, rA, IMMBarrel Shift Right Arithmetical Immediate
bsllirD, rA, IMMBarrel Shift Left Logical Immediate
0 11 00 1rDrA00 00 0 S T 0 00 0IMM
061116212731
Description
Shifts the contents of register rA by the amount specified by IMM and puts the result in
register rD.
The mnemonic bsll sets the S bit (Side bit). If the S bit is set, the barrel shift is done to the
left. The mnemonics bsrl and bsra clear the S bit and the shift is done to the right.
The mnemonic bsra will set the T bit (Type bit). If the T bit is set, the barrel shift performed
is Arithmetical. The mnemonics bsrl and bsll clear the T bit and the shift performed is
Logical.
These are not Type B Instructions. There is no effect from a preceding imm instruction.
These instructions are optional. Touse them, MicroBlaze has to be configured to use barrel
rD, rA, rBcompare rB with rA (signed)
rD, rA, rBcompare rB with rA (unsigned)
Description
The contents of register rA is subtracted from the contents of register rB and the result is
placed into register rD.
The MSB bit of rD is adjusted to shown true relation between rA and rB. If the U bit is set,
rA and rB is considered unsigned values. If the U bit is clear, rA and rB is considered
signed values.