OpenRISC 1000 Architecture
OpenRISC
1000
Architecture Manual1
Architecture
Version
Document
Revision
Table of Contents
1.3 Document Revision History 11
2.3 Architecture Version Information 17
3 Addressing Modes and Operand Conventions 18
3.1 Memory Addressing Modes 18
3.2 Memory Operand Conventions 19
4.3 Special-Purpose Registers 22
4.4 General-Purpose Registers (GPRs) 27
4.5 Support for Custom Number of GPRs 27
4.6 Supervision Register (SR) 28
4.7 Exception Program Counter Registers (EPCR0 - EPCR15) 29
4.8 Exception Effective Address Registers (EEAR0-EEAR15) 30
4.9 Exception Supervision Registers (ESR0‑ESR15) 30
4.10 Next and Previous Program Counter (NPC and PPC) 31
4.11 Floating Point Control Status Register (FPCSR) 31
6.4 Fast Context Switching (Optional) 257
7.2 Memory Access Ordering 260
8.4 MMU Special-Purpose Registers 264
8.5 Address Translation Mechanism in 32-bit Implementations 277
8.6 Address Translation Mechanism in 64-bit Implementations 280
8.7 Memory Protection Mechanism 283
8.8 Page Table Entry Definition 284
8.9 Page Table Search Operation 285
8.10 Page History Recording 286
9 Cache Model & Cache Coherency 287
9.1 Cache Special-Purpose Registers 287
9.3 Cache/Memory Coherency 294
10.2 Debug Value Registers (DVR0-DVR7) 297
10.3 Debug Control Registers (DCR0-DCR7) 297
10.4 Debug Mode Register 1 (DMR1) 298
10.5 Debug Mode Register 2(DMR2) 300
10.6 Debug Watchpoint Counter Register (DWCR0-DWCR1) 301
10.7 Debug Stop Register (DSR) 302
10.8 Debug Reason Register (DRR) 303
11 Performance Counters Unit (Optional) 306
11.2 Performance Counters Count Registers (PCCR0-PCCR7) 306
11.3 Performance Counters Mode Registers (PCMR0-PCMR7) 307
12 Power Management (Optional) 309
12.2 Power Management Register (PMR) 310
13 Programmable Interrupt Controller (Optional) 311
13.2 PIC Mask Register (PICMR) 311
13.3 PIC Status Register (PICSR) 312
14 Tick Timer Facility (Optional) 313
14.4 Tick Timer Mode Register (TTMR) 315
14.5 Tick Timer Count Register (TTCR) 316
15 OpenRISC 1000 Implementations 317
15.2 Version Register (VR) 317
15.3 Unit Present Register (UPR) 318
15.4 CPU Configuration Register (CPUCFGR) 319
15.5 DMMU Configuration Register (DMMUCFGR) 321
15.6 IMMU Configuration Register (IMMUCFGR) 322
15.7 DC Configuration Register (DCCFGR) 323
15.8 IC Configuration Register (ICCFGR) 324
15.9 Debug Configuration Register (DCFGR) 325
15.10 Performance Counters Configuration Register (PCCFGR) 326
15.11 Version Register 2 (VR2) 326
15.12 Architecture Version Register (AVR) 327
15.13 Exception Vector Base Address Register (EVBAR) 327
15.14 Arithmetic Exception Control Register (AECR) 328
15.15 Arithmetic Exception Status Register (AESR) 329
15.16 Implementation-Specific Registers (ISR0-7) 330
16 Application Binary Interface 331
16.2 Function Calling Sequence 334
16.3 Operating System Interface 337
Table Of Figures
Figure 3-1. Register Indirect with Displacement Addressing 18
Figure 3-2. PC Relative Addressing 19
Figure 5-1. Instruction Set 33
Figure 8-1. Translation of Effective to Physical Address – Simplified block diagram for 32-bit processor implementations 261
Figure 8-2. Memory Divided Into L1 and L2 pages 275
Figure 8-3. Address Translation Mechanism using Two-Level Page Table 276
Figure 8-4. Address Translation Mechanism using only L1 Page Table 277
Figure 8-5. Memory Divided Into L0, L1 and L2 pages 278
Figure 8-6. Address Translation Mechanism using Three-Level Page Table 279
Figure 8-7. Address Translation Mechanism using Two-Level Page Table 280
Figure 8-8. Selection of Page Protection Attributes for Data Accesses 282
Figure 8-9. Selection of Page Protection Attributes for Instruction Fetch Accesses 282
Figure 8-10. Page Table Entry Format 283
Figure 10-1. Block Diagram of Debug Support 295
Figure 13-1. Programmable Interrupt Controller Block Diagram 309
Figure 14-1. Tick Timer Block Diagram 311
Figure 16-1. Byte aligned, sizeof is 1 330
Figure 16-2. No padding, sizeof is 8 331
Figure 16-3. Padding, sizeof is 16 331
Figure 16-4. Storage unit sharing and alignment padding, sizeof is 12 332
Table Of Tables
Table 1. Acronyms and Abbreviations 9
Table 1-1. Authors of this Manual 10
Table 1-2. Revision History 13
Table 1-3. Conventions 15
Table 2-1: Architecture Version Information 17
Table 3-1. Memory Operands and their sizes 20
Table 3-2. Default Bit and Byte Ordering in Halfwords 20
Table 3-3. Default Bit and Byte Ordering in Singlewords and Single Precision Floats 20
Table 3-4. Default Bit and Byte Ordering in Doublewords, Double Precision Floats and all Vector Types 21
Table 3-5. Memory Operand Alignment 21
Table 4-1. Groups of SPRs 23
Table 4-2. List of All Special-Purpose Registers 26
Table 4-3. General-Purpose Registers 27
Table 4-4. SR Field Descriptions 29
Table 4-5. EPCR Field Descriptions 30
Table 4-6. EEAR Field Descriptions 30
Table 4-7. ESR Field Descriptions 31
Table 4-8. FPCSR Field Descriptions 32
Table 5-1. OpenRISC 1000 Instruction Classes 34
Table 6-1. Exception Classes 252
Table 6-2. Exception Types and Causal Conditions 253
Table 6-3. Values of EPCR and EEAR After Exception 255
Table 8-1. MMU Exceptions 262
Table 8-2. List of MMU Special-Purpose Registers 264
Table 8-3. DMMUCR Field Descriptions 264
Table 8-4. DMMUPR Field Descriptions 265
Table 8-5. IMMUCR Field Descriptions 266
Table 8-6. IMMUPR Field Descriptions 267
Table 8-7. xTLBEIR Field Descriptions 267
Table 8-8. xTLBMR Field Descriptions 268
Table 8-9. DTLBTR Field Descriptions 270
Table 8-10. ITLBWyTR Field Descriptions 271
Table 8-11. xATBMR Field Descriptions 272
Table 8-12. DATBTR Field Descriptions 273
Table 8-13. IATBTR Field Descriptions 274
Table 8-14. Protection Attributes 281
Table 8-15. PTE Field Descriptions 283
Table 9-1. Cache Registers 286
Table 9-2. DCCR Field Descriptions 286
Table 9-3. ICCR Field Descriptions 287
Table 9-4. DCBPR Field Descriptions 288
Table 9-5. DCBFR Field Descriptions 288
Table 9-6. DCBIR Field Descriptions 289
Table 9-7. DCBWR Field Descriptions 289
Table 9-8. DCBLR Field Descriptions 290
Table 9-9. ICBPR Field Descriptions 290
Table 9-10. ICBIR Field Descriptions 291
Table 9-11. ICBLR Field Descriptions 291
Table 10-1. DVR Field Descriptions 295
Table 10-2. DCR Field Descriptions 296
Table 10-3. DMR1 Field Descriptions 298
Table 10-4. DMR2 Field Descriptions 299
Table 10-5. DWCR Field Descriptions 300
Table 10-6. DSR Field Descriptions 301
Table 10-7. DRR Field Descriptions 303
Table 11-1. PCCR0 Field Descriptions 305
Table 11-2. PCMR Field Descriptions 306
Table 12-1. PMR Field Descriptions 308
Table 13-1. PICMR Field Descriptions 310
Table 13-2. PICSR Field Descriptions 310
Table 14-1. TTMR Field Descriptions 313
Table 14-2. TTCR Field Descriptions 314
Table 15-1. VR Field Descriptions 316
Table 15-2. UPR Field Descriptions 317
Table 15-3. CPUCFGR Field Descriptions 318
Table 15-4. DMMUCFGR Field Descriptions 320
Table 15-5. IMMUCFGR Field Descriptions 321
Table 15-6. DCCFGR Field Descriptions 322
Table 15-7. ICCFGR Field Descriptions 323
Table 15-8. DCFGR Field Descriptions 323
Table 15-9. PCCFGR Field Descriptions 324
Table 15-10. VR2 Field Descriptions 325
Table 15-11. AVR Field Descriptions 325
Table 15-12. EVBAR Field Descriptions 326
Table 15-13. EACR Field Descriptions 327
Table 15-14. EASR Field Descriptions 328
Table 16-1. Scalar Types 329
Table 16-2. Vector Types 330
Table 16-3. Bit-Field Types and Ranges 331
Table 16-4. General-Purpose Registers 333
Table 16-5. Stack Frame 334
Table 16-6. Hardware Exceptions and Signals 336
Table 16-7. Virtual Address Configuration 337
Table 16-8. e_ident Field Values 338
Table 16-9. e_flags Field Values 339
Acronyms & Abbreviations
ALU |
Arithmetic Logic Unit |
ATB |
Area Translation Buffer |
BIU |
Bus Interface Unit |
BTC |
Branch Target Cache |
CPU |
Central Processing Unit |
DC |
Data Cache |
DMMU |
Data MMU |
DTLB |
Data TLB |
DU |
Debug Unit |
EA |
Effective address |
FPU |
Floating-Point Unit |
GPR |
General-Purpose Register |
IC |
Instruction Cache |
IMMU |
Instruction MMU |
ITLB |
Instruction TLB |
MMU |
Memory Management Unit |
OR1K |
OpenRISC 1000 Architecture |
ORBIS |
OpenRISC Basic Instruction Set |
ORFPX |
OpenRISC Floating-Point eXtension |
ORVDX |
OpenRISC Vector/DSP eXtension |
PC |
Program Counter |
PCU |
Performance Counters Unit |
PIC |
Programmable Interrupt Controller |
PM |
Power Management |
PTE |
Page Table Entry |
R/W |
Read/Write |
RISC |
Reduced Instruction Set Computer |
SMP |
Symmetrical Multi-Processing |
SMT |
Simultaneous Multi-Threading |
SPR |
Special-Purpose Register |
SR |
Supervison Register |
TLB |
Translation Lookaside Buffer |
Table 1. Acronyms and Abbreviations
1About this Manual
1.1Introduction
The OpenRISC 1000 system architecture manual defines the architecture for a family of open-source, synthesizable RISC microprocessor cores. The OpenRISC 1000 architecture allows for a spectrum of chip and system implementations at a variety of price/performance points for a range of applications. It is a 32/64-bit load and store RISC architecture designed with emphasis on performance, simplicity, low power requirements, and scalability. The OpenRISC 1000 architecture targets medium and high performance networking and embedded computer environments.
This manual covers the instruction set, register set, cache management and coherency, memory model, exception model, addressing modes, operands conventions, and the application binary interface (ABI).
This manual does not specify implementation-specific details such as pipeline depth, cache organization, branch prediction, instruction timing, bus interface etc.
1.2Authors
If you have contributed to this manual but your name isn't listed here, it is not meant as a slight – We simply don't know about it. Send an email to the maintainer(s), and we'll correct the situation.
Name |
|
Contribution |
Damjan Lampret |
Initial document |
|
Chen-Min Chen |
Some notes |
|
Marko Mlinar |
Fast context switches |
|
Johan Rydberg |
ELF section |
|
Matan Ziv-Av |
Several suggestions |
|
Chris Ziomkowski |
Several suggestions |
|
Greg McGary |
l.cmov, trap exception |
|
Bob Gardner |
|
Native Speaker Check |
Rohit Mathur |
Technical review and corrections |
|
Maria Bolado |
Technical review and corrections |
|
ORSoC Yann Vernier |
Technical review and corrections |
|
Julius Baxter |
Architecture revision information |
|
Stefan Kristiansson |
Atomic instructions |
Table 1-1. Authors of this Manual
1.3Document Revision History
The revision history of this manual is presented in the table below.
Revision Date |
By |
Modifications |
Arch. Ver (Maj.Min) – Doc Rev |
15/Mar/2000 |
Damjan Lampret |
Initial document |
0.0-0 |
7/Apr/2001 |
Damjan Lampret |
First public release |
0.0-1 |
22/Apr/2001 |
Damjan Lampret |
Incorporated changes from Johan and Matan |
0.0-2 |
16/May/2001 |
Damjan Lampret |
Changed SR, Debug, Exceptions, TT, PM. Added l.cmov, l.ff1, etc. |
0.0-3 |
23/May/2001 |
Damjan Lampret |
Added SR[SUMRA], configuration registerc etc. |
0.0-4 |
24/May/2001 |
Damjan Lampret |
Changed virtually almost all chapters in some way – major change is addition of configuration registers. |
0.0-5 |
28/May/2001 |
Damjan Lampret |
Changed addresses of some SPRs, removed group SPR group 11, added DCR[CT]=7. |
0.0-6 |
24/Jan/2002 |
Marko Mlinar |
Major check and update |
0.0-7 |
9/Apr/2002 |
Marko Mlinar |
PICPR register removed; l.sys convention added; mtspr/mfspr now use bitwise OR instead of sum |
0.0-8 |
28/July/2002 |
Jeanne Wiegelmann |
First overall review & layout adjustment |
0.0-9 |
20/Sep/2002 |
Rohit Mathur |
Second overall review |
0.0-10 |
12/Jan/2003 |
Damjan Lampret |
Synchronization with or1ksim and OR1200 RTL. Not all chapters have been checked. |
0.0-11 |
26/Jan/2003 |
Damjan Lampret |
Synchronization with or1ksim and OR1200 RTL. From this revision on the manual carries revision number 1.0 and parts of the architecture that are implemented in OR1200 will no longer change because OR1200 is being implemented in silicon. Major parts that are not implemented in OR1200 and could change in the future include ORFPX, ORVDX, PCU, fast context switching, and 64-bit extension. |
0.0-12 |
26/Jun/2004 |
Damjan Lampret |
Fixed typos in instruction set description reported by Victor Lopez, Giles Hall and Luís Vitório Cargnini. Fixed typos in various chapters reported by Matjaz Breskvar. Changed description of PICSR. Updated ABI chapter based on agreed ABI from the openrisc mailing list. Removed DMR1[ETE], clearly defined watchpoints&breakpoint, split long watchpoint chain into two, removed WP10 and removed DMR1[DXFW], updated DMR2. Fixed FP definition (added FP exception. FPCSR register). |
0.0-13 |
3/Nov/2005 |
Damjan Lampret |
Corrected description of l.ff1, added l.fl1 instruction, corrected encoding of l.maci and added more description of tick timer. |
0.0-14 |
15/Nov/2005 |
Damjan Lampret |
Corrected description of l.sfXXui (arch manual had a wrong description compared to behavior implemented in or1ksim/gcc/or1200). Removed Atomicity chapter. |
0.0-15 |
22/Mar/2011 |
ORSoC Yann Vernier |
Converted to OpenDocument, ABI review, added instruction index and machine code reference table, added ORFPX and ORVDX headings, corrected descriptions for l.div, l.divu, l.ff1, l.fl1, l.mac*, l.mulu, l.msb, l.sub, lv.cmp_*.h, lv.muls.h, lv.pack.h, lv.subus.b, TLBTR, OF64S, specified link register for l.jal and l.jalr, PPN sizes, adjusted instruction classes, various typographical cleanups, clarified delay slot and exception interaction for l.j* and l.sys, removed empty 32-bit implementation for lv.pack/unpack to prevent blank pages |
0.0-16 |
6/Aug/2011 |
Julius Baxter |
Added architecture revision information. |
0.0-17 |
05/Dec/2012 |
Julius Baxter |
Architecture version update Clarify unimplemented SPR space to be read as zero, writing to have no effect Clarify GPR0 implementation and use Remove l.trap instruction's conditional execution function Update ABI statement on returning structures by value Fix typo in register width description of l.sfle.d instruction Add UVRP bit in VR Add description of SPR VR2 Add description of SPR AVR Add description of SPR EVBAR Mention implication of EVBAR in appropriate sections Add description of ISR SPRs Add presence bits for AVR, EVBAR, ISRs to CPUCFGR Add ND bit to CPUCFGR and mention optional delay slot in appropriate sections Mention exceptions possible for all branch/jump instructions Add description of SPRs AECR, AESR Add presence bits for AECR and AESR to CPUCFGR Clarify overflow exception behavior for appropriate unsigned and signed arithmetic instructions (l.add, l.addi, l.addc, l.addic, l.mul, l.muli, l.mulu, l.div, l.divu, l.sub, l.mac, l.maci, l.msb) Remove “signed” from name of addition and subtraction instructions, as they are used for both unsigned and signed arithmetic Add l.macu and l.msbu instructions for performing unsigned MAC operations Add l.muld and l.muldu for performing multiplication and allowing the 64-bit result to be accessible on 32-bit implementations |
1.0-0 |
21/Apr/2014 |
Stefan Kristiansson |
Add atomicity chapter. Add l.lwa and l.swa instructions. |
1.1-0 |
Table 1-2. Revision History
1.4Work in Progress
This document is work in progress. Anything in the manual could change until we have made our first silicon. The latest version is always available from OPENCORES revision control (Subversion as of this writing). See details about how to get it on www.opencores.org.
We are currently looking for people to work on and maintain this document. If you would like to contribute, please send an email to one of the authors.
1.5Fonts in this Manual
In this manual, fonts are used as follows:
Typewriter font is used for programming examples.
Bold font is used for emphasis.
UPPER CASE items may be either acronyms or register mode fields that can be written by software. Some common acronyms appear in the glossary.
Square brackets [] indicate an addressed field in a register or a numbered register in a register file.
1.6Conventions
l.mnemonic |
Identifies an ORBIS32/64 instruction. |
lv.mnemonic |
Identifies an ORVDX32/64 instruction. |
lf.mnemonic |
Identifies an ORFPX32/64 instruction. |
0x |
Indicates a hexadecimal number. |
rA |
Instruction syntax used to identify a general purpose register |
REG[FIELD] |
Syntax used to identify specific bit(s) of a general or special purpose register. FIELD can be a name of one bit or a group of bits or a numerical range constructed from two values separated by a colon. |
X |
In certain contexts, this indicates a ‘don't care’. |
N |
In certain contexts, this indicates an undefined numerical value. |
Implementation |
An actual processor implementing the OpenRISC 1000 architecture. |
Unit |
Sometimes referred to as a coprocessor. An implemented unit usually with some special registers and controlling instructions. It can be defined by the architecture or it may be custom. |
Exception |
A vectored transfer of control to supervisor software through an exception vector table. A way in which a processor can request operating system assistance (division by zero, TLB miss, external interrupt etc). |
Privileged |
An instruction (or register) that can only be executed (or accessed) when the processor is in supervisor mode (when SR[SM]=1). |
Table 1-3. Conventions
1.7Numbering
All numbers are decimal or hexadecimal unless otherwise indicated. The prefix 0x indicates a hexadecimal number. Decimal numbers don't have a special prefix. Binary and other numbers are marked with their base.
2Architecture Overview
This chapter introduces the OpenRISC 1000 architecture and describes the general architectural features.
2.1Features
The OpenRISC 1000 architecture includes the following principal features:
A completely free and open architecture.
A linear, 32-bit or 64-bit logical address space with implementation-specific physical address space.
Simple and uniform-length instruction formats featuring different instruction set extensions:
OpenRISC Basic Instruction Set (ORBIS32/64) with 32-bit wide instructions aligned on 32-bit boundaries in memory and operating on 32- and 64-bit data
OpenRISC Vector/DSP eXtension (ORVDX64) with 32-bit wide instructions aligned on 32-bit boundaries in memory and operating on 8-, 16-, 32- and 64-bit data
OpenRISC Floating-Point eXtension (ORFPX32/64) with 32-bit wide instructions aligned on 32-bit boundaries in memory and operating on 32- and 64-bit data
Two simple memory addressing modes, whereby memory address is calculated by:
addition of a register operand and a signed 16-bit immediate value
addition of a register operand and a signed 16-bit immediate value followed by update of the register operand with the calculated effective address
Two register operands (or one register and a constant) for most instructions who then place the result in a third register
Shadowed or single 32-entry or narrow 16-entry general purpose register file
Optional branch delay slot for keeping the pipeline as full as possible
Support for separate instruction and data caches/MMUs (Harvard architecture) or for unified instruction and data caches/MMUs (Stanford architecture)
A flexible architecture definition that allows certain functions to be performed either in hardware or with the assistance of implementation-specific software
Number of different, separated exceptions simplifying exception model
Fast context switch support in register set, caches, and MMUs
2.2Introduction
The OpenRISC 1000 architecture is a completely open architecture. It defines the architecture of a family of open source, RISC microprocessor cores. The OpenRISC 1000 architecture allows for a spectrum of chip and system implementations at a variety of price/performance points for a range of applications. It is a 32/64-bit load and store RISC architecture designed with emphasis on performance, simplicity, low power requirements, and scalability. OpenRISC 1000 targets medium and high performance networking and embedded computer environments.
Performance features include a full 32/64-bit architecture; vector, DSP and floating-point instructions; powerful virtual memory support; cache coherency; optional SMP and SMT support, and support for fast context switching. The architecture defines several features for networking and embedded computer environments. Most notable are several instruction extensions, a configurable number of general-purpose registers, configurable cache and TLB sizes, dynamic power management support, and space for user-provided instructions.
The OpenRISC 1000 architecture is the predecessor of a richer and more powerful next generation of OpenRISC architectures.
The full source for implementations of the OpenRISC 1000 architecture is available at www.opencores.org and is supported with GNU software development tools and a behavioral simulator. Most OpenRISC implementations are designed to be modular and vendor-independent. They can be interfaced with other open-source cores available at www.opencores.org.
Opencores.org encourages third parties to design and market their own implementations of the OpenRISC 1000 architecture and to participate in further development of the architecture.
2.3Architecture Version Information
It is anticipated that revisions of the OR1K architecture will come about as architectural modifications are made over time. This document shall be valid for the latest version stated in it. Each implementation should indicate the minimum revision it supports in the Architecture Version Register (AVR).
The following table lists the versions and their release date.
Version |
Date |
Summary |
0.0 |
November 2005 |
Initial architecture specification. |
1.0 |
December 2012 |
First version. |
1.1 |
April 2014 |
Atomic instructions additions. |
Table 2-1: Architecture Version Information
3Addressing Modes and Operand Conventions
This chapter describes memory-addressing modes and memory operand conventions defined by the OpenRISC 1000 system architecture.
3.1Memory Addressing Modes
The processor computes an effective address when executing a memory access instruction or branch instruction or when fetching the next sequential instruction. If the sum of the effective address and the operand length exceeds the maximum effective address in logical address space, the memory operand wraps around from the maximum effective address through effective address 0.
3.1.1Register Indirect with Displacement
Load/store instructions using this address mode contain a signed 16-bit immediate value, which is sign-extended and added to the contents of a general-purpose register specified in the instruction.
Figure 3-1. Register Indirect with Displacement Addressing
Figure 3-1 shows how an effective address is computed when using register indirect with displacement addressing mode.
3.1.2PC Relative
Branch instructions using this address mode contain a signed 26-bit immediate value that is sign-extended and added to the contents of a Program Counter register. Before the execution at the destination PC, instruction in delay slot is executed if the ND bit in CPU Configuration Register (CPUCFGR) is set.
Figure 3-2. PC Relative Addressing
Figure 3-2 shows how an effective address is generated when using PC relative addressing mode.
3.2Memory Operand Conventions
The architecture defines an 8-bit byte, 16-bit halfword, a 32-bit word, and a 64-bit doubleword. It also defines IEEE-754 compliant 32-bit single precision float and 64-bit double precision float storage units. 64-bit vectors of bytes, 64-bit vectors of halfwords, 64-bit vectors of singlewords, and 64-bit vectors of single precision floats are also defined.
Type of Data |
Length in Bytes |
Length in Bits |
Byte |
1 |
8 |
Halfword (or half) |
2 |
16 |
Singleword (or word) |
4 |
32 |
Doubleword (or double) |
8 |
64 |
Single precision float |
4 |
32 |
Double precision float |
8 |
64 |
Vector of bytes |
8 |
64 |
Vector of halfwords |
8 |
64 |
Vector of singlewords |
8 |
64 |
Vector of single precision floats |
8 |
64 |
Table 3-1. Memory Operands and their sizes
3.2.1Bit and Byte Ordering
Byte ordering defines how the bytes that make up halfwords, singlewords and doublewords are ordered in memory. To simplify OpenRISC implementations, the architecture implements Most Significant Byte (MSB) ordering – or big endian byte ordering by default. But implementations can support Least Significant Byte (LSB) ordering if they implement byte reordering hardware. Reordering is enabled with bit SR[LEE].
The figures below illustrate the conventions for bit and byte numbering within various width storage units. These conventions hold for both integer and floating-point data, where the most significant byte of a floating-point value holds the sign and at least significant byte holds the start of the exponent.
Table 3-2 shows how bits and bytes are ordered in a halfword.
-
Bit 15
Bit 8
Bit 7
Bit 0
MSB
LSB
Byte address 0
Byte address 1
Table 3-2. Default Bit and Byte Ordering in Halfwords
Table 3-3 shows how bits and bytes are ordered in a singleword.
Bit 31 |
|
Bit 24 |
Bit 23 |
Bit 16 |
Bit 15 |
Bit 8 |
Bit 7 |
|
Bit 0 |
MSB |
|
|
LSB |
||||||
Byte address 0 |
Byte address 1 |
Byte address 2 |
Byte address 3 |
Table 3-3. Default Bit and Byte Ordering in Singlewords and Single Precision Floats
Table 3-4 shows how bits and bytes are ordered in a doubleword.
Bit 63 |
|
Bit 56 |
|
|
|
||
MSB |
|
|
|
||||
Byte address 0 |
Byte address 1 |
Byte address 2 |
Byte address 3 |
||||
|
|
|
|
||||
|
|
|
Bit 7 |
|
Bit 0 |
||
|
|
|
LSB |
||||
Byte address 4 |
Byte address 5 |
Byte address 6 |
Byte address 7 |
Table 3-4. Default Bit and Byte Ordering in Doublewords, Double Precision Floats and all Vector Types
3.2.2Aligned and Misaligned Accesses
A memory operand is naturally aligned if its address is an integral multiple of the operand length. Implementations might support accessing unaligned memory operands, but the default behavior is that accesses to unaligned operands result in an alignment exception. See chapter Exception Model on page 255 for information on alignment exception.
Current OR32 implementations (OR1200) do not implement 8 byte alignment, but do require 4 byte alignment. Therefore the Application Binary Interface (chapter 16) uses 4 byte alignment for 8 byte types. Future extensions such as ORVDX64 may require natural alignment.
Operand |
Length |
addr[3:0] if aligned |
Byte |
8 bits |
Xxxx |
Halfword (or half) |
2 bytes |
Xxx0 |
Singleword (or word) |
4 bytes |
Xx00 |
Doubleword (or double) |
8 bytes |
X000 |
Single precision float |
4 bytes |
Xx00 |
Double precision float |
8 bytes |
X000 |
Vector of bytes |
8 bytes |
X000 |
Vector of halfwords |
8 bytes |
X000 |
Vector of singlewords |
8 bytes |
X000 |
Vector of single precision floats |
8 bytes |
X000 |
Table 3-5. Memory Operand Alignment
OR32 instructions are four bytes long and word-aligned.
4Register Set
4.1Features
The OpenRISC 1000 register set includes the following principal features:
Thirty-two or sixteen 32/64-bit general-purpose registers – OpenRISC 1000 implementations optimized for use in FPGAs and ASICs in embedded and similar environments may implement only the first sixteen of the possible thirty-two registers.
All other registers are special-purpose registers defined for each unit separately and accessible through the l.mtspr/l.mfspr instructions.
4.2Overview
An OpenRISC 1000 processor includes several types of registers: user level general-purpose and special-purpose registers, supervisor level special-purpose registers and unit-dependent registers.
User level general-purpose and special-purpose registers are accessible both in user mode and supervisor mode of operation. Supervisor level special-purpose registers are accessible only in supervisor mode of operation (SR[SM]=1).
Unit dependent registers are usually only accessible in supervisor mode but there can be exceptions to this rule. Accessibility for architecture-defined units is defined in this manual. Accessibility for custom units not covered by this manual will be defined in the appropriate implementation-specific manuals.
4.3Special-Purpose Registers
The special-purpose registers of all units are grouped into thirty-two groups. Each group can have different register address decoding depending on the maximum theoretical number of registers in that particular group. A group can contain registers from several different units or processes. The SR[SM] bit is also used in register address decoding, as some registers are accessible only in supervisor mode. The l.mtspr and l.mfspr instructions are used for reading and writing registers.
Unimplemented SPRs should read as zero. Writing to unimplemented SPRs will have no effect, and the l.mtspr instruction will effectively be a no-operation.
GROUP # |
UNIT DESCRIPTION |
0 |
System Control and Status registers |
1 |
Data MMU (in the case of a single unified MMU, groups 1 and 2 decode into a single set of registers) |
2 |
Instruction MMU (in the case of a single unified MMU, groups 1 and 2 decode into a single set of registers) |
3 |
Data Cache (in the case of a single unified cache, groups 3 and 4 decode into a single set of registers) |
4 |
Instruction Cache (in the case of a single unified cache, groups 3 and 4 decode into a single set of registers) |
5 |
MAC unit |
6 |
Debug unit |
7 |
Performance counters unit |
8 |
Power Management |
9 |
Programmable Interrupt Controller |
10 |
Tick Timer |
11 |
Floating Point unit |
12-23 |
Reserved for future use |
24-31 |
Custom units |
Table 4-1. Groups of SPRs
An OpenRISC 1000 processor implementation is required to implement at least the special purpose registers from group 0. All other groups are optional, and registers from these groups are implemented only if the implementation has the corresponding unit. Which units are actually implemented may be determined by reading the UPR register from group 0.
A 16-bit SPR address is made of 5-bit group index (bits 15-11) and 11-bit register index (bits 10-0).
Grp # |
Reg # |
Reg Name |
USER MODE |
SUPV MODE |
Description |
0 |
0 |
VR |
– |
R |
Version register |
0 |
1 |
UPR |
– |
R |
Unit Present register |
0 |
2 |
CPUCFGR |
– |
R |
CPU Configuration register |
0 |
3 |
DMMUCFGR |
– |
R |
Data MMU Configuration register |
0 |
4 |
IMMUCFGR |
– |
R |
Instruction MMU Configuration register |
0 |
5 |
DCCFGR |
– |
R |
Data Cache Configuration register |
0 |
6 |
ICCFGR |
– |
R |
Instruction Cache Configuration register |
0 |
7 |
DCFGR |
– |
R |
Debug Configuration register |
0 |
8 |
PCCFGR |
–– |
R |
Performance Counters Configuration register |
0 |
9 |
VR2 |
– |
R |
Version register 2 |
0 |
10 |
AVR |
– |
R |
Architecture version register |
0 |
11 |
EVBAR |
– |
R/W |
Exception vector base address register |
0 |
12 |
AECR |
– |
R/W |
Arithmetic Exception Control Register |
0 |
13 |
AESR |
– |
R/W |
Arithmetic Exception Status Register |
0 |
16 |
NPC |
– |
R/W |
PC mapped to SPR space (next PC) |
0 |
17 |
SR |
– |
R/W |
Supervision register |
0 |
18 |
PPC |
– |
R/W |
PC mapped to SPR space (previous PC) |
0 |
20 |
FPCSR |
R* |
R/W |
FP Control Status register |
0 |
21-28 |
ISR0-ISR7 |
|
R |
Implementation-specific registers |
0 |
32-47 |
EPCR0-EPCR15 |
– |
R/W |
Exception PC registers |
0 |
48-63 |
EEAR0-EEAR15 |
– |
R/W |
Exception EA registers |
0 |
64-79 |
ESR0-ESR15 |
– |
R/W |
Exception SR registers |
0 |
1024-1535 |
GPR0-GPR511 |
– |
R/W |
GPRs mapped to SPR space |
1 |
0 |
DMMUCR |
– |
R/W |
Data MMU Control register |
1 |
1 |
DMMUPR |
– |
R/W |
Data MMU Protection Register |
1 |
2 |
DTLBEIR |
– |
W |
Data TLB Entry Invalidate register |
1 |
4-7 |
DATBMR0-DATBMR3 |
– |
R/W |
Data ATB Match registers |
1 |
8-11 |
DATBTR0-DATBTR3 |
– |
R/W |
Data ATB Translate registers |
1 |
512-639 |
DTLBW0MR0-DTLBW0MR127 |
– |
R/W |
Data TLB Match registers Way 0 |
1 |
640-767 |
DTLBW0TR0-DTLBW0TR127 |
– |
R/W |
Data TLB Translate registers Way 0 |
1 |
768-895 |
DTLBW1MR0-DTLBW1MR127 |
– |
R/W |
Data TLB Match registers Way 1 |
1 |
896-1023 |
DTLBW1TR0-DTLBW1TR127 |
– |
R/W |
Data TLB Translate registers Way 1 |
1 |
1024-1151 |
DTLBW2MR0-DTLBW2MR127 |
– |
R/W |
Data TLB Match registers Way 2 |
1 |
1152-1279 |
DTLBW2TR0-DTLBW2TR127 |
– |
R/W |
Data TLB Translate registers Way 2 |
1 |
1280-1407 |
DTLBW3MR0-DTLBW3MR127 |
– |
R/W |
Data TLB Match registers Way 3 |
1 |
1408-1535 |
DTLBW3TR0-DTLBW3TR127 |
– |
R/W |
Data TLB Translate registers Way 3 |
2 |
0 |
IMMUCR |
– |
R/W |
Instruction MMU Control register |
2 |
1 |
IMMUPR |
– |
R/W |
Instruction MMU Protection Register |
2 |
2 |
ITLBEIR |
– |
W |
Instruction TLB Entry Invalidate register |
2 |
4-7 |
IATBMR0-IATBMR3 |
– |
R/W |
Instruction ATB Match registers |
2 |
8-11 |
IATBTR0-IATBTR3 |
– |
R/W |
Instruction ATB Translate registers |
2 |
512-639 |
ITLBW0MR0-ITLBW0MR127 |
– |
R/W |
Instruction TLB Match registers Way 0 |
2 |
640-767 |
ITLBW0TR0-ITLBW0TR127 |
– |
R/W |
Instruction TLB Translate registers Way 0 |
2 |
768-895 |
ITLBW1MR0-ITLBW1MR127 |
– |
R/W |
Instruction TLB Match registers Way 1 |
2 |
896-1023 |
ITLBW1TR0-ITLBW1TR127 |
– |
R/W |
Instruction TLB Translate registers Way 1 |
2 |
1024-1151 |
ITLBW2MR0-ITLBW2MR127 |
– |
R/W |
Instruction TLB Match registers Way 2 |
2 |
1152-1279 |
ITLBW2TR0- ITLBW2TR127 |
– |
R/W |
Instruction TLB Translate registers Way 2 |
2 |
1280-1407 |
ITLBW3MR0-ITLBW3MR127 |
– |
R/W |
Instruction TLB Match registers Way 3 |
2 |
1408-1535 |
ITLBW3TR0-ITLBW3TR127 |
– |
R/W |
Instruction TLB Translate registers Way 3 |
3 |
0 |
DCCR |
– |
R/W |
DC Control register |
3 |
1 |
DCBPR |
W |
W |
DC Block Prefetch register |
3 |
2 |
DCBFR |
W |
W |
DC Block Flush register |
3 |
3 |
DCBIR |
– |
W |
DC Block Invalidate register |
3 |
4 |
DCBWR |
W |
W |
DC Block Write-back register |
3 |
5 |
DCBLR |
W |
W |
DC Block Lock register |
4 |
0 |
ICCR |
– |
R/W |
IC Control register |
4 |
1 |
ICBPR |
W |
W |
IC Block Prefetch register |
4 |
2 |
ICBIR |
– |
W |
IC Block Invalidate register |
4 |
3 |
ICBLR |
W |
W |
IC Block Lock register |
5 |
1 |
MACLO |
R/W* |
R/W* |
MAC Low |
5 |
2 |
MACHI |
R/W* |
R/W* |
MAC High |
6 |
0-7 |
DVR0-DVR7 |
– |
R/W |
Debug Value registers |
6 |
8-15 |
DCR0-DCR7 |
– |
R/W |
Debug Control registers |
6 |
16 |
DMR1 |
– |
R/W |
Debug Mode register 1 |
6 |
17 |
DMR2 |
– |
R/W |
Debug Mode register 2 |
6 |
18-19 |
DCWR0-DCWR1 |
– |
R/W |
Debug Watchpoint Counter registers |
6 |
20 |
DSR |
– |
R/W |
Debug Stop register |
6 |
21 |
DRR |
– |
R/W |
Debug Reason register |
7 |
0-7 |
PCCR0-PCCR7 |
R* |
R/W |
Performance Counters Count registers |
7 |
8-15 |
PCMR0-PCMR7 |
– |
R/W |
Performance Counters Mode registers |
8 |
0 |
PMR |
– |
R/W |
Power Management register |
9 |
0 |
PICMR |
– |
R/W |
PIC Mask register |
9 |
2 |
PICSR |
– |
R/W |
PIC Status register |
10 |
0 |
TTMR |
– |
R/W |
Tick Timer Mode register |
10 |
1 |
TTCR |
R* |
R/W |
Tick Timer Count register |
Table 4-2. List of All Special-Purpose Registers
SPRs with R* for user mode access are readable in user mode if SR[SUMRA] is set.
The MACLO and MACHI registers are synchronized, such that any ongoing MAC operation finishes before they are read or written.
4.4General-Purpose Registers (GPRs)
The thirty-two general-purpose registers are labeled R0-R31 and are 32 bits wide in 32-bit implementations and 64 bits wide in 64-bit implementations. They hold scalar integer data, floating-point data, vectors or memory pointers. Table 4-3 contains a list of general-purpose registers. The GPRs may be accessed as both source and destination registers by ORBIS, ORVDX and ORFPX instructions.
See chapter Application Binary Interface on page 332 for information on floating-point data types. See also Register Usage on page 335, where r9 is defined as the Link Register.
Register |
|
|
|
|
r31 |
r30 |
Register |
r29 |
r28 |
r27 |
r26 |
r25 |
r24 |
Register |
r23 |
r22 |
r21 |
r20 |
r19 |
r18 |
Register |
r17 |
r16 |
r15 |
r14 |
r13 |
r12 |
Register |
r11 |
r10 |
r9 LR |
r8 |
r7 |
r6 |
Register |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
Table 4-3. General-Purpose Registers
R0 should always hold a zero value. It is the responsibility of software to initialize it. (This differs from architecture version 0 which commented on implementation and that it should never be used as a destination register – this is no longer specified.) Functions of other registers are explained in chapter Application Binary Interface on page 332.
An implementation may have several sets of GPRs and use them as shadow registers, switching between them whenever a new exception occurs. The current set is identified by the SR[CID] value.
An implementation is not required to initialize GPRs to zero during the reset procedure. The reset exception handler is responsible for initializing GPRs to zero if that is necessary.
4.5Support for Custom Number of GPRs
Programs may be compiled with less than thirty-two registers. Unused registers are disabled (set as fixed registers) when compiling code. Such code is also executable on normal implementations with thirty-two registers but not vice versa. This feature is quite useful since users are expected to move from less powerful OpenRISC implementations with less than thirty-two registers to more powerful thirty-two register OpenRISC implementations.
If configuration registers are implemented, CPUCFGR[CGF] indicates whether implementation has complete thirty-two general-purpose registers or less than thirty-two registers. OR1200 has been implemented with 16 or 32 registers.
4.6Supervision Register (SR)
The Supervison register is a 32-bit special-purpose supervisor-level register accessible with the l.mtspr/l.mfspr instructions in supervisor mode only.
The SR value defines the state of the processor.
Bit |
31-28 |
27-17 |
16 |
Identifier |
CID |
Reserved |
SUMRA |
Reset |
0 |
0 |
0 |
R/W |
R/W |
Read Only |
R/W |
Bit |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
Identifier |
FO |
EPH |
DSX |
OVE |
OV |
CY |
F |
CE |
Reset |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
Bit |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
Identifier |
LEE |
IME |
DME |
ICE |
DCE |
IEE |
TEE |
SM |
Reset |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
SM |
Supervisor Mode 0 Processor is in User Mode 1 Processor is in Supervisor Mode |
TEE |
Tick Timer Exception Enabled 0 Tick Timer Exceptions are not recognized 1 Tick Timer Exceptions are recognized |
IEE |
Interrupt Exception Enabled 0 Interrupts are not recognized 1 Interrupts are recognized |
DCE |
Data Cache Enable 0 Data Cache is not enabled 1 Data Cache is enabled |
ICE |
Instruction Cache Enable 0 Instruction Cache is not enabled 1 Instruction Cache is enabled |
DME |
Data MMU Enable 0 Data MMU is not enabled 1 Data MMU is enabled |
IME |
Instruction MMU Enable 0 Instruction MMU is not enabled 1 Instruction MMU is enabled |
LEE |
Little Endian Enable 0 Little Endian (LSB) byte ordering is not enabled 1 Little Endian (LSB) byte ordering is enabled |
CE |
CID Enable 0 CID disabled and shadow registers disabled 1 CID automatic increment and shadow registers enabled |
F |
Flag 0 Conditional branch flag was cleared by sfXX instructions 1 Conditional branch flag was set by sfXX instructions |
CY |
Carry flag 0 No carry out produced by last arithmetic operation 1 Carry out was produced by last arithmetic operation |
OV |
Overflow flag 0 No overflow occured during last arithmetic operation 1 Overflow occured during last arithmetic operation |
OVE |
Overflow flag Exception 0 Overflow flag does not cause an exception 1 Overflow flag causes range exception |
DSX |
Delay Slot Exception 0 EPCR points to instruction not in the delay slot 1 EPCR points to instruction in delay slot |
EPH |
Exception Prefix High 0 Exceptions vectors are located in memory area starting at 0x0 1 Exception vectors are located in memory area starting at 0xF0000000 |
FO |
Fixed One This bit is always set |
SUMRA |
SPRs User Mode Read Access 0 All SPRs are inaccessible in user mode 1 Certain SPRs can be read in user mode |
CID |
Context ID (Fast Context Switching (Optional), page 258) 0-15 Current Processor Context |
Table 4-4. SR Field Descriptions
4.7Exception Program Counter Registers (EPCR0 - EPCR15)
The Exception Program Counter registers are special-purpose supervisor-level registers accessible with the l.mtspr/l.mfspr instructions in supervisor mode. Read access in user mode is possible if it is enabled in PCMRx[SUMRA]. They are 32-bit wide registers in 32-bit implementations and can be wider than 32 bits in 64-bit implementations.
After an exception, the EPCR is set to the program counter address (PC) of the instruction that was interrupted by the exception. If only one EPCR is present in the implementation (Fast Context Switching (Optional) disabled), it must be saved by the exception handler routine before exception recognition is re-enabled in the SR.
Bit |
31-0 |
Identifier |
EPC |
Reset |
0 |
R/W |
R/W |
EPC |
Exception Program Counter Address |
Table 4-5. EPCR Field Descriptions
4.8Exception Effective Address Registers (EEAR0-EEAR15)
The Exception Effective Address registers are special-purpose supervisor-level registers accessible with the l.mtspr/l.mfspr instructions in supervisor mode. Read access in user mode is possible if it is enabled in SR[SUMRA]. The EEARs are 32-bit wide registers in 32-bit implementations and can be wider than 32 bits in 64-bit implementations.
After an exception, the EEAR is set to the effective address (EA) generated by the faulting instruction. If only one EEAR is present in the implementation, it must be saved by the exception handler routine before exception recognition is re-enabled in the SR.
Bit |
31-0 |
Identifier |
EEA |
Reset |
0 |
R/W |
R/W |
EEA |
Exception Effective Address |
Table 4-6. EEAR Field Descriptions
4.9Exception Supervision Registers (ESR0‑ESR15)
The Exception Supervision registers are special-purpose supervisor-level registers accessible with l.mtspr/l.mfspr instructions in supervisor mode. They are 32 bits wide registers in 32-bit implementations and can be wider than 32 bits in 64-bit implementations.
After an exception, the Supervision register (SR) is copied into the ESR. If only one ESR is present in the implementation, it must be saved by the exception handler routine before exception recognition is re-enabled in the SR.
Bit |
31-0 |
Identifier |
ESR |
Reset |
0 |
R/W |
R/W |
EEA |
Exception SR |
Table 4-7. ESR Field Descriptions
4.10Next and Previous Program Counter (NPC and PPC)
The Program Counter registers represent the address just executed and the address instruction just to be executed.
These and the GPR registers mapped into SPR space should only be used for debugging purposes by an external debugger. Applications should use the l.jal instruction to obtain the current program counter and arithmethic instructions to obtain GPR register values.
4.11Floating Point Control Status Register (FPCSR)
Floating point control status register is a 32-bit special-purpose register accessible with the l.mtspr/l.mfspr instructions in supervisor mode and as read-only register in user mode if enabled in SR[SUMRA].
The FPCSR value controls floating point rounding modes, optional generation of floating point exception and provides floating point status flags. Status flags are updated after every floating point instruction is completed and can serve to determine what caused the floating point exception.
If floating point exception is enabled then FPCSR status flags have to be cleared in floating point exception handler. Status flags are cleared by writing 0 to all status bits.
Bit |
31-12 |
11 |
10 |
9 |
8 |
Identifier |
Reserved |
DZF |
INF |
IVF |
IXF |
Reset |
0 |
0 |
0 |
0 |
0 |
R/W |
Read Only |
R/W |
R/W |
R/W |
R/W |
Bit |
7 |
6 |
5 |
4 |
3 |
2-1 |
0 |
Identifier |
ZF |
QNF |
SNF |
UNF |
OVF |
RM |
FPEE |
Reset |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
R/W |
FPEE |
Floating Point Exception Enabled 0 FP Exception is disabled 1 FP Exception is enabled |
RM |
Rounding Mode 0 Round to nearest 1 Round to zero 2 Round to infinity+ 3 Round to infinity- |
OVF |
OVerflow Flag 0 No overflow 1 Result overflowed |
UNF |
UNderflow Flag 0 No underflow 1 Result underflowed |
SNF |
SNAN Flag 0 Result not SNAN 1 Result SNAN |
QNF |
QNAN Flag 0 Result not QNAN 1 Result QNAN |
ZF |
Zero Flag 0 Result not zero 1 Result zero |
IXF |
IneXact Flag 0 Result precise 1 Result inexact |
IVF |
InValid Flag 0 Result valid 1 Result invalid |
INF |
INfinity Flag 0 Result finite 1 Result infinite |
DZF |
Divide by Zero Flag 0 Proper divide 1 Divide by zero |
Table 4-8. FPCSR Field Descriptions
5Instruction Set
This chapter describes the OpenRISC 1000 instruction set.
5.1Features
The OpenRISC 1000 instruction set includes the following principal features:
Simple and uniform-length instruction formats featuring five Instruction Subsets
OpenRISC Basic Instruction Set (ORBIS32/64) with 32-bit wide instructions aligned on 32-bit boundaries in memory and operating on 32-bit and 64-bit data
OpenRISC Vector/DSP eXtension (ORVDX64) with 32-bit wide instructions aligned on 32-bit boundaries in memory and operating on 8-, 16-, 32- and 64-bit data
OpenRISC Floating-Point eXtension (ORFPX32/64) with 32-bit wide instructions aligned on 32-bit boundaries in memory and operating on 32-bit and 64-bit data
Reserved opcodes for custom instructions
Note: Instructions are divided into instruction classes. Only the basic classes are required to be implemented in an OpenRISC 1000 implementation.
Figure 5-1. Instruction Set
5.2Overview
OpenRISC 1000 instructions belong to one of the following instruction subsets:
ORBIS32:
32-bit integer instructions
Basic DSP instructions
32-bit load and store instructions
Program flow instructions
Special instructions
ORBIS64:
64-bit integer instructions
64-bit load and store instructions
ORFPX32:
Single-precision floating-point instructions
ORFPX64:
Double-precision floating-point instructions
64-bit load and store instructions
ORVDX64:
Vector instructions
DSP instructions
Instructions in each subset are also split into two instruction classes according to implementation importance:
Class I
Class II
Class |
Description |
I |
Instructions in class I must always be implemented. |
II |
Instructions from class II are optional and an implementation may choose to use some or all instructions from this class based on requirements of the target application. |
Table 5-1. OpenRISC 1000 Instruction Classes
5.3ORBIS32/64
Format:
l.add rD,rA,rB
Description:
The contents of general-purpose register rA are added to the contents of general-purpose register rB to form the result. The result is placed into general-purpose register rD.
The instruction will set the carry flag on unsigned overflow, and the overflow flag on signed overflow.
32-bit Implementation:
rD[31:0]
←
rA[31:0] + rB[31:0]
SR[CY]
←
carry (unsigned
overflow)
SR[OV]
←
signed overflow
64-bit Implementation:
rD[63:0]
←
rA[63:0] + rB[63:0]
SR[CY]
←
carry (unsigned
overflow)
SR[OV]
←
signed overflow
Exceptions:
Range Exception on overflow if SR[OVE] and AECR[OVADDE] are set.
Range Exception on carry if SR[OVE] and AECR[CYADDE] are set.
Format:
l.addc rD,rA,rB
Description:
The contents of general-purpose register rA are added to the contents of general-purpose register rB and carry SR[CY] to form the result. The result is placed into general-purpose register rD.
The instruction will set the carry flag on unsigned overflow, and the overflow flag on signed overflow.
32-bit Implementation:
rD[31:0]
←
rA[31:0] + rB[31:0] + SR[CY]
SR[CY]
←
carry (unsigned
overflow)
SR[OV]
←
signed overflow
64-bit Implementation:
rD[63:0]
←
rA[63:0] + rB[63:0] + SR[CY]
SR[CY]
←
carry (unsigned overflow)
SR[OV]
←
overflow
Exceptions:
Range Exception on overflow if SR[OVE] and AECR[OVADDE] are set.
Range Exception on carry if SR[OVE] and AECR[CYADDE] are set.
Format:
l.addi rD,rA,I
Description:
The immediate value is sign-extended and added to the contents of general-purpose register rA to form the result. The result is placed into general-purpose register rD.
The instruction will set the carry flag on unsigned overflow, and the overflow flag on signed overflow.
32-bit Implementation:
rD[31:0]
←
rA[31:0] + exts(Immediate)
SR[CY]
←
carry (unsigned
overflow)
SR[OV]
←
signed overflow
64-bit Implementation:
rD[63:0]
←
rA[63:0] + exts(Immediate)
SR[CY]
←
carry (unsigned
overflow)
SR[OV]
←
signed overflow
Exceptions:
Range Exception on overflow if SR[OVE] and AECR[OVADDE] are set.
Range Exception on carry if SR[OVE] and AECR[CYADDE] are set.
Format:
l.addic rD,rA,I
Description:
The immediate value is sign-extended and added to the contents of general-purpose register rA and carry SR[CY] to form the result. The result is placed into general-purpose register rD.
The instruction will set the carry flag on unsigned overflow, and the overflow flag on signed overflow.
32-bit Implementation:
rD[31:0]
←
rA[31:0] + exts(Immediate) + SR[CY]
SR[CY]
←
carry (unsigned
overflow)
SR[OV]
←
signed overflow
64-bit Implementation:
rD[63:0]
←
rA[63:0] + exts(Immediate) + SR[CY]
SR[CY]
←
carry (unsigned
overflow)
SR[OV]
←
signed overflow
Exceptions:
Range Exception on overflow if SR[OVE] and AECR[OVADDE] are set.
Range Exception on carry if SR[OVE] and AECR[CYADDE] are set.
Format:
l.and rD,rA,rB
Description:
The contents of general-purpose register rA are combined with the contents of general-purpose register rB in a bit-wise logical AND operation. The result is placed into general-purpose register rD.
32-bit Implementation:
rD[31:0] ← rA[31:0] AND rB[31:0]
64-bit Implementation:
rD[63:0] ← rA[63:0] AND rB[63:0]
Exceptions:
None
Format:
l.andi rD,rA,K
Description:
The immediate value is zero-extended and combined with the contents of general-purpose register rA in a bit-wise logical AND operation. The result is placed into general-purpose register rD.
32-bit Implementation:
rD[31:0] ← rA[31:0] AND extz(Immediate)
64-bit Implementation:
rD[63:0] ← rA[63:0] AND extz(Immediate)
Exceptions:
None
Format:
l.bf N
Description:
The immediate value is shifted left two bits, sign-extended to program counter width, and then added to the address of the branch instruction. The result is the effective address of the branch. If the flag is set, the program branches to EA. If CPUCFGR[ND] is not set, the branch occurs with a delay of one instruction.
32-bit Implementation:
EA
←
exts(Immediate << 2) + BranchInsnAddr
PC
←
EA if SR[F] set
64-bit Implementation:
EA
←
exts(Immediate << 2) + BranchInsnAddr
PC
←
EA if SR[F] set
Exceptions:
None
Format:
l.bnf N
Description:
The immediate value is shifted left two bits, sign-extended to program counter width, and then added to the address of the branch instruction. The result is the effective address of the branch. If the flag is cleared, the program branches to EA. If CPUCFGR[ND] is not set, the branch occurs with a delay of one instruction.
32-bit Implementation:
EA
←
exts(Immediate << 2) + BranchInsnAddr
PC
←
EA if SR[F] cleared
64-bit Implementation:
EA
←
exts(Immediate << 2) + BranchInsnAddr
PC
←
EA if SR[F] cleared
Exceptions:
None
Format:
l.cmov rD,rA,rB
Description:
If SR[F] is set, general-purpose register rA is placed in general-purpose register rD. If SR[F] is cleared, general-purpose register rB is placed in general-purpose register rD.
32-bit Implementation:
rD[31:0] ← SR[F] ? rA[31:0] : rB[31:0]
64-bit Implementation:
rD[63:0] ← SR[F] ? rA[63:0] : rB[63:0]
Exceptions:
None
Format:
l.csync
Description:
Execution of context synchronization instruction results in completion of all operations inside the processor and a flush of the instruction pipelines. When all operations are complete, the RISC core resumes with an empty instruction pipeline and fresh context in all units (MMU for example).
32-bit Implementation:
context-synchronization
64-bit Implementation:
context-synchronization
Exceptions:
None
Format:
l.cust1
Description:
This fake instruction only allocates instruction set space for custom instructions. Custom instructions are those that are not defined by the architecture but rather by the implementation itself.
32-bit Implementation:
N/A
64-bit Implementation:
N/A
Exceptions:
N/A
Format:
l.cust2
Description:
This fake instruction only allocates instruction set space for custom instructions. Custom instructions are those that are not defined by the architecture but rather by the implementation itself.
32-bit Implementation:
N/A
64-bit Implementation:
N/A
Exceptions:
N/A
Format:
l.cust3
Description:
This fake instruction only allocates instruction set space for custom instructions. Custom instructions are those that are not defined by the architecture but rather by the implementation itself.
32-bit Implementation:
N/A
64-bit Implementation:
N/A
Exceptions:
N/A
Format:
l.cust4
Description:
This fake instruction only allocates instruction set space for custom instructions. Custom instructions are those that are not defined by the architecture but rather by the implementation itself.
32-bit Implementation:
N/A
64-bit Implementation:
N/A
Exceptions:
N/A
Format:
l.cust5 rD,rA,rB,L,K
Description:
This fake instruction only allocates instruction set space for custom instructions. Custom instructions are those that are not defined by the architecture but rather by the implementation itself.
32-bit Implementation:
N/A
64-bit Implementation:
N/A
Exceptions:
N/A
Format:
l.cust6
Description:
This fake instruction only allocates instruction set space for custom instructions. Custom instructions are those that are not defined by the architecture but rather by the implementation itself.
32-bit Implementation:
N/A
64-bit Implementation:
N/A
Exceptions:
N/A
Format:
l.cust7
Description:
This fake instruction only allocates instruction set space for custom instructions. Custom instructions are those that are not defined by the architecture but rather by the implementation itself.
32-bit Implementation:
N/A
64-bit Implementation:
N/A
Exceptions:
N/A
Format:
l.cust8
Description:
This fake instruction only allocates instruction set space for custom instructions. Custom instructions are those that are not defined by the architecture but rather by the implementation itself.
32-bit Implementation:
N/A
64-bit Implementation:
N/A
Exceptions:
N/A
Format:
l.div rD,rA,rB
Description:
The content of general-purpose register rA are divided by the content of general-purpose register rB, and the result is placed into general-purpose register rD. Both operands are treated as signed integers.
On divide-by zero, rD will be undefined, and the overflow flag will be set. Note that prior revisions of the manual (pre-2011) stored the divide by zero flag in SR[CY].
32-bit Implementation:
rD[31:0]
←
rA[31:0] / rB[31:0]
SR[OV]
←
rB[31:0]
== 0
64-bit Implementation:
rD[63:0]
←
rA[63:0] / rB[63:0]
SR[OV]
←
rB[63:0]
== 0
Exceptions:
Range Exception when divisor is zero if SR[OVE] and AECR[DBZE] are set.
Format:
l.divu rD,rA,rB
Description:
The content of general-purpose register rA are divided by the content of general-purpose register rB, and the result is placed into general-purpose register rD. Both operands are treated as unsigned integers.
On divide-by zero, rD will be undefined, and the overflow flag will be set.
32-bit Implementation:
rD[31:0]
←
rA[31:0] / rB[31:0]
SR[CY]
←
rB[31:0]
== 0
64-bit Implementation:
rD[63:0]
←
rA[63:0] / rB[63:0]
SR[CY]
←
rB[63:0]
== 0
Exceptions:
Range Exception when divisor is zero if SR[OVE] and AECR[DBZE] are set.
Format:
l.extbs rD,rA
Description:
Bit 7 of general-purpose register rA is placed in high-order bits of general-purpose register rD. The low-order eight bits of general-purpose register rA are copied into the low-order eight bits of general-purpose register rD.
32-bit Implementation:
rD[31:8]
←
rA[7]
rD[7:0]
←
rA[7:0]
64-bit Implementation:
rD[63:8]
←
rA[7]
rD[7:0]
←
rA[7:0]
Exceptions:
None
Format:
l.extbz rD,rA
Description:
Zero is placed in high-order bits of general-purpose register rD. The low-order eight bits of general-purpose register rA are copied into the low-order eight bits of general-purpose register rD.
32-bit Implementation:
rD[31:8]
←
0
rD[7:0]
←
rA[7:0]
64-bit Implementation:
rD[63:8]
←
0
rD[7:0]
←
rA[7:0]
Exceptions:
None
Format:
l.exths rD,rA
Description:
Bit 15 of general-purpose register rA is placed in high-order bits of general-purpose register rD. The low-order 16 bits of general-purpose register rA are copied into the low-order 16 bits of general-purpose register rD.
32-bit Implementation:
rD[31:16]
←
rA[15]
rD[15:0]
←
rA[15:0]
64-bit Implementation:
rD[63:16]
←
rA[15]
rD[15:0]
←
rA[15:0]
Exceptions:
None
Format:
l.exthz rD,rA
Description:
Zero is placed in high-order bits of general-purpose register rD. The low-order 16 bits of general-purpose register rA are copied into the low-order 16 bits of general-purpose register rD.
32-bit Implementation:
rD[31:16]
←
0
rD[15:0]
←
rA[15:0]
64-bit Implementation:
rD[63:16]
←
0
rD[15:0]
←
rA[15:0]
Exceptions:
None
Format:
l.extws rD,rA
Description:
Bit 31 of general-purpose register rA is placed in high-order bits of general-purpose register rD. The low-order 32 bits of general-purpose register rA are copied from low-order 32 bits of general-purpose register rD.
32-bit Implementation:
rD[31:0] ← rA[31:0]
64-bit Implementation:
rD[63:32]
←
rA[31]
rD[31:0]
←
rA[31:0]
Exceptions:
None
Format:
l.extwz rD,rA
Description:
Zero is placed in high-order bits of general-purpose register rD. The low-order 32 bits of general-purpose register rA are copied into the low-order 32 bits of general-purpose register rD.
32-bit Implementation:
rD[31:0] ← rA[31:0]
64-bit Implementation:
rD[63:32]
←
0
rD[31:0]
←
rA[31:0]
Exceptions:
None
Format:
l.ff1 rD,rA,rB
Description:
Position of the lowest order '1' bit is written into general-purpose register rD. Checking for bit '1' starts with bit 0 (LSB), and counting is incremented for every zero bit. If first '1' bit is discovered in LSB, one is written into rD, if first '1' bit is discovered in MSB, 32 (64) is written into rD. If there is no '1' bit, zero is written in rD.
32-bit Implementation:
rD[31:0] ← rA[0] ? 1 : rA[1] ? 2 ... rA[31] ? 32 : 0
64-bit Implementation:
rD[63:0] ← rA[0] ? 1 : rA[1] ? 2 ... rA[63] ? 64 : 0
Exceptions:
None
Format:
l.fl1 rD,rA,rB
Description:
Position of the highest order '1' bit is written into general-purpose register rD. Checking for bit '1' starts with bit 31/63 (MSB), and counting is decremented for every zero bit until the last ‘1’ bit is found nearing the LSB. If highest order '1' bit is discovered in MSB, 32 (64) is written into rD, if highest order '1' bit is discovered in LSB, one is written into rD. If there is no '1' bit, zero is written in rD.
32-bit Implementation:
rD[31:0] ← rA[31] ? 32 : rA[30] ? 31 ... rA[0] ? 1 : 0
64-bit Implementation:
rD[63:0] ← rA[63] ? 64 : rA[62] ? 63 ... rA[0] ? 1 : 0
Exceptions:
None
Format:
l.j N
Description:
The immediate value is shifted left two bits, sign-extended to program counter width, and then added to the address of the jump instruction. The result is the effective address of the jump. The program unconditionally jumps to EA. If CPUCFGR[ND] is not set, the jump occurs with a delay of one instruction.
Note that l.sys should not be placed in the delay slot after a jump.
32-bit Implementation:
PC ← exts(Immediate << 2) + JumpInsnAddr
64-bit Implementation:
PC ← exts(Immediate << 2) + JumpInsnAddr
Exceptions:
TLB
miss
Page
fault
Bus
error
Format:
l.jal N
Description:
The immediate value is shifted left two bits, sign-extended to program counter width, and then added to the address of the jump instruction. The result is the effective address of the jump. The program unconditionally jumps to EA. If CPUCFGR[ND] is not set, the jump occurs with a delay of one instruction. The address of the instruction after the delay slot is placed in the link register r9 (see Register Usage on page 335).
The value of the link register, if read as an operand in the delay slot will be the new value, not the old value. If the link register is written in the delay slot, the value written will replace the value stored by the l.jal instruction.
Note that l.sys should not be placed in the delay slot after a jump.
32-bit Implementation:
PC
←
exts(Immediate << 2) + JumpInsnAddr
LR
←
CPUCFGR[ND] ? JumpInsnAddr + 4 : DelayInsnAddr + 4
64-bit Implementation:
PC
←
exts(Immediate << 2) + JumpInsnAddr
LR
←
CPUCFGR[ND] ? JumpInsnAddr + 4 : DelayInsnAddr + 4
Exceptions:
TLB
miss
Page
fault
Bus
error
Format:
l.jalr rB
Description:
The contents of general-purpose register rB is the effective address of the jump. The program unconditionally jumps to EA. If CPUCFGR[ND] is not set, the jump occurs with a delay of one instruction. The address of the instruction after the delay slot is placed in the link register.
It is not allowed to specify link register r9 (see Register Usage on page 335) as rB. This is because an exception in the delay slot (including external interrupts) may cause l.jalr to be reexecuted.
The value of the link register, if read as an operand in the delay slot will be the new value, not the old value. If the link register is written in the delay slot, the value written will replace the value stored by the l.jalr instruction.
Note that l.sys should not be placed in the delay slot after a jump.
32-bit Implementation:
PC
←
rB
LR
←
CPUCFGR[ND] ? JumpInsnAddr + 4 : DelayInsnAddr + 4
64-bit Implementation:
PC
←
rB
LR
←
CPUCFGR[ND] ? JumpInsnAddr + 4 : DelayInsnAddr + 4
Exceptions:
Alignment
TLB
miss
Page
fault
Bus
error
Format:
l.jr rB
Description:
The contents of general-purpose register rB is the effective address of the jump. The program unconditionally jumps to EA. If CPUCFGR[ND] is not set, the jump occurs with a delay of one instruction.
Note that l.sys should not be placed in the delay slot after a jump.
32-bit Implementation:
PC ← rB
64-bit Implementation:
PC ← rB
Exceptions:
Alignment
TLB
miss
Page
fault
Bus
error
Format:
l.lbs rD,I(rA)
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The byte in memory addressed by EA is loaded into the low-order eight bits of general-purpose register rD. High-order bits of general-purpose register rD are replaced with bit 7 of the loaded value.
32-bit Implementation:
EA
←
exts(Immediate) + rA[31:0]
rD[7:0]
←
(EA)[7:0]
rD[31:8]
←
(EA)[7]
64-bit Implementation:
EA
←
exts(Immediate) + rA[63:0]
rD[7:0]
←
(EA)[7:0]
rD[63:8]
←
(EA)[7]
Exceptions:
TLB
miss
Page
fault
Bus
error
Format:
l.lbz rD,I(rA)
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The byte in memory addressed by EA is loaded into the low-order eight bits of general-purpose register rD. High-order bits of general-purpose register rD are replaced with zero.
32-bit Implementation:
EA
←
exts(Immediate) + rA[31:0]
rD[7:0]
←
(EA)[7:0]
rD[31:8]
←
0
64-bit Implementation:
EA
←
exts(Immediate) + rA[63:0]
rD[7:0]
←
(EA)[7:0]
rD[63:8]
←
0
Exceptions:
TLB
miss
Page
fault
Bus
error
Format:
l.ld rD,I(rA)
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The double word in memory addressed by EA is loaded into general-purpose register rD.
32-bit Implementation:
N/A
64-bit Implementation:
EA
←
exts(Immediate) + rA[63:0]
rD[63:0]
←
(EA)[63:0]
Exceptions:
TLB
miss
Page
fault
Bus
error
Alignment
Format:
l.lhs rD,I(rA)
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The half word in memory addressed by EA is loaded into the low-order 16 bits of general-purpose register rD. High-order bits of general-purpose register rD are replaced with bit 15 of the loaded value.
32-bit Implementation:
EA
←
exts(Immediate) + rA[31:0]
rD[15:0]
←
(EA)[15:0]
rD[31:16]
←
(EA)[15]
64-bit Implementation:
EA
←
exts(Immediate) + rA[63:0]
rD[15:0]
←
(EA)[15:0]
rD[63:16]
←
(EA)[15]
Exceptions:
TLB
miss
Page
fault
Bus
error
Alignment
Format:
l.lhz rD,I(rA)
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The half word in memory addressed by EA is loaded into the low-order 16 bits of general-purpose register rD. High-order bits of general-purpose register rD are replaced with zero.
32-bit Implementation:
EA
←
exts(Immediate) + rA[31:0]
rD[15:0]
←
(EA)[15:0]
rD[31:16]
←
0
64-bit Implementation:
EA
←
exts(Immediate) + rA[63:0]
rD[15:0] ←
(EA)[15:0]
rD[63:16]
←
0
Exceptions:
TLB
miss
Page
fault
Bus
error
Alignment
Format:
l.lwa rD,I(rA)
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The single word in memory addressed by EA is loaded into the low-order 32 bits of general-purpose register rD. High-order bits of general-purpose register rD are replaced with zero.
An atomic reservation is placed on the address formed from EA. In case an MMU is enabled, the physical translation of EA is used.
32-bit Implementation:
EA ←
exts(Immediate) + rA[31:0]
rD[31:0] ←
(EA)[31:0]
atomic_reserve[to_phys(EA)] ← 1
64-bit Implementation:
EA ←
exts(Immediate) + rA[63:0]
rD[31:0] ←
(EA)[31:0]
rD[63:32]
←
0
atomic_reserve[to_phys(EA)] ← 1
Exceptions:
TLB
miss
Page
fault
Bus
error
Alignment
Format:
l.lws rD,I(rA)
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The single word in memory addressed by EA is lloaded into the low-order 32 bits of general-purpose register rD. High-order bits of general-purpose register rD are replaced with bit 31 of the loaded value.
32-bit Implementation:
EA ←
exts(Immediate) + rA[31:0]
rD[31:0] ←
(EA)[31:0]
64-bit Implementation:
EA ←
exts(Immediate) + rA[63:0]
rD[31:0] ←
(EA)[31:0]
rD[63:32]
←
(EA)[31]
Exceptions:
TLB
miss
Page
fault
Bus
error
Alignment
Format:
l.lwz rD,I(rA)
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The single word in memory addressed by EA is loaded into the low-order 32 bits of general-purpose register rD. High-order bits of general-purpose register rD are replaced with zero.
32-bit Implementation:
EA ←
exts(Immediate) + rA[31:0]
rD[31:0] ←
(EA)[31:0]
64-bit Implementation:
EA ←
exts(Immediate) + rA[63:0]
rD[31:0] ←
(EA)[31:0]
rD[63:32]
←
0
Exceptions:
TLB
miss
Page
fault
Bus
error
Alignment
Format:
l.mac rA,rB
Description:
The contents of general-purpose register rA and the contents of general-purpose register rB are multiplied, and the 64 bit result is added to the special-purpose registers MACHI and MACLO. All operands are treated as signed integers.
The instruction will set the overflow flag if signed overflow is detecting during the addition stage.
32-bit Implementation:
MACHI[31:0]MACLO[31:0] ← MACHI[31:0]MACLO[31:0] +
rA[31:0] * rB[31:0]
SR[OV] ← signed overflow during addition stage
64-bit Implementation:
MACHI[31:0]MACLO[31:0]
←
MACHI[31:0]MACLO[31:0] +
rA[63:0] * rB[63:0]
SR[OV] ← signed overflow during addition stage
Exceptions:
Range Exception on signed overflow if SR[OVE] and AECR[OVMACADDE] are set.
Format:
l.maci rA,I
Description:
The immediate value and the contents of general-purpose register rA are multiplied, and the 64 bit result is added to the special-purpose registers MACHI and MACLO. All operands are treated as signed integers.
The instruction will set the overflow flag if signed overflow is detecting during the addition stage.
32-bit Implementation:
MACHI[31:0]MACLO[31:0] ← MACHI[31:0]MACLO[31:0] +
rA[31:0] * exts(Immediate)
SR[OV] ← signed overflow during addition stage
64-bit Implementation:
MACHI[31:0]MACLO[31:0] ← MACHI[31:0]MACLO[31:0] +
rA[63:0] * exts(Immediate)
SR[OV] ← signed overflow during addition stage
Exceptions:
Range Exception on signed overflow if SR[OVE] and AECR[OVMACADDE] are set.
Format:
l.macrc rD
Description:
Once all instructions in MAC pipeline are completed, the contents of MAC is placed into general-purpose register rD and MAC accumulator is cleared.
The MAC pipeline also synchronizes with the instruction pipeline on any access to MACLO or MACHI SPRs, so that l.mfspr can be used to read MACHI before executing l.macrc.
32-bit Implementation:
synchronize-mac
rD[31:0] ←
MACLO[31:0]
MACLO[31:0], MACHI[31:0] ← 0
64-bit Implementation:
synchronize-mac
rD[63:0] ←
MACHI[31:0]MACLO[31:0]
MACLO[31:0], MACHI[31:0] ← 0
Exceptions:
None
Format:
l.macu rA,rB
Description:
The contents of general-purpose register rA and the contents of general-purpose register rB are multiplied, and the 64 bit result is added to the special-purpose registers MACHI and MACLO. All operands are treated as unsigned integers.
The instruction will set the overflow flag if unsigned overflow is detecting during the addition stage.
32-bit Implementation:
MACHI[31:0]MACLO[31:0] ← MACHI[31:0]MACLO[31:0] +
rA[31:0] * rB[31:0]
SR[CY] ← unsigned overflow during addition stage
64-bit Implementation:
MACHI[31:0]MACLO[31:0]
←
MACHI[31:0]MACLO[31:0] +
rA[63:0] * rB[63:0]
SR[CY] ← unsigned overflow during addition stage
Exceptions:
Range Exception on unsigned overflow if SR[OVE] and AECR[CYMACADDE] are set.
Format:
l.mfspr rD,rA,K
Description:
The contents of the special register, defined by contents of general-purpose rA logically ORed with immediate value, are moved into general-purpose register rD.
32-bit Implementation:
rD[31:0] ← spr(rA OR Immediate)
64-bit Implementation:
rD[63:0] ← spr(rA OR Immediate)
Exceptions:
None
Format:
l.movhi rD,K
Description:
The 16-bit immediate value is zero-extended, shifted left by 16 bits, and placed into general-purpose register rD.
32-bit Implementation:
rD[31:0] ← extz(Immediate) << 16
64-bit Implementation:
rD[63:0] ← extz(Immediate) << 16
Exceptions:
None
Format:
l.msb rA,rB
Description:
The contents of general-purpose register rA and the contents of general-purpose register rB are multiplied, and the 64 bit result is subtracted from the special-purpose registers MACHI and MACLO. Result of the subtraction is placed into MACHI and MACLO registers. All operands are treated as signed integers.
The instruction will set the overflow flag if signed overflow is detecting during the subtraction stage.
32-bit Implementation:
MACHI[31:0]MACLO[31:0] ← MACHI[31:0]MACLO[31:0] -
rA[31:0] * rB[31:0]
SR[OV] ← signed overflow during subtraction stage
64-bit Implementation:
MACHI[31:0]MACLO[31:0] ← MACHI[31:0]MACLO[31:0] –
rA[63:0] * rB[63:0]
SR[OV] ← signed overflow during subtraction stage
Exceptions:
Range Exception on signed overflow if SR[OVE] and AECR[OVMACADDE] are set.
Format:
l.msbu rA,rB
Description:
The contents of general-purpose register rA and the contents of general-purpose register rB are multiplied, and the 64 bit result is subtracted from the special-purpose registers MACHI and MACLO. Result of the subtraction is placed into MACHI and MACLO registers. All operands are treated as unsigned integers.
The instruction will set the overflow flag if unsigned overflow is detecting during the subtraction stage.
32-bit Implementation:
MACHI[31:0]MACLO[31:0] ← MACHI[31:0]MACLO[31:0] -
rA[31:0] * rB[31:0]
SR[CY] ← unsigned overflow during subtraction stage
64-bit Implementation:
MACHI[31:0]MACLO[31:0] ← MACHI[31:0]MACLO[31:0] –
rA[63:0] * rB[63:0]
SR[CY] ← unsigned overflow during subtraction stage
Exceptions:
Range Exception on signed overflow if SR[OVE] and AECR[CYMACADDE] are set.
Format:
l.msync
Description:
Execution of the memory synchronization instruction results in completion of all load/store operations before the RISC core continues.
32-bit Implementation:
memory-synchronization
64-bit Implementation:
memory-synchronization
Exceptions:
None
Format:
l.mtspr rA,rB,K
Description:
The contents of general-purpose register rB are moved into the special register defined by contents of general-purpose register rA logically ORed with the immediate value.
32-bit Implementation:
spr(rA OR Immediate) ← rB[31:0]
64-bit Implementation:
spr(rA OR Immediate) ← rB[31:0]
Exceptions:
None
Format:
l.mul rD,rA,rB
Description:
The contents of general-purpose register rA and the contents of general-purpose register rB are multiplied, and the result is truncated to destination register width and placed into general-purpose register rD. Both operands are treated as signed integers.
The instruction will set the overflow flag on signed overflow.
32-bit Implementation:
rD[31:0]
←
rA[31:0] * rB[31:0]
SR[OV]
←
signed overflow
64-bit Implementation:
rD[63:0]
←
rA[63:0] * rB[63:0]
SR[OV]
←
signed overflow
Exceptions:
Range Exception on signed overflow if SR[OVE] and AECR[OVMULE] are set.
Format:
l.muld rA,rB
Description:
The contents of general-purpose register rA and the contents of general-purpose register rB are multiplied, and the result is stored in the MACHI and MACLO registers. Both operands are treated as signed integers.
The instruction will set the overflow flag on signed overflow.
32-bit Implementation:
MACHI[31:0]MACLO[31:0] ← rA[31:0] * rB[31:0]
64-bit Implementation:
MACHI[31:0]MACLO[31:0] ← rA[63:0] * rB[63:0]
SR[OV] ← signed overflow
Exceptions:
Range Exception on signed overflow if SR[OVE] and AECR[OVMULE] are set.
Format:
l.muldu rA,rB
Description:
The contents of general-purpose register rA and the contents of general-purpose register rB are multiplied, and the result is stored in the MACHI and MACLO registers. Both operands are treated as unsigned integers.
The instruction will set the overflow flag on unsigned overflow.
32-bit Implementation:
MACHI[31:0]MACLO[31:0] ← rA[31:0] * rB[31:0]
64-bit Implementation:
MACHI[31:0]MACLO[31:0] ← rA[63:0] * rB[63:0]
SR[CY] ← unsigned overflow
Exceptions:
Range Exception on signed overflow if SR[OVE] and AECR[CYMULE] are set.
Format:
l.muli rD,rA,I
Description:
The immediate value and the contents of general-purpose register rA are multiplied, and the result is truncated to destination register width and placed into general-purpose register rD.
The instruction will set the overflow flag on signed overflow.
32-bit Implementation:
rD[31:0]
←
rA[31:0] * exts(Immediate)
SR[OV]
←
signed overflow
64-bit Implementation:
rD[63:0]
←
rA[63:0] * exts(Immediate)
SR[OV]
←
signed overflow
Exceptions:
Range Exception on signed overflow if SR[OVE] and AECR[OVMULE] are set.
Format:
l.mulu rD,rA,rB
Description:
The contents of general-purpose register rA and the contents of general-purpose register rB are multiplied, and the result is truncated to destination register width and placed into general-purpose register rD. Both operands are treated as unsigned integers.
The instruction will set the carry flag on unsigned overflow.
32-bit Implementation:
rD[31:0]
←
rA[31:0] * rB[31:0]
SR[CY]
←
carry (unsigned overflow)
64-bit Implementation:
rD[63:0]
←
rA[63:0] * rB[63:0]
SR[CY]
←
carry (unsigned overflow)
Exceptions:
Range Exception on unsigned overflow if SR[OVE] and AECR[CYMULE] are set.
Format:
l.nop K
Description:
This instruction does not do anything except that it takes at least one clock cycle to complete. It is often used to fill delay slot gaps. Immediate value can be used for simulation purposes.
32-bit Implementation:
64-bit Implementation:
Exceptions:
None
Format:
l.or rD,rA,rB
Description:
The contents of general-purpose register rA are combined with the contents of general-purpose register rB in a bit-wise logical OR operation. The result is placed into general-purpose register rD.
32-bit Implementation:
rD[31:0] ← rA[31:0] OR rB[31:0]
64-bit Implementation:
rD[63:0] ← rA[63:0] OR rB[63:0]
Exceptions:
None
Format:
l.ori rD,rA,K
Description:
The immediate value is zero-extended and combined with the contents of general-purpose register rA in a bit-wise logical OR operation. The result is placed into general-purpose register rD.
32-bit Implementation:
rD[31:0] ← rA[31:0] OR extz(Immediate)
64-bit Implementation:
rD[63:0] ← rA[63:0] OR extz(Immediate)
Exceptions:
None
Format:
l.psync
Description:
Execution of pipeline synchronization instruction results in completion of all instructions that were fetched before l.psync instruction. Once all instructions are completed, instructions fetched after l.psync are flushed from the pipeline and fetched again.
32-bit Implementation:
pipeline-synchronization
64-bit Implementation:
pipeline-synchronization
Exceptions:
None
Format:
l.rfe
Description:
Execution of this instruction partially restores the state of the processor prior to the exception. This instruction does not have a delay slot.
32-bit Implementation:
PC
←
EPCR
SR
←
ESR
64-bit Implementation:
PC
←
EPCR
SR
←
ESR
Exceptions:
None
Format:
l.ror rD,rA,rB
Description:
General-purpose register rB specifies the number of bit positions; the contents of general-purpose register rA are rotated right. The result is written into general-purpose register rD.
32-bit Implementation:
rD[31-rB[4:0]:0]
←
rA[31:rB[4:0]]
rD[31:32-rB[4:0]]
←
rA[rB[4:0]-1:0]
64-bit Implementation:
rD[63-rB[5:0]:0]
←
rA[63:rB[5:0]]
rD[63:64-rB[5:0]]
←
rA[rB[5:0]-1:0]
Exceptions:
None
Format:
l.rori rD,rA,L
Description:
The 6-bit immediate value specifies the number of bit positions; the contents of general-purpose register rA are rotated right. The result is written into general-purpose register rD. In 32-bit implementations bit 5 of immediate is ignored.
32-bit Implementation:
rD[31-L:0]
←
rA[31:L]
rD[31:32-L]
←
rA[L-1:0]
64-bit Implementation:
rD[63-L:0]
←
rA[63:L]
rD[63:64-L]
←
rA[L-1:0]
Exceptions:
None
Format:
l.sb I(rA),rB
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The low-order 8 bits of general-purpose register rB are stored to memory location addressed by EA.
32-bit Implementation:
EA ←
exts(Immediate) + rA[31:0]
(EA)[7:0]
←
rB[7:0]
64-bit Implementation:
EA ←
exts(Immediate) + rA[63:0]
(EA)[7:0]
←
rB[7:0]
Exceptions:
TLB
miss
Page
fault
Bus
error
Format:
l.sd I(rA),rB
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The double word in general-purpose register rB is stored to memory location addressed by EA.
32-bit Implementation:
N/A
64-bit Implementation:
EA
←
exts(Immediate) + rA[63:0]
(EA)[63:0]
←
rB[63:0]
Exceptions:
TLB
miss
Page
fault
Bus
error
Alignment
Format:
l.sfeq rA,rB
Description:
The contents of general-purpose registers rA and rB are compared. If the contents are equal, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] == rB[31:0]
64-bit Implementation:
SR[F] ← rA[63:0] == rB[63:0]
Exceptions:
None
Format:
l.sfeqi rA,I
Description:
The contents of general-purpose register rA and the sign-extended immediate value are compared. If the two values are equal, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] == exts(Immediate)
64-bit Implementation:
SR[F] ← rA[63:0] == exts(Immediate)
Exceptions:
None
Format:
l.sfges rA,rB
Description:
The contents of general-purpose registers rA and rB are compared as signed integers. If the contents of the first register are greater than or equal to the contents of the second register, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] >= rB[31:0]
64-bit Implementation:
SR[F] ← rA[63:0] >= rB[63:0]
Exceptions:
None
Format:
l.sfgesi rA,I
Description:
The contents of general-purpose register rA and the sign-extended immediate value are compared as signed integers. If the contents of the first register are greater than or equal to the immediate value the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] >= exts(Immediate)
64-bit Implementation:
SR[F] ← rA[63:0] >= exts(Immediate)
Exceptions:
None
Format:
l.sfgeu rA,rB
Description:
The contents of general-purpose registers rA and rB are compared as unsigned integers. If the contents of the first register are greater than or equal to the contents of the second register, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] >= rB[31:0]
64-bit Implementation:
SR[F] ← rA[63:0] >= rB[63:0]
Exceptions:
None
Format:
l.sfgeui rA,I
Description:
The contents of general-purpose register rA and the sign-extended immediate value are compared as unsigned integers. If the contents of the first register are greater than or equal to the immediate value the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] >= exts(Immediate)
64-bit Implementation:
SR[F] ← rA[63:0] >= exts(Immediate)
Exceptions:
None
Format:
l.sfgts rA,rB
Description:
The contents of general-purpose registers rA and rB are compared as signed integers. If the contents of the first register are greater than the contents of the second register, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] > rB[31:0]
64-bit Implementation:
SR[F] ← rA[63:0] > rB[63:0]
Exceptions:
None
Format:
l.sfgtsi rA,I
Description:
The contents of general-purpose register rA and the sign-extended immediate value are compared as signed integers. If the contents of the first register are greater than the immediate value the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] > exts(Immediate)
64-bit Implementation:
SR[F] ← rA[63:0] > exts(Immediate)
Exceptions:
None
Format:
l.sfgtu rA,rB
Description:
The contents of general-purpose registers rA and rB are compared as unsigned integers. If the contents of the first register are greater than the contents of the second register, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] > rB[31:0]
64-bit Implementation:
SR[F] ← rA[63:0] > rB[63:0]
Exceptions:
None
Format:
l.sfgtui rA,I
Description:
The contents of general-purpose register rA and the sign-extended immediate value are compared as unsigned integers. If the contents of the first register are greater than the immediate value the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] > exts(Immediate)
64-bit Implementation:
SR[F] ← rA[63:0] > exts(Immediate)
Exceptions:
None
Format:
l.sfles rA,rB
Description:
The contents of general-purpose registers rA and rB are compared as signed integers. If the contents of the first register are less than or equal to the contents of the second register, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] <= rB[31:0]
64-bit Implementation:
SR[F] ← rA[63:0] <= rB[63:0]
Exceptions:
None
Format:
l.sflesi rA,I
Description:
The contents of general-purpose register rA and the sign-extended immediate value are compared as signed integers. If the contents of the first register are less than or equal to the immediate value the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] <= exts(Immediate)
64-bit Implementation:
SR[F] ← rA[63:0] <= exts(Immediate)
Exceptions:
None
Format:
l.sfleu rA,rB
Description:
The contents of general-purpose registers rA and rB are compared as unsigned integers. If the contents of the first register are less than or equal to the contents of the second register, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] <= rB[31:0]
64-bit Implementation:
SR[F] ← rA[63:0] <= rB[63:0]
Exceptions:
None
Format:
l.sfleui rA,I
Description:
The contents of general-purpose register rA and the sign-extended immediate value are compared as unsigned integers. If the contents of the first register are less than or equal to the immediate value the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] <= exts(Immediate)
64-bit Implementation:
SR[F] ← rA[63:0] <= exts(Immediate)
Exceptions:
None
Format:
l.sflts rA,rB
Description:
The contents of general-purpose registers rA and rB are compared as signed integers. If the contents of the first register are less than the contents of the second register, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] < rB[31:0]
64-bit Implementation:
SR[F] ← rA[63:0] < rB[63:0]
Exceptions:
None
Format:
l.sfltsi rA,I
Description:
The contents of general-purpose register rA and the sign-extended immediate value are compared as signed integers. If the contents of the first register are less than the immediate value the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] < exts(Immediate)
64-bit Implementation:
SR[F] ← rA[63:0] < exts(Immediate)
Exceptions:
None
Format:
l.sfltu rA,rB
Description:
The contents of general-purpose registers rA and rB are compared as unsigned integers. If the contents of the first register are less than the contents of the second register, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] < rB[31:0]
64-bit Implementation:
SR[F] ← rA[63:0] < rB[63:0]
Exceptions:
None
Format:
l.sfltui rA,I
Description:
The contents of general-purpose register rA and the sign-extended immediate value are compared as unsigned integers. If the contents of the first register are less than the immediate value the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] < exts(Immediate)
64-bit Implementation:
SR[F] ← rA[63:0] < exts(Immediate)
Exceptions:
None
Format:
l.sfne rA,rB
Description:
The contents of general-purpose registers rA and rB are compared. If the contents are not equal, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] != rB[31:0]
64-bit Implementation:
SR[F] ← rA[63:0] != rB[63:0]
Exceptions:
None
Format:
l.sfnei rA,I
Description:
The contents of general-purpose register rA and the sign-extended immediate value are compared. If the two values are not equal, the compare flag is set; otherwise the compare flag is cleared.
32-bit Implementation:
SR[F] ← rA[31:0] != exts(Immediate)
64-bit Implementation:
SR[F] ← rA[63:0] != exts(Immediate)
Exceptions:
None
Format:
l.sh I(rA),rB
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The low-order 16 bits of general-purpose register rB are stored to memory location addressed by EA.
32-bit Implementation:
EA
←
exts(Immediate) + rA[31:0]
(EA)[15:0]
←
rB[15:0]
64-bit Implementation:
EA
←
exts(Immediate) + rA[63:0]
(EA)[15:0]
←
rB[15:0]
Exceptions:
TLB
miss
Page
fault
Bus
error
Alignment
Format:
l.sll rD,rA,rB
Description:
General-purpose register rB specifies the number of bit positions; the contents of general-purpose register rA are shifted left, inserting zeros into the low-order bits. The result is written into general-purpose rD. In 32-bit implementations bit 5 of rB is ignored.
32-bit Implementation:
rD[31:rB[4:0]]
←
rA[31-rB[4:0]:0]
rD[rB[4:0]-1:0]
←
0
64-bit Implementation:
rD[63:rB[5:0]]
←
rA[63-rB[5:0]:0]
rD[rB[5:0]-1:0]
←
0
Exceptions:
None
Format:
l.slli rD,rA,L
Description:
The immediate value specifies the number of bit positions; the contents of general-purpose register rA are shifted left, inserting zeros into the low-order bits. The result is written into general-purpose register rD. In 32-bit implementations bit 5 of immediate is ignored.
32-bit Implementation:
rD[31:L]
←
rA[31-L:0]
rD[L-1:0]
←
0
64-bit Implementation:
rD[63:L]
←
rA[63-L:0]
rD[L-1:0]
←
0
Exceptions:
None
Format:
l.sra rD,rA,rB
Description:
General-purpose register rB specifies the number of bit positions; the contents of general-purpose register rA are shifted right, sign-extending the high-order bits. The result is written into general-purpose register rD. In 32-bit implementations bit 5 of rB is ignored.
32-bit Implementation:
rD[31-rB[4:0]:0]
←
rA[31:rB[4:0]]
rD[31:32-rB[4:0]]
←
rA[31]
64-bit Implementation:
rD[63-rB[5:0]:0]
←
rA[63:rB[5:0]]
rD[63:64-rB[5:0]]
←
rA[63]
Exceptions:
None
Format:
l.srai rD,rA,L
Description:
The 6-bit immediate value specifies the number of bit positions; the contents of general-purpose register rA are shifted right, sign-extending the high-order bits. The result is written into general-purpose register rD. In 32-bit implementations bit 5 of immediate is ignored.
32-bit Implementation:
rD[31-L:0]
←
rA[31:L]
rD[31:32-L]
←
rA[31]
64-bit Implementation:
rD[63-L:0]
←
rA[63:L]
rD[63:64-L]
←
rA[63]
Exceptions:
None
Format:
l.srl rD,rA,rB
Description:
General-purpose register rB specifies the number of bit positions; the contents of general-purpose register rA are shifted right, inserting zeros into the high-order bits. The result is written into general-purpose register rD. In 32-bit implementations bit 5 of rB is ignored.
32-bit Implementation:
rD[31-rB[4:0]:0]
←
rA[31:rB[4:0]]
rD[31:32-rB[4:0]]
←
0
64-bit Implementation:
rD[63-rB[5:0]:0]
←
rA[63:rB[5:0]]
rD[63:64-rB[5:0]]
←
0
Exceptions:
None
Format:
l.srli rD,rA,L
Description:
The 6-bit immediate value specifies the number of bit positions; the contents of general-purpose register rA are shifted right, inserting zeros into the high-order bits. The result is written into general-purpose register rD. In 32-bit implementations bit 5 of immediate is ignored.
32-bit Implementation:
rD[31-L:0]
←
rA[31:L]
rD[31:32-L]
←
0
64-bit Implementation:
rD[63-L:0]
←
rA[63:L]
rD[63:64-L]
←
0
Exceptions:
None
Format:
l.sub rD,rA,rB
Description:
The contents of general-purpose register rB are subtracted from the contents of general-purpose register rA to form the result. The result is placed into general-purpose register rD.
The instruction will set the carry flag on unsigned overflow, and the overflow flag on signed overflow.
32-bit Implementation:
rD[31:0]
←
rA[31:0] - rB[31:0]
SR[CY]
←
carry (unsigned overflow)
SR[OV]
←
signed overflow
64-bit Implementation:
rD[63:0]
←
rA[63:0] - rB[63:0]
SR[CY]
←
carry (unsigned overflow)
SR[OV]
←
signed overflow
Exceptions:
Range Exception on overflow if SR[OVE] and AECR[OVADDE] are set.
Range Exception on carry if SR[OVE] and AECR[CYADDE] are set.
Format:
l.sw I(rA),rB
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The low-order 32 bits of general-purpose register rB are stored to memory location addressed by EA.
32-bit Implementation:
EA
←
exts(Immediate) + rA[31:0]
(EA)[31:0]
←
rB[31:0]
64-bit Implementation:
EA
←
exts(Immediate) + rA[63:0]
(EA)[31:0]
←
rB[31:0]
Exceptions:
TLB
miss
Page
fault
Bus
error
Alignment
Format:
l.swa I(rA),rB
Description:
The offset is sign-extended and added to the contents of general-purpose register rA. The sum represents an effective address. The low-order 32 bits of general-purpose register rB are conditionally stored to memory location addressed by EA. The 'atomic' condition relies on that an atomic reserve to EA is still intact. When the MMU is enabled, the physical translation of EA is used to do the address comparison.
32-bit Implementation:
EA ← exts(Immediate) + rA[31:0]
if (atomic) (EA)[31:0] ← rB[31:0]
SR[F] ← atomic
64-bit Implementation:
EA
←
exts(Immediate) + rA[63:0]
if
(atomic) (EA)[31:0]
←
rB[31:0]
SR[F]