Altera Nios II Custom User Manual
Page 12

1–8
Chapter 1: Nios II Custom Instruction Overview
Custom Instruction Types
Nios II Custom Instruction User Guide
January 2011
Altera Corporation
is a block diagram of an extended custom instruction with bit-swap,
byte-swap, and half-word swap operations.
The custom instruction in
performs swap operations on data received at
the
dataa
port. It uses the two-bit-wide
n
port to select the output from a multiplexer,
determining which result is presented to the
result
port.
1
This logic is just a simple example, using a multiplexer on the output. You can
implement function selection based on an index in any way that is appropriate for
your application.
Extended custom instructions can be combinational or multicycle custom
instructions. To implement an extended custom instruction, simply add an
n
port to
your custom instruction logic. The bit width of the
n
port is a function of the number
of operations the custom logic block can perform.
Extended custom instructions occupy multiple custom instruction indices. For
example, the custom instruction illustrated in
occupies 4 indices, because
n
is two bits wide. Therefore, when this instruction is implemented in a Nios II system,
256 - 4 = 252 available indices remain.
For information about the custom instruction index, refer to
Assembly Software Interface” on page 2–3
All extended custom instruction port operations are identical to those for the
combinational and multicycle custom instructions, with the exception of the
n
port,
which is not present in combinational and multicycle custom instructions. The
n
port
timing is the same as that of the
dataa
port. For example, for an extended variable
multicycle custom instruction, the processor presents the index value to the
n
port on
the same rising edge of the clock at which
start
is asserted, and the
n
port remains
stable during execution of the custom instruction.
Figure 1–7. Extended Custom Instruction with Swap Operations
dataa[31..0]
0
1
2
n[1..0]
result[31..0]
bit-swap
operation
byte-swap
operation
half-word-swap
operation
Custom
Instruction