17.11.2012 Views

Soft-Core Processor Design - CiteSeer

Soft-Core Processor Design - CiteSeer

Soft-Core Processor Design - CiteSeer

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

instruction is immediately preceded by the PFX instruction, the K register is used to form a 16-bit<br />

immediate operand. Otherwise, a 5-bit immediate operand is used. This is referred to as the<br />

5/16-bit immediate addressing mode. The K register value is also used as the only immediate<br />

operand by some instructions. Other instructions use immediate operands of various lengths<br />

specified as a part of the instruction word. Logic instructions AND, ANDN, OR and XOR use<br />

either register or 16-bit immediate addressing mode, depending on whether the instruction is<br />

preceded by the PFX instruction or not. If the instruction is preceded by the PFX instruction, the<br />

5-bit immediate value is used to form a 16-bit immediate operand. Otherwise, the same 5 bits are<br />

used as a register address. Register indirect and register indirect with offset addressing modes are<br />

used for memory accesses. All load instructions read a word (or halfword for 16-bit Nios) from<br />

memory. Special store instructions allow writing a partial word into memory. Relative addressing<br />

mode is used by branch instructions for target address calculation.<br />

In addition to the addressing modes already mentioned, some instructions also use implicit<br />

operands, like %fp and %sp. The term stack addressing mode is sometimes used for instructions<br />

that use %sp as an implicit operand. Similarly, the term pointer addressing mode is used for<br />

instructions that use one of the registers %L0 to %L3 as a base register. The pointer addressing<br />

mode requires fewer bits in the instruction word for register addressing, since only 4 registers can<br />

be used. In the stack addressing mode, the implicit operand (%sp) is encoded in the OP code.<br />

Control-flow instructions include unconditional branches, jumps, and trap instructions; and<br />

conditional skip instructions. Branches and jumps have delay slot behaviour. The instruction<br />

immediately following a branch or a jump is said to be in the delay slot, and is executed before<br />

the target instruction of the branch. The PFX instruction and the control-flow instructions are not<br />

allowed in the delay slot of another control-flow instruction.<br />

Instructions BR and BSR are unconditional branch instructions. The target address is<br />

calculated relative to the current PC. An 11-bit immediate operand is used as the offset. The<br />

offset is given as a signed number of halfwords, and is therefore limited to the memory window<br />

of 4 KB. The BSR instruction is similar to the BR instruction, but it also saves the return address<br />

in register %o7. The return address is the address of the second instruction after the branch,<br />

because the instruction in the delay slot is executed prior to branching. Jump instructions JMP<br />

and CALL are similar to BR and BSR, respectively, except that the target address is specified in a<br />

general-purpose register. Instructions TRAP and TRET are used for trap and interrupt handling,<br />

and do not have the delay slot behaviour.<br />

Conditional execution in the Nios architecture is done by using one of five conditional skip<br />

instructions. A conditional skip instruction tests the specified condition, and if the condition is<br />

16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!