0% found this document useful (0 votes)
44 views13 pages

Nios Interrupts

The document discusses NIOS interrupts and the HAL framework for handling interrupts in a NIOS system. It describes the internal and external interrupt controllers, exception handling, and functions for registering and managing interrupts.

Uploaded by

cointoin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views13 pages

Nios Interrupts

The document discusses NIOS interrupts and the HAL framework for handling interrupts in a NIOS system. It describes the internal and external interrupt controllers, exception handling, and functions for registering and managing interrupts.

Uploaded by

cointoin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

NIOS Interrupts

Last updated 8/20/20


NIOS Interrupts

These slides describe the interrupt controllers for the


NIOS system

Upon completion: You should be able to implement


an interrupt controller in a NIOS system

EE 3921 2 © tj
NIOS Interrupts
• HAL Framework – Interrupts

• 2 Options for dealing with interrupts

• Internal Interrupt Controller – IIC


• External Interrupt Controller - EIC

• The IIC has two versions


• Legacy API
• Enhanced API

EE 3921 3 © tj
NIOS Interrupts
• HAL Framework – Interrupts

• On an interrupt or exception the processor


• Saves the current status
• Disables HW interrupts
• Saves the next execution address (Program Counter)
• Transfers control to the exception handler

• What about all the registers?


• NIOS supports shadow registers
• Removes the need to save the registers to the stack

EE 3921 4 © tj
NIOS Interrupts
• HAL Framework – Interrupts

• Support for 32 interrupt signals


• Interrupt # indicates inverse priority**

• We set these in QSYS

** Managed by the HAL SW


EE 3921 5 © tj
NIOS Interrupts
• HAL Framework – Interrupts

• The HAL Internal Interrupt framework uses a single


exception controller

• We set the address for the “exception handler” when we instantiate


the NIOS II processor

EE 3921 6 © tj
NIOS Interrupts
• HAL Framework – Interrupts

• The single Exception handler

• Handles exceptions and interrupts

• Exception handler keeps a table of ISR priorities

• To be included in the table – we must “register” the IRQ


of each module

EE 3921 7 © tj
NIOS Interrupts
• HAL Framework – Interrupts

• Enhanced Exception Handler Functions


• ALT_ENHANCED_INTERRUPT_API_PRESENT in system.h

alt_ic_isr_register()
alt_ic_irq_disable()
alt_ic_irq_enable()
alt_irq_disable_all()
alt_irq_enable_all()
alt_ic_irq_enabled()

EE 3921 8 © tj
NIOS Interrupts
• HAL Framework – Interrupts

• Legacy Exception Handler Functions


• ALT_LEGACY_INTERRUPT_API_PRESENT in system.h

alt_irq_register() alt_irq_interruptible()
alt_irq_disable() alt_irq_non_interruptible()
alt_irq_enable() alt_ic_irq_enabled()
alt_irq_disable_all()
alt_irq_enable_all()

EE 3921 9 © tj
NIOS Interrupts
• HAL Framework – Interrupts

• ISR register function - prototype


int alt_ic_isr_register(
alt_u32 ic_id, // interrupt controller ID
alt_u32 irq, // interrupt ID
alt_isr_func isr, // isr name
void * isr_context, // pointer to any passed context
void * flags // reserved - 0
);

EE 3921 10 © tj
NIOS Interrupts
• HAL Framework – Interrupts
• Register prototype
interrupt controller ID – not used with IIC - 0
interrupt ID – from system.h
isr name – your choice
pointer to any passed context – e.g PIO input value
this can be any type → needs a “void” pointer

#define SW_PIO_HAS_IN 1
#define SW_PIO_HAS_OUT 0
#define SW_PIO_HAS_TRI 0
#define SW_PIO_IRQ 10
#define SW_PIO_IRQ_INTERRUPT_CONTROLLER_ID 0
#define SW_PIO_IRQ_TYPE "EDGE"
#define SW_PIO_NAME "/dev/sw_pio"
#define SW_PIO_RESET_VALUE 0
#define SW_PIO_SPAN 16
#define SW_PIO_TYPE "altera_avalon_pio"

EE 3921 11 © tj
NIOS Interrupts
• HAL Framework – Interrupts

• ISR prototype

void isr(void * context)

void pointers do not have a type


void pointers can point to any type
void pointers cannot be dereferenced
void pointers can be cast to any type
pointer arithmetic is not allowed with void pointers

EE 3921 12 © tj
NIOS Interrupts
• HAL Framework – process
int
Choose a name Create a global
foo
for ISR variable

Create a void * void *


pointer to the foo_ptr
global variable

Register the ISR – passing context


the context in via the
void * pointer
increment
Create an cast foo
appropriate type
pointer
int *
Cast the context void * my_ptr
ISR pointer to the appropriate
type pointer

Modify the appropriate (*my_ptr)++;


type pointer as usual

EE 3921 13 © tj

You might also like