Nios Cpu Datasheet
Nios Cpu Datasheet
1 CPU
Introduction The 2.1 version of the Nios® CPU is a pipelined general-purpose RISC
microprocessor. Nios supports both 32-bit and 16-bit architectural
variants and both 16 and 32-bit variants use 16-bit instructions. The
principal features of the Nios instruction set architecture are:
■ Simple, complete instruction set — Both 32-bit and 16-bit Nios variants
use 16-bit-wide instructions. 16-bit instructions reduce code footprint
and instruction-memory bandwidth.
f See the Nios 16-Bit Programmer’s Reference Manual and the Nios 32-Bit
Programmer’s Reference Manual for an extensive discussion of the Nios 32-
bit and 16-bit instruction set architecture. The latest revisions of all Nios
documentation are at http://www.altera.com/literature/lit-nio.html.
Nios 2.1 The Nios version 2.1 implementation is a five-stage pipeline with separate
instruction and data-memory masters (Harvard memory architecture).
Implementation Both instruction and data-memory control ports are implemented as
Details Avalon™ bus masters. Using the SOPC Builder system design tool, you
can specify connections between both Nios bus masters and any Avalon
slaves in your system such as memory and peripherals. The SOPC Builder
automatically inserts arbiters as required.
f See the Avalon Bus Specification Reference Manual for bus master and
avalon-slave signal and timing details.
Altera Corporation 1
DS-NIOSCPU-1.1
Nios 2.1 CPU Data Sheet
Instruction Bus-Master
The Nios instruction master is a 16-bit wide, latency-aware Avalon bus
master. This master is only used to fetch instructions from memory that
will be executed by the Nios CPU. This master never performs any write
operations. Because this master is latency-aware, it can perform posted-
read operations to latent memory devices. The instruction master issues
new read requests before data is returned by the bus. Nios uses a branch-
not-taken prediction scheme to issue speculative addresses. Native
support for latency minimizes the impact of latent memory and increases
the overall fMax of the system as a whole. Penalties occur only for mis-
predicted branches.
f See the Avalon Bus Specification Reference Manual for bus master and
avalon-slave signal and timing details.
Data Bus-Master
The Nios data master is 32 bits wide for 32-bit architecture variants and
16-bits wide for 16-bit architecture variants. The data master is used for
three purposes:
2 Altera Corporation
Nios 2.1 CPU Data Sheet
Shift Unit
Previous Nios architecture implementations (version 1.1.1 or earlier)
allowed user-configuration of the internal shift-unit. Nios now uses fixed
(non-configurable) barrel-shifter logic that executes all shift instructions
(ASR, ASRI, ASL, ASLI, LSL, LSLI, RLC and RRC) in two clock cycles,
regardless of the shift-distance.
Multiply Support
Nios supports three different options for implementing integer
multiplication operations from software:
When using the MUL option with Altera® StratixTM devices, the
hardware multiplier uses the DSP blocks for implementation.
Altera Corporation 3
Nios 2.1 CPU Data Sheet
Interrupt Support
Version 2.1 of Nios allows optional removal of support for TRAP
instructions, hardware interrupts, and internal exceptions. This option is
intended for use only in Nios systems where the processor is
implementing a very simple control function (that is, not running complex
software). When so configured, the Nios will not:
class = “altera_nios”;
4 Altera Corporation
Nios 2.1 CPU Data Sheet
Altera Corporation 5
Nios 2.1 CPU Data Sheet
In either case, the SDK associated with this CPU will be generated with the
correct libraries and default compiler options necessary to create software
for the selected architecture variant.
MSTEP Assignment
This assignment may be set to 1 only for 32-bit Nios cores. When mstep =
1, the generated Nios CPU includes hardware that implements the MSTEP
instruction. The generated SDK makes use of MSTEP in the C-runtime
libraries. When mstep = 0, the MSTEP instruction is not implemented,
and the C-runtime libraries will not use it.
MULTIPLY Assignment
This assignment may be set to 1 only for 32-bit Nios cores. When
multiply = 1, the generated Nios CPU includes hardware that
implements the MUL instruction, and the generated SDK makes use of
MUL in the C-runtime libraries. When multiply = 0, the MUL
instruction is not implemented, and the C-runtime libraries will not use it.
Issuing the MUL instruction when multiply = 0 produces an undefined
result.
6 Altera Corporation
Nios 2.1 CPU Data Sheet
rom_decoder Assignment
The Nios CPU includes internal instruction-decode logic that takes the
incoming 16-bit instruction word as input and produces approximately 80
control signals that determine the operation performed by the data path
logic. A significant portion of the instruction-decoder logic can be
implemented either as logic elements (LEs) or as an internal ROM memory
using a single embedded-system block (ESB) in APEX™-family devices.
When rom_decoder = 1, a single ESB (APEX) is used in the instruction-
decode logic, saving approximately 52-58 LEs. The exact savings depends
on which other CPU options have been selected. When rom_decoder =
0, no memory resources are used in the instruction decoder, reducing the
CPU’s ESB-utilization by exactly one.
wvalid_wr Assignment
Control-register number 2 (%ctl2) is the WVALID register. Software can
always read this register to determine the limits of travel on current
window pointer (CWP). WVALID determines when underflow and
overflow exceptions are generated. A detailed description of the WVALID
register appears in the Nios 32-Bit Programmer’s Reference Manual and Nios
16-Bit Programmer’s Reference Manual. Regardless of the setting of
wvalid_wr, the WVALID register is initialized at reset so that the entire
windowed register file is available to software (LO_LIMIT = 1 and
HI_LIMIT = <number-of-registers> - 2). The vast majority of compiled
programs never need to alter the initially-set WVALID value.
Altera Corporation 7
Nios 2.1 CPU Data Sheet
num_regs Assignment
This assignment value determines the total number of registers
implemented in the CPU’s windowed-register file. Larger register files
use more on-chip memory resources. Larger register files allow deeper
subroutine-nesting before a register-window underflow exception is
generated. With 128 registers, software can call subroutines 7-levels deep
before an underflow exception is generated. With 512 registers, software
can call subroutines 31-levels deep before an underflow exception is
generated. Software that frequently generates underflow/overflow
exceptions may experience significant performance degradation. In
practice, even complicated software can live comfortably in 512 registers
although recursive algorithms can cause even simple software to execute
very deep-subroutine nesting. The best setting for num_regs depends on
the complexity and performance requirements of the application software
and the amount of on-chip memory resources available.
include_debug Assignment
The Nios 2.1 CPU includes an optional internal-debug core. This core,
when used with appropriate software (included GDB-stub), allows
hardware breakpoints to be set on various types of memory-access
including both data and instruction accesses to ranges of memories.
Breakpoints can be further qualified to trigger only when certain data
values are detected for read or write (LD/ST) operations.
f For more detailed instructions on using the internal debug core to set
breakpoints, See the Nios Software Development Reference Manual.
The debug core can be implemented either with or without support for an
external trace-capture buffer. See “include_trace Assignment” on page 9.
When include_debug = 1, the CPU will use considerably more logic
resources.
8 Altera Corporation
Nios 2.1 CPU Data Sheet
include_trace Assignment
The Nios internal debug core can be implemented with (include_trace
= 1) or without (include_trace = 0) support for an off-chip SSRAM
trace memory buffer. When include_trace = 1, the Nios CPU core will
grow an additional dedicated set of pins which can be connected directly
to a trace memory board, available from 3rd-party partners. Software and
libraries included in the Nios Development Kit allow limited capture and
display facilities for trace data gathered by the internal debug core into an
external buffer. Third-party software is available for controlling trace
capture, disassembly, and display from within an integrated development
environment (IDE).
reset_slave Assignment
The Nios CPU logic is generated with a built-in reset address. The value
of the reset address is derived from two PTF assignments: reset_slave
and reset_offset. The reset_slave assignment is used to extract a
base-address from the slave port of the specified slave-port on the
specified module. The reset_offset assignment specifies a byte-offset
that is applied to the indicated devices’s base-address.
After system reset is asserted and released, the CPU will fetch its first
instruction from the computed reset-address. For example, consider a
system with a Nios CPU and an on-chip memory module named
boot_rom mapped at base-address 0x400. In this example, suppose the
on-chip memory module has a single slave-port named s1. Suppose that
this memory contains the CPU’s startup program based at the beginning
of the memory.
reset_slave = “boot_rom/s1”;
reset_offset = “0x0”;
Altera Corporation 9
Nios 2.1 CPU Data Sheet
reset_offset Assignment
See “reset_slave Assignment” on page 9 for reset_offset assignment
information.
vecbase_slave Assignment
The Nios CPU logic is generated with a built-in vector-table base address.
The vector-table address is derived from two PTF assignments:
vecbase_slave and vecbase_offset. The vecbase_slave
assignment is used to extract a base address from the slave port of the
specified slave port on the specified module. The vebase_offset
assignment specifies a byte offset which is applied to the indicated
devices’s base address.
vecbase_slave = “general_purpose_ram/s1”;
vecbase_offset = “0xF00”;
vecbase_offset Assignment
See “vecbase_slave Assignment” on page 10.
10 Altera Corporation
Nios 2.1 CPU Data Sheet
support_interrupts Assignment
When the assignment support_interrupts = 0, the Nios CPU will
have neither irq nor irqnumber input signals on its Avalon bus master
interface and therefore cannot receive hardware interrupts. The CPU will
not generate internal exceptions for register-window underflows and
overflows. The results of executing a TRAP instruction is undefined.
implement_forward_b1
This assignment controls the CPU’s handling of certain types of pipeline-
data hazards. The CPU always hides all pipeline implementation details
from software, and behaves exactly as indicated in the Nios 32-Bit
Programmers’ Reference Manual and 16-Bit Programmer’s Reference Manual
regardless of this setting.
Most compiled code does not encounter this class of data hazard very
often. Performance on the Dhrystone benchmark (at a fixed clock
frequency) is improved by about three percent when
implement_forward_b1 = 1. When implement_forward_b1 = 0, the
CPU will stall for one clock-cycle when the b operand of an instruction
was modified by its immediate predecessor.
Altera Corporation 11
Nios 2.1 CPU Data Sheet
support_rlc_rrc Assignment
These instructions rotate a register right or left (respectively) by one bit
through the carry flag. These instructions are never used by the compiler.
Support for these instructions requires some dedicated logic (between 12-
21) that can usually be saved. When assignment support_rlc_rrc = 0,
the CPU does not support these instructions, and the behavior of both
RRC and RLC instructions is undefined. When assignment
support_rlc_rrc = 1, the CPU supports RLC and RRC instructions.
Use this setting if you have written any assembly-language software that
explicitly uses these instructions.
f See the complete Nios instruction set including the RRC and RLC
instructions in the Nios 32-Bit Programmer’s Reference Manual and Nios 16-
Bit Programmer’s Reference Manual.
germs_monitor_id Assignment
The Nios CPU is generated along with a custom SDK including libraries,
example programs, and utilities. One of the several programs generated
as part of the Nios SDK is a customized GERMS monitor (boot-monitor
program). The GERMS monitor prints a message at start up. The contents
of this message are taken from the CPU’s germs_monitor_id
assignment. It is often useful to set different id messages to display
different hardware revision levels of your system.
mainmem_slave Assignment
The Nios CPU is generated along with a custom SDK including libraries,
example programs, and utilities. C programs are, by default, compiled to
reside at a base address within the system’s designated main-memory
device. This PTF assignment is used to designate the memory device
where, by default, compiled programs will be located. The generated SDK
is aware of the vector table, and will set the base address of compiled
programs to avoid the vector-table if, for example, the vector table is
mapped at the beginning of the designated main memory device.
datamem_slave Assignment
The Nios CPU is generated along with a custom SDK including libraries,
example programs, and utilities. C programs are, by default, compiled
with their stack, heap (malloc data) and writable global variables within
the system’s designated data-memory device. This PTF assignment is
used to designate the memory device where, by default, compiled
programs’ writable data will be located. The generated SDK is aware of
the vector table, and will locate the stack and heap to avoid conflicts.
12 Altera Corporation
Nios 2.1 CPU Data Sheet
maincomm_slave Assignment
The Nios CPU is generated along with a custom SDK including libraries,
example programs, and utilities. Some libraries and utilities implicitly
make use of a standard output or console device, for example, the printf
library. The SDK uses a designated Avalon UART peripheral as the
default I/O device for many text input-output functions. The PTF
assignment maincomm_slave designates which UART is used by the
generated SDK for default text I/O.
debugcomm_slave Assignment
The Nios CPU is generated along with a custom SDK including libraries,
example programs, and utilities. One such utility is a resident GDB stub
which communicates with host debugging software over a designated
serial device (Avalon UART). The PTF assignment debugcomm_slave
designates which Avalon UART is used by the debug stub. It can be the
same UART as the maincomm_slave, but it is generally easier to debug
systems with separate debugcomm_slave and maincomm_slave
UARTs.
Altera Corporation 13
Nios 2.1 CPU Data Sheet
Copyright © 2002 Altera Corporation. All rights reserved. Altera, The Programmable Solutions Company, the
stylized Altera logo, specific device designations, and all other words and logos that are identified as
101 Innovation Drive trademarks and/or service marks are, unless noted otherwise, the trademarks and service marks of Altera
Corporation in the U.S. and other countries. All other product or service names are the property of their
San Jose, CA 95134 respective holders. Altera products are protected under numerous U.S. and foreign patents and pending
(408) 544-7000 applications, mask work rights, and copyrights. Altera warrants performance of its
http://www.altera.com semiconductor products to current specifications in accordance with Altera’s standard
warranty, but reserves the right to make changes to any products and services at any time
Applications Hotline: without notice. Altera assumes no responsibility or liability arising out of the application
(800) 800-EPLD or use of any information, product, or service described herein except as expressly agreed
Literature Services: to in writing by Altera Corporation. Altera customers are advised to obtain the latest
version of device specifications before relying on any published information and before
[email protected] placing orders for products or services.
14 Altera Corporation