The revision list can be viewed directly by
clicking the title page.
The revision list summarizes the locations of
revisions and additions. Details should always
be checked by referring to the relevant text.
32
SH-4A
Software Manual
Renesas 32-Bit RISC Microcomputer
SuperH™ RISC engine Family
Rev.1.50
Revision Date: Oct. 29, 2004
Page 2
Rev. 1.50, 10/04, page ii of xx
Page 3
Keep safety first in your circuit designs!
1. Renesas Technology Corp. puts the maximum effort into making semiconductor products better and
more reliable, but there is always the possibility that trouble may occur with them. Trouble with
semiconductors may lead to personal injury, fire or property damage.
Remember to give due consideration to safety when making your circuit designs, with appropriate
measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of nonflammable material or
(iii) prevention against any malfunction or mishap.
Notes regarding these materials
1. These materials are intended as a reference to assist our customers in the selection of the Renesas
Technology Corp. product best suited to the customer's application; they do not convey any license
under any intellectual property rights, or any other rights, belonging to Renesas Technology Corp. or
a third party.
2. Renesas Technology Corp. assumes no responsibility for any damage, or infringement of any thirdparty's rights, originating in the use of any product data, diagrams, charts, programs, algorithms, or
circuit application examples contained in these materials.
3. All information contained in these materials, including product data, diagrams, charts, programs and
algorithms represents information on products at the time of publication of these materials, and are
subject to change by Renesas Technology Corp. without notice due to product improvements or
other reasons. It is therefore recommended that customers contact Renesas Technology Corp. or
an authorized Renesas Technology Corp. product distributor for the latest product information
before purchasing a product listed herein.
The information described here may contain technical inaccuracies or typographical errors.
Renesas Technology Corp. assumes no responsibility for any damage, liability, or other loss rising
from these inaccuracies or errors.
Please also pay attention to information published by Renesas Technology Corp. by various means,
including the Renesas Technology Corp. Semiconductor home page (http://www.renesas.com).
4. When using any or all of the information contained in these materials, including product data,
diagrams, charts, programs, and algorithms, please be sure to evaluate all information as a total
system before making a final decision on the applicability of the information and products. Renesas
Technology Corp. assumes no responsibility for any damage, liability or other loss resulting from the
information contained herein.
5. Renesas Technology Corp. semiconductors are not designed or manufactured for use in a device or
system that is used under circumstances in which human life is potentially at stake. Please contact
Renesas Technology Corp. or an authorized Renesas Technology Corp. product distributor when
considering the use of a product contained herein for any specific purposes, such as apparatus or
systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater use.
6. The prior written approval of Renesas Technology Corp. is necessary to reprint or reproduce in
whole or in part these materials.
7. If these products or technologies are subject to the Japanese export control restrictions, they must
be exported under a license from the Japanese government and cannot be imported into a country
other than the approved destination.
Any diversion or reexport contrary to the export control laws and regulations of Japan and/or the
country of destination is prohibited.
8. Please contact Renesas Technology Corp. for further details on these materials or the products
contained therein.
Rev. 1.50, 10/04, page iii of xx
Page 4
General Precautions on Handling of Product
1. Treatment of NC Pins
Note: Do not connect anything to the NC pins.
The NC (not connected) pins are either not connected to any of the internal circuitry or are
they are used as test pins or to reduce noise. If something is connected to the NC pins, the
operation of the LSI is not guaranteed.
2. Treatment of Unused Input Pins
Note: Fix all unused input pins to high or low level.
Generally, the input pins of CMOS products are high-impedance input pins. If unused pins
are in their open states, intermediate levels are induced by noise in the vicinity, a passthrough current flows internally, and a malfunction may occur.
3. Processing before Initialization
Note: When power is first supplied, the product’s state is undefined.
The states of internal circuits are undefined until full power is supplied throughout the
chip and a low level is input on the reset pin. During the period where the states are
undefined, the register settings and the output state of each pin are also undefined. Design
your system so that it does not malfunction because of processing while it is in this
undefined state. For those products which have a reset function, reset the LSI immediately
after the power supply has been turned on.
4. Prohibition of Access to Undefined or Reserved Addresses
Note: Access to undefined or reserved addresses is prohibited.
The undefined or reserved addresses may be used to expand functions, or test registers
may have been be allocated to these addresses. Do not access these registers; the system’s
operation is not guaranteed if they are accessed.
5. Reading from/Writing to Reserved Bit of Each Register
Note: Treat the reserved bit of register used in each module as follows except in cases where the
specifications for values which are read from or written to the bit are provided in the
description.
The bit is always read as 0. The write value should be 0 or one, which has been read
immediately before writing.
Writing the value, which has been read immediately before writing has the advantage of
preventing the bit from being affected on its extended function when the function is
assigned.
Rev. 1.50, 10/04, page iv of xx
Page 5
Configuration of This Manual
This manual comprises the following items:
1. General Precautions on Handling of Product
2. Configuration of This Manual
3. Preface
4. Contents
5. Overview
6. Description of Functional Modules
• CPU and System-Control Modules
• On-Chip Peripheral Modules
The configuration of the functional description of each module differs according to the
module. However, the generic style includes the following items:
i) Feature
ii) Input/Output Pin
iii) Register Description
iv) Operation
v) Usage Note
When designing an application system that includes this LSI, take notes into account. Each
section includes notes in relation to the descriptions given, and usage notes are given, as required,
as the final part of each section.
7. List of Registers
8. Appendix
9. Index
Rev. 1.50, 10/04, page v of xx
Page 6
Preface
The SH-4A is a RISC (Reduced Instruction Set Computer) microcomputer which includes a
Renesas Technology-original RISC CPU as its core.
Target Users: This manual was written for users who will be using the SH-4A in the design of
application systems. Users of this manual are expected to understand the
fundamentals of electrical circuits, logical circuits, microcomputers, and assembly/C
languages programming.
Objective: This manual was written to understand the instructions of the SH4A. For the
hardware functions, refer to corresponding hardware manual.
Notes on reading this manual:
• In order to understand the overall functions of the chip
Read the manual according to the contents. This manual can be roughly categorized into parts
on the CPU, system control functions, and instructions.
• In order to understand the instructions
The instruction format and basic operation are explained in section 3, Instruction Set. For
details on each instruction operation, read section 10, Instruction Descriptions.
Rules: Register name: The following notation is used for cases when the same or a
similar function, e.g. serial communication, is implemented
on more than one channel:
XXX_N (XXX is the register name and N is the channel
number)
Bit order: The MSB is on the left and the LSB is on the right.
Number notation: Binary is B'xxxx, hexadecimal is H'xxxx, decimal is xxxx.
Signal notation: An overbar is added to a low-active signal: xxxx
Related Manuals: The latest versions of all related manuals are available from our web site.
Please ensure you have the latest versions of all documents you require.
http://www.renesas.com/
The SH-4A is a 32-bit RISC (reduced instruction set computer) microprocessor that is upward
compatible with the SH-1, SH-2, SH-3, and SH-4 microcomputers at instruction set code level. Its
16-bit fixed-length instruction set enables program code size to be reduced by almost 50%
compared with 32-bit instructions. The features of the SH-4A are listed in table 1.1.
Table 1.1 Features
Item Features
CPU
• Renesas Technology original architecture
• 32-bit internal data bus
• General-register files:
Sixteen 32-bit general registers (eight 32-bit shadow registers)
Seven 32-bit control registers
Four 32-bit system registers
• RISC-type instruction set (upward compatible with the SH-1, SH-2, SH-3,
and SH-4 microcomputers)
Instruction length: 16-bit fixed length for improved code efficiency
Load/store architecture
Delayed branch instructions
Instructions executed with conditions
Instruction set based on the C language
• Super scalar which executes two instructions simultaneously including the
FPU
• Instruction execution time: Two instructions per cycle (max)
• Virtual address space: 4 Gbytes
• Space identifier ASID: 8 bits, 256 virtual address spaces
• On-chip multiplier
• Seven-stage pipeline
Rev. 1.50, 10/04, page 1 of 448
Page 22
Item Features
Floatingpoint unit
(FPU)
Memory
management
unit (MMU)
• On-chip floating-point coprocessor
• Supports single-precision (32 bits) and double-precision (64 bits)
• Supports IEEE754-compliant data types and exceptions
• Two rounding modes: Round to Nearest and Round to Zero
• Handling of denormalized numbers: Truncation to zero or interrupt
• 64-entry full associative TLB for instructions and operands
• Supports software selection of replacement method and random-counter
replacement algorithms
• Contents of TLB are directly accessible through address mapping
Rev. 1.50, 10/04, page 2 of 448
Page 23
Item Features
Cache memory
L memory
• Instruction cache (IC)
4-way set associative
32-byte block length
• Operand cache (OC)
4-way set associative
32-byte block length
Selectable write method (copy-back or write-through)
• Storage queue (32 bytes × 2 entries)
Note: For the size of instruction cash and operand cash, see corresponding
hardware manual on the product.
• Two independent read/write ports
8-/16-/32-/64-bit access from the CPU
8-/16-/32-/64-bit and 16-/32-byte access from the external devices
Note: For the size of L memory, see the hardware manual of the target product.
Rev. 1.50, 10/04, page 3 of 448
Page 24
1.2 Changes from SH-4 to SH-4A
Table 1.2 summarizes the changes from SH-4 to SH-4A based on the sections and sub-sections in
this manual.
Table 1.2 Changes from SH-4 to SH-4A
Section No. and
Name
1. Overview Modified entirely
2. Programming
Model
3. Instruction Set 3.3 Instruction Set
4. Pipelining
5. Exception Handling
6. FPU
Subsection
2.2 Register
4.1 Pipelines The number of stages in the pipeline is
4.2 Parallel-
4.3 Execution Cycles The number of execution cycles is
6.3.2 Floating-Point
6.5 Floating-Point
Sub-section
Name Changes
(Detailed differences are described in the
following sections).
The operations in SZ=1 and PR=1 are
Descriptions
Executability
Status/Control
Register (FPSCR)
Exceptions
added to the floating point status/control
register (FPSCR).
9 instructions are added as CPU
instructions.
3 instructions are added as FPU
instructions.
changed from five to seven.
9 instructions are added as CPU
instructions.
3 instructions are added as FPU
instructions.
Instruction group and parallel execution
combinations are modified.
modified.
Operations in SZ = 1 and PR = 1 and each
endian are added
Specification of FPU exception detection
condition with FPU exception enabled is
changed.
Rev. 1.50, 10/04, page 4 of 448
Page 25
Section No. and
Name
7. Memory
Management Unit
7.7 32-Bit Address
Subsection
7.1.1 Address Spaces
7.2 Register
7.2.6 Physical Address
7.2.7 Instruction Re-
7.3 TLB Functions Space attribute bits (SA [2:0]) and timing
7.4.5 Avoiding Synonym
7.5.1,
7.5.4
7.6 Memory-Mapped
7.6.3 UTLB Address
7.6.4 UTLB Data Array Memory allocated addresses are changed
Sub-section
Name Changes
Area P4 configuration is modified.
On-chip RAM space is deleted.
The page table entry assist register (PTEA)
Descriptions
Space Control
Register (PASCR)
Fetch Inhibit
Control Register
(IRMCR)
Problems
Instruction TLB
Multiple Hit
Exception and
Data TLB Multiple
Hit Exception
TLB Configuration
Array
Extended Mode
is deleted.
A physical address space control register is
added.
Newly added
Newly added.
control bit (TC) are deleted from the TLB.
The corresponding bits are modified
according to the cache size change and the
index mode deletion.
Multiple hits during the UTLB search
caused by ITLB mishandling are changed
to be handled as a TLB multiple hit
instruction exception.
Data array 2 in the ITLB and UTLB is
deleted.
Associative writes to the UTLB address
array are changed to not generate data
TLB multiple hit exceptions.
Memory allocated addresses are changed
from H'F6000000–H'F6FFFFFF to
H'F6000000–H'F60FFFFF.
from H'F7000000–H'F77FFFFF to
H'F7000000–H'F70FFFFF.
Newly added.
Rev. 1.50, 10/04, page 5 of 448
Page 26
Section No. and
Name
8. Caches
8.8 Notes on Using
9. L Memory Newly added.
10. Instruction
Descriptions
Subsection
8.1 Features
8.2 Register
8.2.1 Cache Control
8.2.4 On-Chip Memory
8.3 Operand Cache
8.3.6 OC Two-Way
8.4 Instruction Cache
8.4.3 IC Two-Way Mode Newly added.
8.5.1 Coherency
8.6 Memory-Mapped
Sub-section
Name Changes
Instruction cache capacity is changed to 32
Kbytes.
The caching method is changed to a 4-way
set-associative method.
An on-chip memory control register is
Descriptions
Register (CCR)
Control Register
(RAMCR)
Operation
Mode
Operation
between Cache
and External
Memory
Cache
Configuration
32-Bit Address
Extended Mode
added.
Modified.
(Descriptions in CCR are modified.)
Newly added.
RAM mode and OC index mode are
deleted.
Newly added.
IC index mode is deleted.
The ICBI, PREFI, and SYNCO instructions
are added.
The entry bits and the way bits are modified
according to the size modification and
changed into 4-way set associative cache.
Newly added.
9 instructions are added as CPU
instructions.
3 instructions are added as FPU
instructions.
Rev. 1.50, 10/04, page 6 of 448
Page 27
Section 2 Programming Model
The programming model of the SH-4A is explained in this section. The SH-4A has registers and
data formats as shown below.
2.1 Data Formats
The data formats supported in the SH-4A are shown in figure 2.1.
0
7
Byte (8 bits)
Word (16 bits)
Longword (32 bits)
Single-precision floating-point (32 bits)
Double-precision floating-point (64 bits)
[Legend]
s
:Sign field
e
:Exponent field
f
:Fraction field
6251
se
Figure 2.1 Data Formats
15
31
sef
f
0
0
031 3022
063
Rev. 1.50, 10/04, page 7 of 448
Page 28
2.2 Register Descriptions
2.2.1 Privileged Mode and Banks
Processing Modes: This LSI has two processing modes, user mode and privileged mode. This
LSI normally operates in user mode, and switches to privileged mode when an exception occurs or
an interrupt is accepted. There are four kinds of registers—general registers, system registers,
control registers, and floating-point registers—and the registers that can be accessed differ in the
two processing modes.
General Registers: There are 16 general registers, designated R0 to R15. General registers R0 to
R7 are banked registers which are switched by a processing mode change.
• Privileged mode
In privileged mode, the register bank bit (RB) in the status register (SR) defines which banked
register set is accessed as general registers, and which set is accessed only through the load
control register (LDC) and store control register (STC) instructions.
When the RB bit is 1 (that is, when bank 1 is selected), the 16 registers comprising bank 1
general registers R0_BANK1 to R7_BANK1 and non-banked general registers R8 to R15 can
be accessed as general registers R0 to R15. In this case, the eight registers comprising bank 0
general registers R0_BANK0 to R7_BANK0 are accessed by the LDC/STC instructions.
When the RB bit is 0 (that is, when bank 0 is selected), the 16 registers comprising bank 0
general registers R0_BANK0 to R7_BANK0 and non-banked general registers R8 to R15 can
be accessed as general registers R0 to R15. In this case, the eight registers comprising bank 1
general registers R0_BANK1 to R7_BANK1 are accessed by the LDC/STC instructions.
• User mode
In user mode, the 16 registers comprising bank 0 general registers R0_BANK0 to R7_BANK0
and non-banked general registers R8 to R15 can be accessed as general registers R0 to R15.
The eight registers comprising bank 1 general registers R0_BANK1 to R7_BANK1 cannot be
accessed.
Control Registers: Control registers comprise the global base register (GBR) and status register
(SR), which can be accessed in both processing modes, and the saved status register (SSR), saved
program counter (SPC), vector base register (VBR), saved general register 15 (SGR), and debug
base register (DBR), which can only be accessed in privileged mode. Some bits of the status
register (such as the RB bit) can only be accessed in privileged mode.
System Registers: System registers comprise the multiply-and-accumulate registers
(MACH/MACL), the procedure register (PR), and the program counter (PC). Access to these
registers does not depend on the processing mode.
Rev. 1.50, 10/04, page 8 of 448
Page 29
Floating-Point Registers and System Regi sters Rela ted t o FPU : There are thirty-two floating-
point registers, FR0–FR15 and XF0–XF15. FR0–FR15 and XF0–XF15 can be assigned to either
of two banks (FPR0_BANK0–FPR15_BANK0 or FPR0_BANK1–FPR15_BANK1).
FR0–FR15 can be used as the eight registers DR0/2/4/6/8/10/12/14 (double-precision floatingpoint registers, or pair registers) or the four registers FV0/4/8/12 (register vectors), while XF0–
XF15 can be used as the eight registers XD0/2/4/6/8/10/12/14 (register pairs) or register matrix
XMTRX.
System registers related to the FPU comprise the floating-point communication register (FPUL)
and the floating-point status/control register (FPSCR). These registers are used for communication
between the FPU and the CPU, and the exception handling setting.
Register values after a reset are shown in table 2.1.
Table 2.1 Initial Register Values
Type RegistersInitial Value*
General registers R0_BANK0 to R7_BANK0,
R0_BANK1 to R7_BANK1,
R8 to R15
Control registers
SR MD bit = 1, RB bit = 1, BL bit = 1, FD bit = 0,
3.
Accessed as general registers when the RB bit is set to 1 in SR. Accessed only by
LDC/STC instructions when the RB bit is cleared to 0.
Banked registers
4.
Accessed as general registers when the RB bit is cleared to 0 in SR. Accessed only
by LDC/STC instructions when the RB bit is set to 1.
Figure 2.2 CPU Register Configuration in Each Processing M ode
GBR
MACH
MACL
PR
VBR
PC
SPC
SGR
DBR
3
3
3
3
3
3
3
3
Rev. 1.50, 10/04, page 10 of 448
Page 31
2.2.2 General Registers
Figure 2.3 shows the relationship between the processing modes and general registers. The SH-4A
has twenty-four 32-bit general registers (R0_BANK0 to R7_BANK0, R0_BANK1 to
R7_BANK1, and R8 to R15). However, only 16 of these can be accessed as general registers R0
to R15 in one processing mode. The SH-4A has two processing modes, user mode and privileged
mode.
• R0_BANK0 to R7_BANK0
Allocated to R0 to R7 in user mode (SR.MD = 0)
Allocated to R0 to R7 when SR.RB = 0 in privileged mode (SR.MD = 1).
• R0_BANK1 to R7_BANK1
Cannot be accessed in user mode.
Allocated to R0 to R7 when SR.RB = 1 in privileged mode.
Note on Programming: As the user's R0 to R7 are assigned to R0_BANK0 to R7_BANK0, and
after an exception or interrupt R0 to R7 are assigned to R0_BANK1 to
R7_BANK1, it is not necessary for the interrupt handler to save and
restore the user's R0 to R7 (R0_BANK0 to R7_BANK0).
Rev. 1.50, 10/04, page 11 of 448
Page 32
2.2.3 Floating-Point Registers
Figure 2.4 shows the floating-point register configuration. There are thirty-two 32-bit floatingpoint registers, FPR0_BANK0 to FPR15_BANK0, AND FPR0_BANK1 to FPR15_BANK1,
comprising two banks. These registers are referenced as FR0 to FR15, DR0/2/4/6/8/10/12/14,
FV0/4/8/12, XF0 to XF15, XD0/2/4/6/8/10/12/14, or XMTRX. Reference names of each register
are defined depending on the state of the FR bit in FPSCR (see figure 2.4).
When FPSCR.FR = 0, FR0 to FR15 are assigned to FPR0_BANK0 to FPR15_BANK0;
when FPSCR.FR = 1, FR0 to FR15 are assigned to FPR0_BANK1 to FPR15_BANK1.
3. Double-precision floating-point registers or single-precision floating-point registers, DRi (8
registers): A DR register comprises two FR registers.
29 RB 1 R/W Privileged Mode General Register Bank Specification
28 BL 1 R/W Exception/Interrupt Block Bit
27 to 16 — All 0 R Reserved
0111000000000000
R/W:
RR/WR/WR/WRRRRRRRRRRRR
BIt:
151413121110987654321
FDMQIMASKST
0000000011110000
R/W:
R/WRRRRRR/W R/W R/W R/W R/W R/WRRR/W R/W
Initial
Value R/W Description
For details on reading/writing this bit, see General
Precautions on Handling of Product.
Selects the processing mode.
0: User mode (Some instructions cannot be executed
and some resources cannot be accessed.)
1: Privileged mode
This bit is set to 1 by an exception or interrupt.
Bit
0: R0_BANK0 to R7_BANK0 are accessed as general
registers R0 to R7 and R0_BANK1 to R7_BANK1 can
be accessed using LDC/STC instructions
1: R0_BANK1 to R7_BANK1 are accessed as general
registers R0 to R7 and R0_BANK0–R7_BANK0 can
be accessed using LDC/STC instructions
This bit is set to 1 by an exception or interrupt.
This bit is set to 1 by a reset, an exception, or an
interrupt. While this bit is set to 1, an interrupt request is
masked. In this case, this processor enters the reset
state when a general exception other than a user break
occurs.
For details on reading/writing this bit, see General
Precautions on Handling of Product.
0
Rev. 1.50, 10/04, page 14 of 448
Page 35
Initial
Bit Bit Name
15 FD 0 R/W FPU Disable Bit
14 to 10 — All 0 R Reserved
9 M 0 R/W M Bit
8 Q 0 R/W Q Bit
7 to 4 IMASK All 1 R/W Interrupt Mask Level Bits
3, 2 — All 0 R Reserved
1 S 0 R/W S Bit
0 T 0 R/W T Bit
Value R/W Description
When this bit is set to 1 and an FPU instruction is not in
a delay slot, a general FPU disable exception occurs.
When this bit is set to 1 and an FPU instruction is in a
delay slot, a slot FPU disable exception occurs. (FPU
instructions: H'F*** instructions and LDS (.L)/STS(.L)
instructions using FPUL/FPSCR)
For details on reading/writing this bit, see General
Precautions on Handling of Product.
Used by the DIV0S, DIV0U, and DIV1 instructions.
Used by the DIV0S, DIV0U, and DIV1 instructions.
An interrupt whose priority is equal to or less than the
value of the IMASK bits is masked. It can be chosen by
CPU operation mode register (CPUOPM) whether the
level of IMASK is changed to accept an interrupt or not
when an interrupt is occurred. For details, see Appendix
A, CPU Operation Mode Register (CPUOPM).
For details on reading/writing this bit, see General
Precautions on Handling of Product.
Used by the MAC instruction.
Indicates true/false condition, carry/borrow, or
overflow/underflow.
For details, see section 3, Instruction Set.
Saved Status Register (SSR) (32 bits, Privileged Mode, Initial Value = Undefined): The
contents of SR are saved to SSR in the event of an exception or interrupt.
Saved Program Counter (SPC) (32 bits, Privileged Mode, Initial Value = Undefined): The
address of an instruction at which an interrupt or exception occurs is saved to SPC.
Global Base Register (GBR) (32 bits, Initial Value = Undefined): GBR is referenced as the
base address of addressing @(disp,GBR) and @(R0,GBR).
Rev. 1.50, 10/04, page 15 of 448
Page 36
Vector Base Register (VBR) (32 bits, Privileged Mode, Initial Value = H'000 000 00): VBR is
referenced as the branch destination base address in the event of an exception or interrupt. For
details, see section 5, Exception Handling.
Saved General Register 15 (SGR) (32 bits, Privileged Mode, Initial Value = Undefined): The
contents of R15 are saved to SGR in the event of an exception or interrupt.
Debug Base Register (DBR) (32 bits, Privileged Mode, Initial Value = Undefined): When the
user break debugging function is enabled (CBCR.UBDE = 1), DBR is referenced as the branch
destination address of the user break handler instead of VBR.
2.2.5 System Registers
Multiply-and-Accumulate Registers (MACH and MACL) (32 bits, Initial Value =
Undefined): MACH and MACL are used for the added value in a MAC instruction, and to store
the operation result of a MAC or MUL instruction.
Procedure Register (PR) (32 bits, Initial Value = Undefined): The return address is stored in
PR in a subroutine call using a BSR, BSRF, or JSR instruction. PR is referenced by the subroutine
return instruction (RTS).
Program Counter (PC) (32 bits, Initial Value = H'A0000000): PC indicates the address of the
For details on reading/writing this bit, see General
Precautions on Handling of Product.
21 FR 0 R/W Floating-Point Register Bank
0: FPR0_BANK0 to FPR15_BANK0 are assigned to
FR0 to FR15 and FPR0_BANK1 to FPR15_BANK1
are assigned to XF0 to XF15
1: FPR0_BANK0 to FPR15_BANK0 are assigned to
XF0 to XF15 and FPR0_BANK1 to FPR15_BANK1
are assigned to FR0 to FR15
20 SZ 0 R/W Transfer Size Mode
0: Data size of FMOV instruction is 32-bits
1: Data size of FMOV instruction is a 32-bit register
pair (64 bits)
For relationship between the SZ bit, PR bit, and endian,
see figure 2.5.
19 PR 0 R/W Precision Mode
0: Floating-point instructions are executed as
single-precision operations
1: Floating-point instructions are executed as
double-precision operations (graphics support
instructions are undefined)
For relationship between the SZ bit, PR bit, and endian,
see figure 2.5
18 DN 1 R/W Denormalization Mode
0: Denormalized number is treated as such
1: Denormalized number is treated as zero
FRSZPRDN
Cause
R/W
0
FlagRM
Rev. 1.50, 10/04, page 17 of 448
Page 38
Initial
Bit Bit Name
17 to 12 Cause All 0 R/W
11 to 7 Enable (EN) All 0 R/W
6 to 2 Flag All 0 R/W
Value R/W Description
FPU Exception Cause Field
FPU Exception Enable Field
FPU Exception Flag Field
Each time an FPU operation instruction is executed, the
FPU exception cause field is cleared to 0. When an
FPU exception occurs, the bits corresponding to FPU
exception cause field and flag field are set to 1. The
FPU exception flag field remains set to 1 until it is
cleared to 0 by software.
For bit allocations of each field, see table 2.2.
1, 0 RM 01 R/W Rounding Mode
These bits select the rounding mode.
00: Round to Nearest
01: Round to Zero
10: Reserved
11: Reserved
<Big endian>
630
Floating-point register
DR (2i)
630
FR (2i)FR (2i+1)
Memory area
<Little endian>
Floating-point register
Memory area
63 32 31 0
630630
630
FR (2i)FR (2i+1)
63 32
Notes: 1. In the case of SZ = 0 and PR = 0, DR register can not be used.
2. The bit-location of DR register is used for double precision format when PR = 1.
(In the case of (2), it is used when PR is changed from 0 to 1.)
Figure 2.5 Relationship between SZ bit and Endian
Rev. 1.50, 10/04, page 18 of 448
8n+4 8n+78n8n+3
DR (2i)
4n4m4n+34m+3
(1) SZ = 0(2) SZ = 1, PR = 0
1, *2
*
31 0
DR (2i)
630
FR (2i+1)FR (2i)
63 32 31 0
630
2
*
630
63 32
8n+48n+78n+38n
DR (2i)
FR (2i+1)FR (2i)
31 0
8n8n+38n+78n+4
(3) SZ = 1, PR = 1
Page 39
Table 2.2 Bit Allocation for FPU Exception Handling
Field Name
Cause FPU exception
cause field
Enable FPU exception
enable field
Flag FPU exception flag
field
FPU
Error (E)
Bit 17 Bit 16 Bit 15 Bit 14 Bit 13 Bit 12
None Bit 11 Bit 10 Bit 9 Bit 8 Bit 7
None Bit 6 Bit 5 Bit 4 Bit 3 Bit 2
Invalid
Operation (V)
Division
by Zero (Z)
Overflow
(O)
Underflow
(U)
Inexact
(I)
Floating-Point Communication Regi s ter ( FPUL) (32 bits, Initial Value = Undefined):
Information is transferred between the FPU and CPU via FPUL.
2.3 Memory-Mapped Registers
Some control registers are mapped to the following memory areas. Each of the mapped registers
has two addresses.
H'1C00 0000 to H'1FFF FFFF
H'FC00 0000 to H'FFFF FFFF
These two areas are used as follows.
• H'1C00 0000 to H'1FFF FFFF
This area must be accessed using the address translation function of the MMU.
Setting the page number of this area to the corresponding field of the TLB enables access to a
memory-mapped register.
The operation of an access to this area without using the address translation function of the
MMU is not guaranteed.
• H'FC00 0000 to H'FFFF FFFF
Access to area H'FC00 0000 to H'FFFF FFFF in user mode will cause an address error.
Memory-mapped registers can be referenced in user mode by means of access that involves
address translation.
Note: Do not access addresses to which registers are not mapped in either area. The operation of
an access to an address with no register mapped is undefined. Also, memory-mapped
registers must be accessed using a fixed data size. The operation of an access using an
invalid data size is undefined.
Rev. 1.50, 10/04, page 19 of 448
Page 40
2.4 Data Formats in Registers
Register operands are always longwords (32 bits). When a memory operand is only a byte (8 bits)
or a word (16 bits), it is sign-extended into a longword when loaded into a register.
0
67
S
31
SS
1415
S
31
SS
067
0
01415
Figure 2.6 Formats of Byte Data and Word Data in Register
2.5 Data Formats in Memory
Memory data formats are classified into bytes, words, and longwords. Memory can be accessed in
an 8-bit byte, 16-bit word, or 32-bit longword form. A memory operand less than 32 bits in length
is sign-extended before being loaded into a register.
A word operand must be accessed starting from a word boundary (even address of a 2-byte unit:
address 2n), and a longword operand starting from a longword boundary (even address of a 4-byte
unit: address 4n). An address error will result if this rule is not observed. A byte operand can be
accessed from any address.
Big endian or little endian byte order can be selected for the data format. The endian should be set
with the external pin after a power-on reset. The endian cannot be changed dynamically. Bit
positions are numbered left to right from most-significant to least-significant. Thus, in a 32-bit
longword, the leftmost bit, bit 31, is the most significant bit and the rightmost bit, bit 0, is the least
significant bit.
The data format in memory is shown in figure 2.7.
Rev. 1.50, 10/04, page 20 of 448
Page 41
Address A
Address A + 4
Address A + 8
A + 1 A + 2 A + 3
A
31
231570
70707070
Byte 0
Byte 1 Byte 2
150 150
Word 0
310
Longword
Byte 3
Word 1
A + 11
A + 10 A + 9 A + 8
31
231570
70707070
Byte 3
Byte 2 Byte 1 Byte 0
150
Word 1
310
150
Longword
Word 0
Address A + 8
Address A + 4
Address A
Big endianLittle endian
Figure 2.7 Data Formats in Memory
For the 64-bit data format, see figure 2.5.
2.6 Processing States
This LSI has major three processing states: the reset state, instruction execution state, and powerdown state.
Reset State: In this state the CPU is reset. The reset state is divided into the power-on reset state
and the manual reset.
In the power-on reset state, the internal state of the CPU and the on-chip peripheral module
registers are initialized. In the manual reset state, the internal state of the CPU and some registers
of on-chip peripheral modules are initialized. For details, see register descriptions for each section.
Instruction Execution State: In this state, the CPU executes program instructions in sequence.
The Instruction execution state has the normal program execution state and the exception handling
state.
Power-Down State: In a power-down state, CPU halts operation and power consumption is
reduced. The power-down state is entered by executing a SLEEP instruction. There are two modes
in the power-down state: sleep mode and standby mode.
From any state
when reset/manual
reset input
Reset/manual
reset clearance
Instruction execution state
Figure 2.8 Processing State Transitions
Reset state
Reset/manual
reset input
Sleep instruction execution
Interrupt occurence
Reset/manual
reset input
Power-down state
Rev. 1.50, 10/04, page 21 of 448
Page 42
2.7 Usage Notes
2.7.1 Notes on Self-Modified Codes
The SH-4A prefetches instructions to accelerate the processing speed. Therefore if the instruction
in the memory is modified and it is executed immediately, then the pre-modified code in the
prefetch buffer may be executed. And the SH4AL-DSP supports each instruction and operand
cache, the coherency should be considered. In order to reflect the modified code definitely, one of
the following sequences should be executed.
In Case the Modified Codes are in Non-Cacheable Area:
SYNCO
ICBI @Rn
The target for the ICBI instruction can be any address within the range where no address error
exception occurs.
In Case the Modified Codes are in Cacheable Area (Write-Through):
SYNCO
ICBI @Rn
All instruction cache areas corresponding to the modified codes should be invalidated by the ICBI
instruction. The ICBI instruction should be issued to each cache line. One cache line is 32 bytes.
In Case the Modified Codes are in Cacheable Area (Copy-Back):
OCBP @Rm or OCBWB @Rm
SYNCO
ICBI @Rn
All operand cache areas corresponding to the modified codes should be written back to the main
memory by the OCBP or OCBWB instruction. Then all instruction cache areas corresponding to
the modified codes should be invalidated by the ICBI instruction. The OCBP, OCBWB, and ICBI
instruction should be issued to each cache line. One cache line is 32 bytes.
Rev. 1.50, 10/04, page 22 of 448
Page 43
Section 3 Instruction Set
The SH-4A's instruction set is implemented with 16-bit fixed-length instructions. The SH-4A can
use byte (8-bit), word (16-bit), longword (32-bit), and quadword (64-bit) data sizes for memory
access. Single-precision floating-point data (32 bits) can be moved to and from memory using
longword or quadword size. Double-precision floating-point data (64 bits) can be moved to and
from memory using longword size. When the SH-4A moves byte-size or word-size data from
memory to a register, the data is sign-extended.
3.1 Execution Environment
PC: At the start of instruction execution, the PC indicates the address of the instruction itself.
Load-Store Architecture: The SH-4A has a load-store architecture in which operations are
basically executed using registers. Except for bit-manipulation operations such as logical AND
that are executed directly in memory, operands in an operation that requires memory access are
loaded into registers and the operation is executed between the registers.
Delayed Branches: Except for the two branch instructions BF and BT, the SH-4A's branch
instructions and RTE are delayed branches. In a delayed branch, the instruction following the
branch is executed before the branch destination instruction.
Delay Slot: This execution slot following a delayed branch is called a delay slot. For example, the
BRA execution sequence is as follows:
Table 3.1 Execution Order of Delayed Branch Instructions
Instructions Execution Order
BRA TARGET (Delayed branch instruction) BRA
ADD (Delay slot) ↓
: ADD
: ↓
A slot illegal instruction exception may occur when a specific instruction is executed in a delay
slot. For details, see section 5, Exception Handling. The instruction following BF/S or BT/S for
which the branch is not taken is also a delay slot instruction.
T Bit: The T bit in SR is used to show the result of a compare operation, and is referenced by a
conditional branch instruction. An example of the use of a conditional branch instruction is shown
below.
Rev. 1.50, 10/04, page 23 of 448
Page 44
ADD #1, R0 ; T bit is not changed by ADD operation
CMP/EQ R1, R0 ; If R0 = R1, T bit is set to 1
BT TARGET ; Branches to TARGET if T bit = 1 (R0 = R1)
In an RTE delay slot, the SR bits are referenced as follows. In instruction access, the MD bit is
used before modification, and in data access, the MD bit is accessed after modification. The other
bits—S, T, M, Q, FD, BL, and RB—after modification are used for delay slot instruction
execution. The STC and STC.L SR instructions access all SR bits after modification.
Constant Values: An 8-bit constant value can be specified by the instruction code and an
immediate value. 16-bit and 32-bit constant values can be defined as literal constant values in
memory, and can be referenced by a PC-relative load instruction.
MOV.W @(disp, PC), Rn
MOV.L @(disp, PC), Rn
There are no PC-relative load instructions for floating-point operations. However, it is possible to
set 0.0 or 1.0 by using the FLDI0 or FLDI1 instruction on a single-precision floating-point
register.
Rev. 1.50, 10/04, page 24 of 448
Page 45
3.2 Addressing Modes
Addressing modes and effective address calculation methods are shown in table 3.2. When a
location in virtual memory space is accessed (AT in MMUCR = 1), the effective address is
translated into a physical memory address. If multiple virtual memory space systems are selected
(SV in MMUCR = 0), the least significant bit of PTEH is also referenced as the access ASID. For
details, see section 7, Memory Management Unit (MMU).
Table 3.2 Addressing Modes and Effective Addresses
Addressing
Mode
Register
direct
Register
indirect
Register
indirect
with postincrement
Register
indirect
with predecrement
Instruction
Format Effective Address Calculation Method
Rn Effective address is register Rn.
(Operand is register Rn contents.)
@Rn Effective address is register Rn contents.
RnRn
@Rn+ Effective address is register Rn contents.
A constant is added to Rn after instruction
execution: 1 for a byte operand, 2 for a word
operand, 4 for a longword operand, 8 for a
quadword operand.
RnRn
Rn + 1/2/4
1/2/4
@–Rn Effective address is register Rn contents,
decremented by a constant beforehand:
1 for a byte operand, 2 for a word operand,
4 for a longword operand, 8 for a quadword
operand.
Rn
Rn – 1/2/4
1/2/4
+
–
Rn – 1/2/4/8
Calculation
Formula
—
Rn → EA
(EA: effective
address)
Rn → EA
After
instruction
execution
Byte:
Rn + 1 → Rn
Word:
Rn + 2 → Rn
Longword:
Rn + 4 → Rn
Quadword:
Rn + 8 → Rn
Byte:
Rn – 1 → Rn
Word:
Rn – 2 → Rn
Longword:
Rn – 4 → Rn
Quadword:
Rn – 8 → Rn
Rn → EA
(Instruction
executed
with Rn after
calculation)
Rev. 1.50, 10/04, page 25 of 448
Page 46
Addressing
Mode
Register
indirect with
displacement
Instruction
Format Effective Address Calculation Method
@(disp:4, Rn) Effective address is register Rn contents with
4-bit displacement disp added. After disp is
zero-extended, it is multiplied by 1 (byte), 2
(word), or 4 (longword), according to the operand
size.
Rn
disp
(zero-extended)
+
×
Rn + disp × 1/2/4
Calculation
Formula
Byte: Rn + disp
→ EA
Word: Rn +
disp × 2 → EA
Longword:
Rn + disp × 4
→ EA
Indexed
register
indirect
GBR indirect
with displacement
Indexed GBR
indirect
1/2/4
@(R0, Rn) Effective address is sum of register Rn and R0
contents.
Rn
+
R0
Rn + R0
@(disp:8, GBR) Effective address is register GBR contents with
8-bit displacement disp added. After disp is
zero-extended, it is multiplied by 1 (byte), 2
(word), or 4 (longword), according to the operand
size.
GBR
disp
(zero-extended)
1/2/4
+
×
GBR
+ disp × 1/2/4
@(R0, GBR) Effective address is sum of register GBR and R0
contents.
GBR
Rn + R0 → EA
Byte: GBR +
disp → EA
Word: GBR +
disp × 2 → EA
Longword:
GBR + disp × 4
→ EA
GBR + R0 →
EA
Rev. 1.50, 10/04, page 26 of 448
R0
+
GBR + R0
Page 47
Addressing
Mode
PC-relative
with
displacement
Instruction
Format Effective Address Calculation Method
@(disp:8, PC) Effective address is PC + 4 with 8-bit displacement
disp added. After disp is zero-extended, it is
multiplied by 2 (word), or 4 (longword), according
to the operand size. With a longword operand,
the lower 2 bits of PC are masked.
PC
*
&
Calculation
Formula
Word: PC + 4
+ disp × 2 →
EA
Longword:
PC & H'FFFF
FFFC + 4 +
disp × 4 → EA
H'FFFF FFFC
4
disp
(zero-extended)
2/4
+
PC + 4 + disp
× 2
+
×
*
With longword operand
or PC &
H'FFFF FFFC
+ 4 + disp × 4
PC-relative disp:8 Effective address is PC + 4 with 8-bit displacement
disp added after being sign-extended and
multiplied by 2.
PC
+
4
disp
(sign-extended)
2
+
PC + 4 + disp × 2
×
PC + 4 + disp
× 2 → BranchTarget
Rev. 1.50, 10/04, page 27 of 448
Page 48
Addressing
Mode
Instruction
Format Effective Address Calculation Method
PC-relative disp:12 Effective address is PC + 4 with 12-bit
displacement disp added after being sign-extended
and
multiplied by 2.
PC
+
Calculation
Formula
PC + 4 + disp
× 2 → BranchTarget
4
disp
(sign-extended)
2
Rn Effective address is sum of PC + 4 and Rn.
PC
4
Rn
Immediate #imm:8 8-bit immediate data imm of TST, AND, OR, or
+
PC + 4 + disp × 2
×
PC + 4 + Rn →
Branch-Target
+
+
PC + 4 + Rn
—
XOR instruction is zero-extended.
#imm:8 8-bit immediate data imm of MOV, ADD, or
—
CMP/EQ instruction is sign-extended.
#imm:8 8-bit immediate data imm of TRAPA instruction is
—
zero-extended and multiplied by 4.
Note: For the addressing modes below that use a displacement (disp), the assembler descriptions
in this manual show the value before scaling (×1, ×2, or ×4) is performed according to the
operand size. This is done to clarify the operation of the LSI. Refer to the relevant
assembler notation rules for the actual assembler descriptions.
@ (disp:4, Rn) ; Register indirect with displacement
@ (disp:8, GBR) ; GBR indirect with displacement
@ (disp:8, PC) ; PC-relative with displacement
disp:8, disp:12 ; PC-relative
Rev. 1.50, 10/04, page 28 of 448
Page 49
3.3 Instruction Set
Table 3.3 shows the notation used in the SH instruction lists shown in tables 3.4 to 3.13.
Table 3.3 Notation Used in Instruction List
Item Format Description
Instruction
mnemonic
Operation
notation
Instruction code MSB ↔ LSB mmmm: Register number (Rm, FRm)
Privileged mode "Privileged" means the instruction can only be executed
Instruction OperationInstruction CodePrivilegedT Bit New
FMOV DRm,XDn DRm → XDn
FMOV XDm,DRn XDm → DRn
FMOV XDm,XDn XDm → XDn
FMOV @Rm,XDn (Rm) → XDn
FMOV @Rm+,XDn (Rm) → XDn, Rm + 8 → Rm
FMOV @(R0,Rm),XDn (R0 + Rm) → XDn
FMOV XDm,@Rn XDm → (Rn)
FMOV XDm,@-Rn Rn – 8 → Rn, XDm → (Rn)
FMOV XDm,@(R0,Rn) XDm → (R0 + Rn)
FIPR FVm,FVn inner_product (FVm, FVn) →
FR[n+3]
FTRV XMTRX,FVn transform_vector (XMTRX,
FVn) → FVn
FRCHG ~FPSCR.FR → FPSCR.FR
FSCHG ~FPSCR.SZ → FPSCR.SZ
FPCHG ~FPSCR.PR → FPSCR.PR
FSRRA FRn 1/sqrt(FRn) → FRn
FSCA FPUL,DRn sin(FPUL) → FRn
cos(FPUL) → FR[n + 1]
Note: * sqrt(FRn) is the square root of FRn.
1111nnn1mmm01100
1111nnn0mmm11100
1111nnn1mmm11100
1111nnn1mmmm1000
1111nnn1mmmm1001
1111nnn1mmmm0110
1111nnnnmmm11010
1111nnnnmmm11011
1111nnnnmmm10111
1111nnmm11101101
1111nn0111111101
1111101111111101
1111001111111101
1111011111111101
1111nnnn01111101
1111nnn011111101
— — —
— — —
— — —
— — —
— — —
— — —
— — —
— — —
— — —
— — —
— — —
— — —
— — —
New
New
New
Rev. 1.50, 10/04, page 42 of 448
Page 63
Section 4 Pipelining
The SH-4A is a 2-ILP (instruction-level-parallelism) superscalar pipelining microprocessor.
Instruction execution is pipelined, and two instructions can be executed in parallel.
4.1 Pipelines
Figure 4.1 shows the basic pipelines. Normally, a pipeline consists of seven stages: instruction
fetch (I1/I2), decode and register read (ID), execution (E1/E2/E3), and write-back (WB). An
instruction is executed as a combination of basic pipelines.
The value of PR is changed in the E3 stage of delay slot instruction.
When the STS and STS.L instructions from PR are used as delay slot instructions,
changed PR value is used.
Instructions are categorized into six groups according to the internal function blocks used, as
shown in table 4.2. Table 4.3 shows the parallel-executability of pairs of instructions in terms of
groups. For example, ADD in the EX group and BRA in the BR group can be executed in parallel.
The parallel execution of two instructions can be carried out under following conditions.
1. Both addr (preceding instruction) and addr+2 (following instruction) are specified within the
minimum page size (1 Kbyte).
2. The execution of these two instructions is supported in table 4.3, Combination of Preceding
and Following Instructions.
3. Data used by an instruction of addr does not conflict with data used by a previous instruction
4. Data used by an instruction of addr+2 does not conflict with data used by a previous
instruction
5. Both instructions are valid
Table 4.3 Combination of Preceding and Following Instructions
Preceding Instruction (addr)
EX MT BR LS FE CO
Following
Instruction
(addr+2)
EX No Yes Yes Yes Yes
MT Yes Yes Yes Yes Yes
BR Yes Yes No Yes Yes
LS Yes Yes Yes No Yes
FE Yes Yes Yes Yes No
CO No
Rev. 1.50, 10/04, page 55 of 448
Page 76
4.3 Issue Rates and Execution Cycles
Instruction execution cycles are summarized in table 4.4. Instruction Group in the table 4.4
corresponds to the category in the table 4.2. Penalty cycles due to a pipeline stall are not
considered in the issue rates and execution cycles in this section.
1. Issue Rate
Issue rates indicates the issue period between one instruction and next instruction.
E.g. AND.B instruction
I1I2IDS1S2S3WB
ID
E1S1
ID
E2S2 E3S3WB
Issue rate: 3
E.g. MAC.W instruction
Next instruction
I1I2IDS1S2S3
Issue rate: 2
Next instruction
(I1)
ID
(I2)
(I1)(ID)(I2)
S2S3WB
S1
(ID)
WB
M2
2. Execution Cycles
Execution cycles indicates the cycle counts an instruction occupied the pipeline based on the next rules.
CPU instruction
Execution Cycles: 3
E.g. AND.B instruction
I1I2IDS1S2S3WB
E.g. MAC.W instruction
I1I2IDS1S2S3
ID
E1S1
ID
E2S2 E3S3
Execution Cycles: 4
WB
S2S3WB
S1
ID
M2
M3
FPU instruction
E.g. FMUL instruction
I1I2
ID
FE2FE3FE4FE5FE6
FE1
FE1FE2FE3FE4FE5FE6FS
FE1FE2FE3FE4FE5FE6FS
Execution Cycles: 3
FS
M3
WB
MS
MS
E.g. FDIV instruction
I2
I1
ID
Rev. 1.50, 10/04, page 56 of 448
FE1 FE2
FE5
FE4
FE3
Divider occupation cycle
FE6
FS
Execution Cycles: 14
FE5
FE4
FE3
FE6
FS
Page 77
Table 4.4 Issue Rates and Execution Cycles
Functional
Category
Data transfer
instructions
Instruction
No. Instruction
1 EXTS.B Rm,Rn EX 1 1 2-1
2 EXTS.W Rm,Rn EX 1 1 2-1
3 EXTU.B Rm,Rn EX 1 1 2-1
4 EXTU.W Rm,Rn EX 1 1 2-1
5 MOV Rm,Rn MT 1 1 2-4
6 MOV #imm,Rn MT 1 1 2-3
7 MOVA @(disp,PC),R0 LS 1 1 2-2
8 MOV.W @(disp,PC),Rn LS 1 1 3-1
9 MOV.L @(disp,PC),Rn LS 1 1 3-1
10 MOV.B @Rm,Rn LS 1 1 3-1
11 MOV.W @Rm,Rn LS 1 1 3-1
12 MOV.L @Rm,Rn LS 1 1 3-1
13 MOV.B @Rm+,Rn LS 1 1 3-1
14 MOV.W @Rm+,Rn LS 1 1 3-1
15 MOV.L @Rm+,Rn LS 1 1 3-1
16 MOV.B @(disp,Rm),R0 LS 1 1 3-1
17 MOV.W @(disp,Rm),R0 LS 1 1 3-1
18 MOV.L @(disp,Rm),Rn LS 1 1 3-1
19 MOV.B @(R0,Rm),Rn LS 1 1 3-1
20 MOV.W @(R0,Rm),Rn LS 1 1 3-1
21 MOV.L @(R0,Rm),Rn LS 1 1 3-1
22 MOV.B @(disp,GBR),R0 LS 1 1 3-1
23 MOV.W @(disp, GBR),R0 LS 1 1 3-1
24 MOV.L @(disp, GBR),R0 LS 1 1 3-1
25 MOV.B Rm,@Rn LS 1 1 3-1
26 MOV.W Rm,@Rn LS 1 1 3-1
27 MOV.L Rm,@Rn LS 1 1 3-1
28 MOV.B Rm,@-Rn LS 1 1 3-1
29 MOV.W Rm,@-Rn LS 1 1 3-1
30 MOV.L Rm,@-Rn LS 1 1 3-1
31 MOV.B R0,@(disp,Rn) LS 1 1 3-1
Group
Issue Rate
Execution
Cycles
Execution
Pattern
Rev. 1.50, 10/04, page 57 of 448
Page 78
Functional
Category
Data transfer
instructions
Fixed-point
arithmetic
instructions
Instruction
No. Instruction
32 MOV.W R0,@(disp,Rn) LS 1 1 3-1
33 MOV.L Rm,@(disp,Rn) LS 1 1 3-1
34 MOV.B Rm,@(R0,Rn) LS 1 1 3-1
35 MOV.W Rm,@(R0,Rn) LS 1 1 3-1
36 MOV.L Rm,@(R0,Rn) LS 1 1 3-1
37 MOV.B R0,@(disp,GBR) LS 1 1 3-1
38 MOV.W R0,@(disp,GBR) LS 1 1 3-1
39 MOV.L R0,@(disp,GBR) LS 1 1 3-1
40 MOVCA.L R0,@Rn LS 1 1 3-4
41 MOVCO.L R0,@Rn CO 1 1 3-9
42 MOVLI.L @Rm,R0 CO 1 1 3-8
43 MOVUA.L @Rm,R0 LS 2 2 3-10
44 MOVUA.L @Rm+,R0 LS 2 2 3-10
45 MOVT Rn EX 1 1 2-1
46 OCBI @Rn LS 1 1 3-4
47 OCBP @Rn LS 1 1 3-4
48 OCBWB @Rn LS 1 1 3-4
49 PREF @Rn LS 1 1 3-4
50 SWAP.B Rm,Rn EX 1 1 2-1
51 SWAP.W Rm,Rn EX 1 1 2-1
52 XTRCT Rm,Rn EX 1 1 2-1
53 ADD Rm,Rn EX 1 1 2-1
54 ADD #imm,Rn EX 1 1 2-1
55 ADDC Rm,Rn EX 1 1 2-1
56 ADDV Rm,Rn EX 1 1 2-1
57 CMP/EQ #imm,R0 EX 1 1 2-1
58 CMP/EQ Rm,Rn EX 1 1 2-1
59 CMP/GE Rm,Rn EX 1 1 2-1
60 CMP/GT Rm,Rn EX 1 1 2-1
61 CMP/HI Rm,Rn EX 1 1 2-1
62 CMP/HS Rm,Rn EX 1 1 2-1
Group
Issue Rate
Execution
Cycles
Execution
Pattern
Rev. 1.50, 10/04, page 58 of 448
Page 79
Functional
Category
Fixed-point
arithmetic
instructions
Logical
instructions
Instruction
No. Instruction
63 CMP/PL Rn EX 1 1 2-1
64 CMP/PZ Rn EX 1 1 2-1
65 CMP/STR Rm,Rn EX 1 1 2-1
66 DIV0S Rm,Rn EX 1 1 2-1
67 DIV0U EX 1 1 2-1
68 DIV1 Rm,Rn EX 1 1 2-1
69 DMULS.L Rm,Rn EX 1 2 5-6
70 DMULU.L Rm,Rn EX 1 2 5-6
71 DT Rn EX 1 1 2-1
72 MAC.L @Rm+,@Rn+ CO 2 5 5-9
73 MAC.W @Rm+,@Rn+ CO 2 4 5-8
74 MUL.L Rm,Rn EX 1 2 5-6
75 MULS.W Rm,Rn EX 1 1 5-5
76 MULU.W Rm,Rn EX 1 1 5-5
77 NEG Rm,Rn EX 1 1 2-1
78 NEGC Rm,Rn EX 1 1 2-1
79 SUB Rm,Rn EX 1 1 2-1
80 SUBC Rm,Rn EX 1 1 2-1
81 SUBV Rm,Rn EX 1 1 2-1
82 AND Rm,Rn EX 1 1 2-1
83 AND #imm,R0 EX 1 1 2-1
84 AND.B #imm,@(R0,GBR) CO 3 3 3-2
85 NOT Rm,Rn EX 1 1 2-1
86 OR Rm,Rn EX 1 1 2-1
87 OR #imm,R0 EX 1 1 2-1
88 OR.B #imm,@(R0,GBR) CO 3 3 3-2
89 TAS.B @Rn CO 4 4 3-3
90 TST Rm,Rn EX 1 1 2-1
91 TST #imm,R0 EX 1 1 2-1
92 TST.B #imm,@(R0,GBR) CO 3 3 3-2
93 XOR Rm,Rn EX 1 1 2-1
94 XOR #imm,R0 EX 1 1 2-1
Group
Issue Rate
Execution
Cycles
Execution
Pattern
Rev. 1.50, 10/04, page 59 of 448
Page 80
Functional
Category
Logical
instructions
Shift
instructions
Branch
instructions
System
control
instructions
Instruction
No. Instruction
95 XOR.B #imm,@(R0,GBR) CO 3 3 3-2
96 ROTL Rn EX 1 1 2-1
97 ROTR Rn EX 1 1 2-1
98 ROTCL Rn EX 1 1 2-1
99 ROTCR Rn EX 1 1 2-1
100 SHAD Rm,Rn EX 1 1 2-1
101 SHAL Rn EX 1 1 2-1
102 SHAR Rn EX 1 1 2-1
103 SHLD Rm,Rn EX 1 1 2-1
104 SHLL Rn EX 1 1 2-1
105 SHLL2 Rn EX 1 1 2-1
106 SHLL8 Rn EX 1 1 2-1
107 SHLL16 Rn EX 1 1 2-1
108 SHLR Rn EX 1 1 2-1
109 SHLR2 Rn EX 1 1 2-1
110 SHLR8 Rn EX 1 1 2-1
111 SHLR16 Rn EX 1 1 2-1
112 BF disp BR 1+0 to 2 1 1-1
113 BF/S disp BR 1+0 to 2 1 1-1
114 BT disp BR 1+0 to 2 1 1-1
115 BT/S disp BR 1+0 to 2 1 1-1
116 BRA disp BR 1+0 to 2 1 1-1
117 BRAF Rm BR 1+3 1 1-2
118 BSR disp BR 1+0 to 2 1 1-1
119 BSRF Rm BR 1+3 1 1-2
120 JMP @Rn BR 1+3 1 1-2
121 JSR @Rn BR 1+3 1 1-2
122 RTS BR 1+0 to 3 1 1-3
123 NOP MT 1 1 2-3
124 CLRMAC EX 1 1 5-7
125 CLRS EX 1 1 2-1
Group
Issue Rate
Execution
Cycles
Execution
Pattern
Rev. 1.50, 10/04, page 60 of 448
Page 81
Functional
Category
System
control
instructions
Instruction
No. Instruction
126 CLRT EX 1 1 2-1
127 ICBI @Rn CO 8+5+3 13 3-6
128 SETS EX 1 1 2-1
129 SETT EX 1 1 2-1
130 PREFI CO 5+5+3 10 3-7
131 SYNCO @Rn CO Undefined Undefined 3-4
132 TRAPA #imm CO 8+5+1 13 1-5
133 RTE CO 4+1 4 1-4
134 SLEEP CO Undefined Undefined 1-6
135 LDTLB CO 1 1 3-5
136 LDC Rm,DBR CO 4 4 4-2
137 LDC Rm,SGR CO 4 4 4-2
138 LDC Rm,GBR LS 1 1 4-3
139 LDC Rm,Rp_BANK LS 1 1 4-1
140 LDC Rm,SR CO 4+3 4 4-4
141 LDC Rm,SSR LS 1 1 4-1
142 LDC Rm,SPC LS 1 1 4-1
143 LDC Rm,VBR LS 1 1 4-1
144 LDC.L @Rm+,DBR CO 4 4 4-6
145 LDC.L @Rm+,SGR CO 4 4 4-6
146 LDC.L @Rm+,GBR LS 1 1 4-7
147 LDC.L @Rm+,Rp_BANK LS 1 1 4-5
148 LDC.L @Rm+,SR CO 6+3 4 4-8
149 LDC.L @Rm+,SSR LS 1 1 4-5
150 LDC.L @Rm+,SPC LS 1 1 4-5
151 LDC.L @Rm+,VBR LS 1 1 4-5
152 LDS Rm,MACH LS 1 1 5-1
153 LDS Rm,MACL LS 1 1 5-1
154 LDS Rm,PR LS 1 1 4-13
155 LDS.L @Rm+,MACH LS 1 1 5-2
156 LDS.L @Rm+,MACL LS 1 1 5-2
157 LDS.L @Rm+,PR LS 1 1 4-14
Group
Issue Rate
Execution
Cycles
Execution
Pattern
Rev. 1.50, 10/04, page 61 of 448
Page 82
Functional
Category
System
control
instructions
Singleprecision
floating-point
instructions
Instruction
No. Instruction
158 STC DBR,Rn LS 1 1 4-9
159 STC SGR,Rn LS 1 1 4-9
160 STC GBR,Rn LS 1 1 4-9
161 STC Rp_BANK,Rn LS 1 1 4-9
162 STC SR,Rn CO 1 1 4-10
163 STC SSR,Rn LS 1 1 4-9
164 STC SPC,Rn LS 1 1 4-9
165 STC VBR,Rn LS 1 1 4-9
166 STC.L DBR,@-Rn LS 1 1 4-11
167 STC.L SGR,@-Rn LS 1 1 4-11
168 STC.L GBR,@-Rn LS 1 1 4-11
169 STC.L Rp_BANK,@-Rn LS 1 1 4-11
170 STC.L SR,@-Rn CO 1 1 4-12
171 STC.L SSR,@-Rn LS 1 1 4-11
172 STC.L SPC,@-Rn LS 1 1 4-11
173 STC.L VBR,@-Rn LS 1 1 4-11
174 STS MACH,Rn LS 1 1 5-3
175 STS MACL,Rn LS 1 1 5-3
176 STS PR,Rn LS 1 1 4-15
177 STS.L MACH,@-Rn LS 1 1 5-4
178 STS.L MACL,@-Rn LS 1 1 5-4
179 STS.L PR,@-Rn LS 1 1 4-16
180 FLDI0 FRn LS 1 1 6-13
181 FLDI1 FRn LS 1 1 6-13
182 FMOV FRm,FRn LS 1 1 6-9
183 FMOV.S @Rm,FRn LS 1 1 6-9
184 FMOV.S @Rm+,FRn LS 1 1 6-9
185 FMOV.S @(R0,Rm),FRn LS 1 1 6-9
186 FMOV.S FRm,@Rn LS 1 1 6-9
187 FMOV.S FRm,@-Rn LS 1 1 6-9
188 FMOV.S FRm,@(R0,Rn) LS 1 1 6-9
Group
Issue Rate
Execution
Cycles
Execution
Pattern
Rev. 1.50, 10/04, page 62 of 448
Page 83
Functional
Category
Singleprecision
floating-point
instructions
Doubleprecision
floating-point
instructions
Instruction
No. Instruction
189 FLDS FRm,FPUL LS 1 1 6-10
190 FSTS FPUL,FRn LS 1 1 6-11
191 FABS FRn LS 1 1 6-12
192 FADD FRm,FRn FE 1 1 6-14
193 FCMP/EQ FRm,FRn FE 1 1 6-14
194 FCMP/GT FRm,FRn FE 1 1 6-14
195 FDIV FRm,FRn FE 1 14 6-15
196 FLOAT FPUL,FRn FE 1 1 6-14
197 FMAC FR0,FRm,FRn FE 1 1 6-14
198 FMUL FRm,FRn FE 1 1 6-14
199 FNEG FRn LS 1 1 6-12
200 FSQRT FRn FE 1 30 6-15
201 FSUB FRm,FRn FE 1 1 6-14
202 FTRC FRm,FPUL FE 1 1 6-14
203 FMOV DRm,DRn LS 1 1 6-9
204 FMOV @Rm,DRn LS 1 1 6-9
205 FMOV @Rm+,DRn LS 1 1 6-9
206 FMOV @(R0,Rm),DRn LS 1 1 6-9
207 FMOV DRm,@Rn LS 1 1 6-9
208 FMOV DRm,@-Rn LS 1 1 6-9
209 FMOV DRm,@(R0,Rn) LS 1 1 6-9
210 FABS DRn LS 1 1 6-12
211 FADD DRm,DRn FE 1 1 6-16
212 FCMP/EQ DRm,DRn FE 1 1 6-16
213 FCMP/GT DRm,DRn FE 1 1 6-16
214 FCNVDS DRm,FPUL FE 1 1 6-16
215 FCNVSD FPUL,DRn FE 1 1 6-16
216 FDIV DRm,DRn FE 1 14 6-18
217 FLOAT FPUL,DRn FE 1 1 6-16
218 FMUL DRm,DRn FE 1 3 6-17
219 FNEG DRn LS 1 1 6-12
Group
Issue Rate
Execution
Cycles
Execution
Pattern
Rev. 1.50, 10/04, page 63 of 448
Page 84
Functional
Category
Doubleprecision
floating-point
instructions
FPU system
control
instructions
Graphics
acceleration
instructions
Instruction
No. Instruction
220 FSQRT DRn FE 1 30 6-18
221 FSUB DRm,DRn FE 1 1 6-16
222 FTRC DRm,FPUL FE 1 1 6-16
223 LDS Rm,FPUL LS 1 1 6-1
224 LDS Rm,FPSCR LS 1 1 6-5
225 LDS.L @Rm+,FPUL LS 1 1 6-3
226 LDS.L @Rm+,FPSCR LS 1 1 6-7
227 STS FPUL,Rn LS 1 1 6-2
228 STS FPSCR,Rn LS 1 1 6-6
229 STS.L FPUL,@-Rn LS 1 1 6-4
230 STS.L FPSCR,@-Rn LS 1 1 6-8
231 FMOV DRm,XDn LS 1 1 6-9
232 FMOV XDm,DRn LS 1 1 6-9
233 FMOV XDm,XDn LS 1 1 6-9
234 FMOV @Rm,XDn LS 1 1 6-9
235 FMOV @Rm+,XDn LS 1 1 6-9
236 FMOV @(R0,Rm),XDn LS 1 1 6-9
237 FMOV XDm,@Rn LS 1 1 6-9
238 FMOV XDm,@-Rn LS 1 1 6-9
239 FMOV XDm,@(R0,Rn) LS 1 1 6-9
240 FIPR FVm,FVn FE 1 1 6-19
241 FRCHG FE 1 1 6-14
242 FSCHG FE 1 1 6-14
243 FPCHG FE 1 1 6-14
244 FSRRA FRn FE 1 1 6-21
245 FSCA FPUL,DRn FE 1 3 6-22
246 FTRV XMTRX,FVn FE 1 4 6-20
Group
Issue Rate
Execution
Cycles
Execution
Pattern
Rev. 1.50, 10/04, page 64 of 448
Page 85
Section 5 Exception Handling
5.1 Summary of Exception Handling
Exception handling processing is handled by a special routine which is executed by a reset,
general exception handling, or interrupt. For example, if the executing instruction ends
abnormally, appropriate action must be taken in order to return to the original program sequence,
or report the abnormality before terminating the processing. The process of generating an
exception handling request in response to abnormal termination, and passing control to a userwritten exception handling routine, in order to support such functions, is given the generic name of
exception handling.
The exception handling in the SH-4A is of three kinds: resets, general exceptions, and interrupts.
5.2 Register Descriptions
Table 5.1 lists the configuration of registers related exception handling.
Table 5.1 Register Configuration
Area 7
Register Name Abbr. R/W P4 Address*
TRAPA exception register TRA R/W H'FF00 0020 H'1F00 0020 32
The TRAPA exception register (TRA) consists of 8-bit immediate data (imm) for the TRAPA
instruction. TRA is set automatically by hardware when a TRAPA instruction is executed. TRA
can also be modified by software.
Bit:
31302928272625242322212019181716
Initial value:
Initial value:
Bit Bit Name
31 to 10 All 0 R Reserved
9 to 2 TRACODE Undefined R/W TRAPA Code
1, 0 All 0 R Reserved
0000000000000000
R/W:
RRRRRRRRRRRRRRRR
Bit:
1514131211109876543210
000000
R/W:
RRRRRRR/W
R/W
TRACODE
R/W R/W R/W
R/W R/W R/WRR
Initial
Value R/W Description
For details on reading/writing this bit, see General
Precautions on Handling of Product.
8-bit immediate data of TRAPA instruction is set
For details on reading/writing this bit, see General
Precautions on Handling of Product.
00
Rev. 1.50, 10/04, page 66 of 448
Page 87
5.2.2 Exception Event Register (EXPEVT)
The exception event register (EXPEVT) consists of a 12-bit exception code. The exception code
set in EXPEVT is that for a reset or general exception event. The exception code is set
automatically by hardware when an exception occurs. EXPEVT can also be modified by software.
Bit:
31302928272625242322212019181716
Initial value:
Initial value:
Bit Bit Name
31 to 12 All 0 R Reserved
11 to 0 EXPCODE H'000 or
0000000000000000
R/W:
RRRRRRRRRRRRRRRR
Bit:
1514131211109876543210
0000
R/W:
RRRRR/W R/W R/W
0000000/100000
R/W
EXPCODE
R/W R/W
R/W R/W R/W R/W R/W R/W
Initial
Value R/W Description
For details on reading/writing this bit, see General
Precautions on Handling of Product.
R/W Exception Code
H'020
The exception code for a reset or general exception is
set. For details, see table 5.3.
Rev. 1.50, 10/04, page 67 of 448
Page 88
5.2.3 Interrupt Event Register (INTEVT)
The interrupt event register (INTEVT) consists of a 14-bit exception code. The exception code is
set automatically by hardware when an exception occurs. INTEVT can also be modified by
software.
Bit:
31302928272625242322212019181716
Initial value:
Initial value:
Bit Bit Name
31 to 14 All 0 R Reserved
13 to 0 INTCODE Undefined R/W Exception Code
0000000000000000
R/W:
RRRRRRRRRRRRRRRR
Bit:
1514131211109876543210
R/W
INTCODE
R/W
R/W R/W R/W R/W R/W R/W R/W
00
R/W:
RRR/W R/W R/W R/W R/W
Initial
Value R/W Description
For details on reading/writing this bit, see General
Precautions on Handling of Product.
The exception code for an interrupt is set. For details,
see table 5.3.
Rev. 1.50, 10/04, page 68 of 448
Page 89
5.3 Exception Handling Functions
5.3.1 Exception Handling Flow
In exception handling, the contents of the program counter (PC), status register (SR), and R15 are
saved in the saved program counter (SPC), saved status register (SSR), and saved general
register15 (SGR), and the CPU starts execution of the appropriate exception handling routine
according to the vector address. An exception handling routine is a program written by the user to
handle a specific exception. The exception handling routine is terminated and control returned to
the original program by executing a return-from-exception instruction (RTE). This instruction
restores the PC and SR contents and returns control to the normal processing routine at the point at
which the exception occurred. The SGR contents are not written back to R15 with an RTE
instruction.
The basic processing flow is as follows. For the meaning of the SR bits, see section 2,
Programming Model.
1. The PC, SR, and R15 contents are saved in SPC, SSR, and SGR, respectively.
2. The block bit (BL) in SR is set to 1.
3. The mode bit (MD) in SR is set to 1.
4. The register bank bit (RB) in SR is set to 1.
5. In a reset, the FPU disable bit (FD) in SR is cleared to 0.
6. The exception code is written to bits 11 to 0 of the exception event register (EXPEVT) or
interrupt event register (INTEVT).
7. The CPU branches to the determined exception handling vector address, and the exception
handling routine begins.
5.3.2 Exception Handling Vector Addresses
The reset vector address is fixed at H'A0000000. Exception and interrupt vector addresses are
determined by adding the offset for the specific event to the vector base address, which is set by
software in the vector base register (VBR). In the case of the TLB miss exception, for example,
the offset is H'00000400, so if H'9C080000 is set in VBR, the exception handling vector address
will be H'9C080400. If a further exception occurs at the exception handling vector address, a
duplicate exception will result, and recovery will be difficult; therefore, addresses that are not to
be converted (in P1 and P2 areas) should be specified for vector addresses.
Rev. 1.50, 10/04, page 69 of 448
Page 90
5.4 Exception Types and Priorities
Table 5.3 shows the types of exceptions, with their relative priorities, vector addresses, and
exception/interrupt codes.
Table 5.3 Exceptions
Exception Transition
Direction*3
Exception
Category
Reset Abort type
General
exception
Rev. 1.50, 10/04, page 70 of 448
Execution
Mode
Reexecution
type
Completion
type
Exception
Power-on reset 1 1 H'A000 0000 — H'000
Manual reset 1 2 H'A000 0000 — H'020
H-UDI reset 1 1 H'A000 0000 — H'000
Instruction TLB multiple-hit
exception
Data TLB multiple-hit exception 1 4 H'A000 0000 — H'140
User break before instruction
execution*
Instruction address error 2 1 (VBR) H'100 H'0E0
Instruction TLB miss exception 2 2 (VBR) H'400 H'040
Note: 1. When UBDE in CBCR = 1, PC = DBR. In other cases, PC = VBR + H'100.
2. Priority is first assigned by priority level, then by priority order within each level (the
lowest number represents the highest priority).
3. Control passes to H'A000 0000 in a reset, and to [VBR + offset] in other cases.
4. Stored in EXPEVT for a reset or general exception, and in INTEVT for an interrupt.
Rev. 1.50, 10/04, page 71 of 448
Page 92
5.5 Exception Flow
5.5.1 Exception Flow
Figure 5.1 shows an outline flowchart of the basic operations in instruction execution and
exception handling. For the sake of clarity, the following description assumes that instructions are
executed sequentially, one by one. Figure 5.1 shows the relative priority order of the different
kinds of exceptions (reset, general exception, and interrupt). Register settings in the event of an
exception are shown only for SSR, SPC, SGR, EXPEVT/INTEVT, SR, and PC. However, other
registers may be set automatically by hardware, depending on the exception. For details, see
section 5.6, Description of Exceptions. Also, see section 5.6.4, Priority Order with Multiple
Exceptions, for exception handling during execution of a delayed branch instruction and a delay
slot instruction, or in the case of instructions in which two data accesses are performed.
Reset
requested?
No
Execute next instruction
General
exception requested?
No
Interrupt
requested?
No
Note: * When the exception of the highest priority is an interrupt.
Whether IMASK is updated or not can be set by software.
Yes
Yes
Yes
SSR ← SR
SPC ← PC
SGR ← R15
EXPEVT/INTEVT ← exception code
SR.{MD,RB,BL} ← 111
SR.IMASK ← received interuupt level (*)
PC ← (CBCR.UBDE=1 && User_Break?
DBR: (VBR + Offset))
Figure 5.1 Instruction Execution and Exception Handling
Rev. 1.50, 10/04, page 72 of 448
Page 93
5.5.2 Exception Source Acceptance
A priority ranking is provided for all exceptions for use in determining which of two or more
simultaneously generated exceptions should be accepted. Five of the general exceptions—general
illegal instruction exception, slot illegal instruction exception, general FPU disable exception, slot
FPU disable exception, and unconditional trap exception—are detected in the process of
instruction decoding, and do not occur simultaneously in the instruction pipeline. These
exceptions therefore all have the same priority. General exceptions are detected in the order of
instruction execution. However, exception handling is performed in the order of instruction flow
(program order). Thus, an exception for an earlier instruction is accepted before that for a later
instruction. An example of the order of acceptance for general exceptions is shown in figure 5.2.
Pipeline flow:
Instruction n
Instruction n + 1
Instruction n + 2
Instruction n + 3
Order of detection:
General illegal instruction exception (instruction n + 1) and
TLB miss (instruction n + 2) are detected simultaneously
TLB miss (instruction n)
Order of exception handling:
TLB miss (instruction n)
Re-execution of instruction n
General illegal instruction exception
(instruction n + 1)
Figure 5.2 Example of General Exception Acceptance Order
4
Rev. 1.50, 10/04, page 73 of 448
Page 94
5.5.3 Exception Requests and BL Bit
When the BL bit in SR is 0, exceptions and interrupts are accepted.
When the BL bit in SR is 1 and an exception other than a user break is generated, the CPU's
internal registers and the registers of the other modules are set to their states following a manual
reset, and the CPU branches to the same address as in a reset (H'A0000000). For the operation in
the event of a user break, see the User Break Controller (UBC) section of the hardware manual of
the target product. If an ordinary interrupt occurs, the interrupt request is held pending and is
accepted after the BL bit has been cleared to 0 by software. If a nonmaskable interrupt (NMI)
occurs, it can be held pending or accepted according to the setting made by software.
Thus, normally, SPC and SSR are saved and then the BL bit in SR is cleared to 0, to enable
multiple exception state acceptance.
5.5.4 Return from Exception Handling
The RTE instruction is used to return from exception handling. When the RTE instruction is
executed, the SPC contents are restored to PC and the SSR contents to SR, and the CPU returns
from the exception handling routine by branching to the SPC address. If SPC and SSR were saved
to external memory, set the BL bit in SR to 1 before restoring the SPC and SSR contents and
issuing the RTE instruction.
Rev. 1.50, 10/04, page 74 of 448
Page 95
5.6 Description of Exceptions
The various exception handling operations explained here are exception sources, transition address
on the occurrence of exception, and processor operation when a transition is made.
5.6.1 Resets
Power-On Reset:
• Condition:
Power-on reset request
• Operations:
Exception code H'000 is set in EXPEVT, initialization of the CPU and on-chip peripheral
module is carried out, and then a branch is made to the reset vector (H'A0000000). For details,
see the register descriptions in the relevant sections. A power-on reset should be executed
when power is supplied.
Manual Reset:
• Condition:
Manual reset request
• Operations:
Exception code H'020 is set in EXPEVT, initialization of the CPU and on-chip peripheral
module is carried out, and then a branch is made to the branch vector (H'A0000000). The
registers initialized by a power-on reset and manual reset are different. For details, see the
register descriptions in the relevant sections.
H-UDI Reset:
• Source: SDIR.TI[7:4] = B'0110 (negation) or B'0111 (assertion)
• Transition address: H'A0000000
• Transition operations:
Exception code H'000 is set in EXPEVT, initialization of VBR and SR is performed, and a
branch is made to PC = H'A0000000.
CPU and on-chip peripheral module initialization is performed. For details, see the register
descriptions in the relevant sections of the hardware manual of the target product.
Rev. 1.50, 10/04, page 75 of 448
Page 96
Instruction TLB Multiple Hit Exception:
• Source: Multiple ITLB address matches
• Transition address: H'A0000000
• Transition operations:
The virtual address (32 bits) at which this exception occurred is set in TEA, and the
corresponding virtual page number (22 bits) is set in PTEH [31:10]. ASID in PTEH indicates
the ASID when this exception occurred.
Exception code H'140 is set in EXPEVT, initialization of VBR and SR is performed, and a
branch is made to PC = H'A0000000.
CPU and on-chip peripheral module initialization is performed in the same way as in a manual
reset. For details, see the register descriptions in the relevant sections of the hardware manual
of the target product.
Data TLB Multiple-Hit Exception:
• Source: Multiple UTLB address matches
• Transition address: H'A0000000
• Transition operations:
The virtual address (32 bits) at which this exception occurred is set in TEA, and the
corresponding virtual page number (22 bits) is set in PTEH [31:10]. ASID in PTEH indicates
the ASID when this exception occurred.
Exception code H'140 is set in EXPEVT, initialization of VBR and SR is performed, and a
branch is made to PC = H'A0000000.
CPU and on-chip peripheral module initialization is performed in the same way as in a manual
reset. For details, see the register descriptions in the relevant sections of the hardware manual
of the target product.
Rev. 1.50, 10/04, page 76 of 448
Page 97
5.6.2 General Exceptions
Data TLB Miss Exception:
• Source: Address mismatch in UTLB address comparison
• Transition address: VBR + H'00000400
• Transition operations:
The virtual address (32 bits) at which this exception occurred is set in TEA, and the
corresponding virtual page number (22 bits) is set in PTEH [31:10]. ASID in PTEH indicates
the ASID when this exception occurred.
The PC and SR contents for the instruction at which this exception occurred are saved in SPC
and SSR. The R15 contents at this time are saved in SGR.
Exception code H'040 (for a read access) or H'060 (for a write access) is set in EXPEVT. The
BL, MD, and RB bits are set to 1 in SR, and a branch is made to PC = VBR + H'0400.
To speed up TLB miss processing, the offset is separate from that of other exceptions.
Data_TLB_miss_exception()
{
TEA = EXCEPTION_ADDRESS;
PTEH.VPN = PAGE_NUMBER;
SPC = PC;
SSR = SR;
SGR = R15;
EXPEVT = read_access ? H'0000 0040 : H'0000 0060;
SR.MD = 1;
SR.RB = 1;
SR.BL = 1;
PC = VBR + H'0000 0400;
}
Rev. 1.50, 10/04, page 77 of 448
Page 98
Instruction TLB Miss Exception:
• Source: Address mismatch in ITLB address comparison
• Transition address: VBR + H'00000400
• Transition operations:
The virtual address (32 bits) at which this exception occurred is set in TEA, and the
corresponding virtual page number (22 bits) is set in PTEH [31:10]. ASID in PTEH indicates
the ASID when this exception occurred.
The PC and SR contents for the instruction at which this exception occurred are saved in SPC
and SSR. The R15 contents at this time are saved in SGR.
Exception code H'40 is set in EXPEVT. The BL, MD, and RB bits are set to 1 in SR, and a
branch is made to PC = VBR + H'0400.
To speed up TLB miss processing, the offset is separate from that of other exceptions.
ITLB_miss_exception()
{
TEA = EXCEPTION_ADDRESS;
PTEH.VPN = PAGE_NUMBER;
SPC = PC;
SSR = SR;
SGR = R15;
EXPEVT = H'0000 0040;
SR.MD = 1;
SR.RB = 1;
SR.BL = 1;
PC = VBR + H'0000 0400;
}
Rev. 1.50, 10/04, page 78 of 448
Page 99
Initial Page Write Exception:
• Source: TLB is hit in a store access, but dirty bit D = 0
• Transition address: VBR + H'00000100
• Transition operations:
The virtual address (32 bits) at which this exception occurred is set in TEA, and the
corresponding virtual page number (22 bits) is set in PTEH [31:10]. ASID in PTEH indicates
the ASID when this exception occurred.
The PC and SR contents for the instruction at which this exception occurred are saved in SPC
and SSR. The R15 contents at this time are saved in SGR.
Exception code H'080 is set in EXPEVT. The BL, MD, and RB bits are set to 1 in SR, and a
branch is made to PC = VBR + H'0100.
Initial_write_exception()
{
TEA = EXCEPTION_ADDRESS;
PTEH.VPN = PAGE_NUMBER;
SPC = PC;
SSR = SR;
SGR = R15;
EXPEVT = H'0000 0080;
SR.MD = 1;
SR.RB = 1;
SR.BL = 1;
PC = VBR + H'0000 0100;
}
Rev. 1.50, 10/04, page 79 of 448
Page 100
Data TLB Protection Violation Exception:
• Source: The access does not accord with the UTLB protection information (PR bits) shown
below.
PR Privileged Mode User Mode
00 Only read access possible Access not possible
01 Read/write access possible Access not possible
10 Only read access possible Only read access possible
11 Read/write access possible Read/write access possible
• Transition address: VBR + H'00000100
• Transition operations:
The virtual address (32 bits) at which this exception occurred is set in TEA, and the
corresponding virtual page number (22 bits) is set in PTEH [31:10]. ASID in PTEH indicates
the ASID when this exception occurred.
The PC and SR contents for the instruction at which this exception occurred are saved in SPC
and SSR. The R15 contents at this time are saved in SGR.
Exception code H'0A0 (for a read access) or H'0C0 (for a write access) is set in EXPEVT. The
BL, MD, and RB bits are set to 1 in SR, and a branch is made to PC = VBR + H'0100.
Data_TLB_protection_violation_exception()
{
TEA = EXCEPTION_ADDRESS;
PTEH.VPN = PAGE_NUMBER;
SPC = PC;
SSR = SR;
SGR = R15;
EXPEVT = read_access ? H'0000 00A0 : H'0000 00C0;
SR.MD = 1;
SR.RB = 1;
SR.BL = 1;
PC = VBR + H'0000 0100;
}
Rev. 1.50, 10/04, page 80 of 448
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.