Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

DE0-Nano-SoC: How HPS(ARM) recognizes f2h_irq0 or f2h_irq1 interrupts from FPGA

I designed a block in Verilog. When data processing is finished, this FPGA block sends an interrupt signal to HPS using one of dedicated interrupt line: f2h_irq0 or f2h_irq1. The question is how HPS can recognize that this interrupt is active? Could anybody give an example of C code where HPS reads the interrupt (or decode interrupt vector) from FPGA?

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Nachodizz990,

    Thanks for information. My QSYS system looks as follows:

    Apart of standard blocks like:

    -Cyclone V Hard Processor System

    -JTAG to Avalon Master Bridge

    -JTAG UART (connected to f2h_irq0)

    -System ID Peripherial

    -PIO (Parallel I/O – pio_led),

    I have the following own blocks in QSYS:

    -SPI Master (Altera’s 3 Wire Serial)

    -SPI Slave (Altera’s 3 Wire Serial)

    -My_counter (modulo 32 bits)

    -Merlin IRQ Fanaout (Altera’s IP)

    Merlin IRQ’s Senders are connected to Cyclone_V_Hard_Processor_System’s f2h_irq1 (irq Number=2), and to the LED (to let me see when interrupt is active). Merlin IRQ’s Receiver is supplied by My_counter’s overflow flag. The idea is that after power up the 32-bit counter counts up to maximum and an overflow flag is output to the LED and f2h_irq1.

    The second source of interrupts, connected to Cyclone_V_Hard_Processor_System’s f2h_irq1 consists of two blocks:

    - SPI Master (irq Number=1) and

    - SPI Slave (irq Number=0)

    Their ports are assigned to FPGA’s GPIOs and the wired on the board level in the way that SPI Master will send the data to SPI Slave and SPI Slave hopefully generates an interrupt.

    Whole design was synthesized, and FPGA was programmed successfully by soc_system.sof. I copied soc_system.sopcinfo to Nios Eds Shell folder. Then, in the Nios Eds Shell, I ran sopc-create-header-files command.

    I noticed that the following header files were been generated:

    -fpga_only_master.h

    -hps_0.h

    -hps_0_arm_a9_0.h

    -hps_0_arm_a9_1.h

    -hps_0_bridges.h

    -hps_only_master.h

    -soc_system.h

    I replaced all original header files, in the given example HPS_FPGA_DIPSW_LED/headers, by above newly generated files. However, when I compile main.c, I get the following:

    make all

    arm-linux-gnueabihf-gcc -g -Wall -IC:/altera/15.1/embedded/ip/altera/hps/altera_hps/hwlib/include -Dsoc_cv_av -Dsoc_cv -c main.c -o main.o

    main.c: In function 'main':

    main.c:52:79: error: 'DIPSWITCH_BASE' undeclared (first use in this function)

    DIPSWITCH_address=virtual_base + ( ( unsigned long )( ALT_LWFPGASLVS_OFST + DIPSWITCH_BASE ) & ( unsigned long)( HW_REGS_MASK ) );

    ^

    main.c:52:79: note: each undeclared identifier is reported only once for each function it appears in

    main.c:54:73: error: 'LED_BASE' undeclared (first use in this function)

    LED_address=virtual_base + ( ( unsigned long )( ALT_LWFPGASLVS_OFST + LED_BASE ) & ( unsigned long)( HW_REGS_MASK ) );

    ^

    make: *** [main.o] Error 1

    As I guess, the reason is that I don’t use DIPSWITCH_BASE and LED_BASE in my system any more. In main.c, I should replace them by SPI_MASTER_BASE or SPI_SLAVE_BASE found in hps_0.h.

    However, in hps_0.h, I cannot find any Macros for Merlin IRQ Fanout, which suppose to pass the IRQ from My_counter to f2h_irq1 (irq Number=2). Why? Because they don’t have any bus with address space like SPI master and Slave?

    How can I get info that there is an interrupt from f2h_irq1 (irq Number=2) (My_Counter's overflow flag)?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Nachodizz990,

    Finnally, On the ARM console, I successfully got received IRQ from counter implemented in Verilog. I assigned counter's overflow flag (source of IRQ) to PIO. In addtition, I assigned this flag to LED. In C, I have a while loop printing PIO IRQ value on the console. When on the console, displayed PIO's IRQ value changes from 0x0 to 0x1, on the board I see that LED is ON.

    Thank you very much for your support:)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Can you put that project back up? It's exactly what I'm looking for. Thanks in advance.

    --- Quote Start ---

    -Hei sebar, download your ds5 example from here, and follow the instructions,

    place the folder into your DS5 workspace, open ds5 and import the project.

    - Watch the project configurations, makefile etc ...

    - Make some stupid change into the main.c such as adding a comment and then build all, you must not see any error, warning or file missing.

    - If any error occurs you can ask to me for see what it happens.

    https://www.sendspace.com/file/okshc0

    --- Quote End ---

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi there,

    Can you put that project back up? The link has expired. It seems to be exactly what I'm looking for.

    Thanks