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.

immediate operand. The interrupt number for an I/O interrupt is provided through a 6-bit input<br />

signal. In most systems, the automatically generated Avalon bus provides this functionality, so<br />

the I/O devices need to provide only a single output for an interrupt request. Interrupt priorities<br />

are defined by exception numbers: the lowest exception number has the highest priority.<br />

Internal exceptions can only occur as a result of executing SAVE and RESTORE instructions.<br />

If the SAVE instruction is executed while the lowest valid register window is in use<br />

(CWP = LO_LIMIT), a register window underflow exception occurs. Register window overflow<br />

exception, on the other hand, happens when the highest valid register window is in use<br />

(CWP = HI_LIMIT), and the RESTORE instruction is executed. Register window underflow and<br />

overflow exceptions have exception numbers 1 and 2, respectively. These exceptions ensure that<br />

the data in the register window is not overwritten due to the underflow or overflow of the CWP<br />

value. Register window underflow/overflow exceptions can be handled in two ways: the user<br />

application can terminate with an error message, or the code that virtualizes the register file<br />

(CWP Manager) can be executed. The CWP Manager stores the contents of the register file to<br />

memory on the window underflow, and restores the values from the memory on the window<br />

overflow exception. The CWP Manager is included in the Nios <strong>Soft</strong>ware Development Kit (SDK)<br />

library by default. Only SAVE and RESTORE instructions can cause register window<br />

underflow/overflow exceptions. Modifying the CWP field using the WRCTL instruction cannot<br />

cause exceptions.<br />

All interrupts, except the interrupt number 0 and software interrupts, are handled equivalently.<br />

First of all, an interrupt is only processed if interrupts are enabled (IE bit in the status register is<br />

set), and the interrupt priority is higher than the current interrupt priority (interrupt number is less<br />

than the IPRI field in the status register). Interrupt processing is performed in several steps. First,<br />

the STATUS control register is copied into the ISTATUS register. Next, the IE bit in the<br />

STATUS register is set to 0, CWP is decremented (opening a new register window), and the IPRI<br />

field is set to the interrupt number of the interrupt being processed. At the same time, the return<br />

address is stored in general-purpose register %o7. The return address is the address of the<br />

instruction that would have executed if the interrupt had not occurred. Finally, the address of the<br />

interrupt handling routine is fetched from the corresponding entry in the vector table, and the<br />

control is transferred to that address. Interrupt handling routines can use registers in the newly<br />

opened window, which reduces the interrupt handling latency because the handler routine does<br />

not need to save any registers. The only interrupt that does not open a new window is the register<br />

window overflow exception. The CWP value remains at HI_LIMIT when the register window<br />

overflow exception occurs. This is acceptable, because the program will either terminate or the<br />

20

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

Saved successfully!

Ooh no, something went wrong!