Soft-Core Processor Design - CiteSeer
Soft-Core Processor Design - CiteSeer
Soft-Core Processor Design - CiteSeer
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
4.1.4. Operand Handler<br />
Various instruction formats in the Nios instruction set use various operand types. While some<br />
instructions use only register file operands, others also use immediate operands of different sizes.<br />
Depending on the instruction type, the immediate operands are formed by sign-extending,<br />
multiplying by a constant, or concatenating the immediate value encoded in the instruction word<br />
to the value in the K register. The immediate operands can be handled properly only after both the<br />
type of the instruction and the value in the K register are known. The value in the K register is set<br />
when the PFX instruction is in the operand stage of the pipeline. The value set by the PFX<br />
instruction becomes available in the cycle in which the instruction following PFX reaches the<br />
operand stage, and is used to form the immediate operands for that instruction.<br />
After the value of the immediate operand has been calculated, the correct operand can be<br />
selected, depending on the type of the instruction. Some instructions use both register operands,<br />
and some use one of the register operands and the immediate value. TRAP instruction uses a base<br />
address of the vector table, which is a constant, and an immediate operand to calculate the address<br />
of the vector table entry.<br />
Pre-calculating and selecting the operands prior to the execute stage simplifies the design of<br />
the ALU. For instance, the BGEN instruction generates a power of 2 specified by the immediate<br />
operand (2 IMM ). BGEN may be implemented in the ALU as a separate operation. However, it can<br />
also be implemented using a shifter if the first operand is the constant 1 and the second operand is<br />
the immediate operand. Similarly, the 2’s complement operation (NEG instruction) may be<br />
performed by subtracting the number to be complemented from 0. The same result may be used<br />
by the ABS instruction calculating the absolute value if the input value is negative. Simplifying<br />
the ALU in this way is important because the ALU is a part of the critical path in UT Nios.<br />
Besides operand handling and setting the K register value, branching is also performed in the<br />
operand pipeline stage.<br />
4.1.5. Branch Unit<br />
The UT Nios branch unit maintains the correct value of the program counter (PC), used to<br />
calculate the return address for CALL, BSR, and TRAP instructions. The return address is offset<br />
by 2 or 4 from the actual PC value, depending on whether or not the control-flow instruction has<br />
the delay slot behaviour. The return address is forwarded to the execute stage through the pipeline<br />
registers, where it is stored in the appropriate register in the register file.<br />
The PC is updated to the new value in a cycle in which a control-flow instruction is in the<br />
operand stage. In the same cycle the new value is forwarded to the prefetch unit to update the<br />
38