ARM Technical Support Knowledge Articles

How do I generate interrupts using a SystemC component?

Applies to: Fast Models

Answer

Introduction

The purpose of this example is to demonstrate how interrupts can be generated using a component in SystemC.  For the sake of simplicity, this example uses a dummy component in SystemC that asserts the appropriate IRQ signal whenever the core writes to it.

The System

The example system contains:

  • A Cortex-A8 model (this can be substituted for any other ARM core model).

  • Instruction RAM (address 0x00000000-0x0FFFFFFF).

  • PVBus to AMBA-PV bridge.

  • AMBA-PV Signal to SG Signal bridge.

  • 2 exported ports to SystemC.

IRQ_Gen Component

The IRQ_Gen component has a single memory mapped register and 2 ports in total.  These ports are described below:The IRQ_Gen component has a single memory mapped register and 2 ports in total.  These ports are described below:

  • amba_pv_s : This is connected to the AMBAPV_OUT port of the EVS via a PVBus2AMBAPV bridge.amba_pv_s.

  • irq_signal : This port is responsible for asserting or de-asserting the IRQ signal. 

/* Module ports */
amba_pv::amba_pv_slave_socket<64> amba_pv_s;
amba_pv::signal_master_port<bool> irq_signal;

The component implements read, write, debug read and debug write access functions to allow access to its register. These can be invoked by the core to access the SystemC component's register. The write access function is used to modify the SystemC component's register's value. This in turn also drives the irq_signal port to high which in turn asserts the IRQ pin this is connected to. The code snippet below shows how the write access function is defined. The read access function clears the asserted irq_signal, thus, the IRQ handler in the application code reads the register in order to clear it. The component implements read, write, debug read and debug write access functions to allow access to its register. These can be invoked by the core to access the SystemC component's register. The write access function is used to modify the SystemC component's register's value. This in turn also drives the irq_signal port to high which in turn asserts the IRQ pin this is connected to. The code snippet below shows how the write access function is defined.

/*
 * Write access
 */
amba_pv::amba_pv_resp_t IRQ_Gen::write(int socket_id,
                                   const sc_dt::uint64 & addr,
                                   unsigned char * data,
                                   unsigned int size,
                                   const amba_pv::amba_pv_control * ctrl,
                                   unsigned char * strb,
                                   sc_core::sc_time & t) {
    switch (addr) {
        case REG_ADDR:
std::cout << "**DEBUG** " << name() << ": Received write request "
 << "at address: " << std::showbase << std::hex << "0x" 
 << addr << std::endl;

                        //Call scx_sync(0) to break quantum now
                        scx::scx_sync(0);
//Set IRQ signal High
irq_signal.set_state(true);
            break;

        default: 
            std::cout << "**ERROR** " << name() << ": received write request "
                      << "with input address out of range: " << std::showbase
                      << std::hex << addr << std::endl;
            return (amba_pv::AMBA_PV_SLVERR);
    }
    return (amba_pv::AMBA_PV_OKAY);
}

Example Application

An example application is provided as assembler within the 'app' folder. A build script is also provided to aid rebuilding of the image. The application configures a specific interrupt ID in the Interrupt Controller and then writes to the IRQ_Gen component’s register.An example application is provided as assembler within the 'app' folder. A build script is also provided to aid rebuilding of the image. The application configures a specific interrupt ID in the Interrupt Controller and then writes to the IRQ_Gen component’s register.

Running the example

  1. Build the example. For a debug build with VC2010, use:

        " nmake /f nMakefile  dbg_vc10_32 "

   2. Build the application in the apps folder using the provided batch file (build.bat).

   3. Launch the resulting executable via command line using the following command:

        " Platform.exe  -a  app\image.axf -S" 

Attachments: Sysc-IRQ-Gen.png , SystemC-IRQ_gen.zip

Article last edited on: 2013-03-19 16:08:18

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential