Altera Corporation vii

Contents

How to Contact Altera...................................................................................................................iv
Typographic Conventions...............................................................................................................v

Overview...............................................................................................1

Introduction.......................................................................................................................................1
Audience....................................................................................................................................1
Nios CPU Overview.........................................................................................................................1
Instruction Set ...................................................................................................................................2
Register Overview............................................................................................................................2
General-Purpose Registers......................................................................................................2
The K Register...........................................................................................................................4
The Program Counter...............................................................................................................4
Control Registers.......................................................................................................................4
Memory Access Overview...............................................................................................................7
Reading from Memory (or Peripherals)........................................................................8
Writing to Memory (or Peripherals)..............................................................................9
Addressing Modes..........................................................................................................................10
5/16-bit Immediate Value.....................................................................................................10
Full Width Register-Indirect..................................................................................................12
Partial Width Register-Indirect.............................................................................................12
Full Width Register-Indirect with Offset.............................................................................13
Partial Width Register-Indirect with Offset........................................................................13
Program-Flow Control...................................................................................................................14
Relative-Branch Instructions.................................................................................................14
Absolute-Jump Instructions..................................................................................................15
Trap Instructions.....................................................................................................................15
Conditional Instructions........................................................................................................15
Exceptions........................................................................................................................................16
Exception Handling Overview.............................................................................................16
Exception Vector Table..........................................................................................................16
External Hardware Interrupt Sources..................................................................................17
Internal Exception Sources....................................................................................................17
Register Window Underflow........................................................................................17
Register Window Overflow...........................................................................................18
Direct Software Exceptions (TRAP Instructions)...............................................................19
Exception Processing Sequence............................................................................................19
Register Window Usage.................................................................................................20
Status Preservation: ISTATUS Register.......................................................................20
Return-Address.......................................................................................................................21
Simple and Complex Exception Handlers..........................................................................21
Altera Corporation #
Contents