Jump to content

Need help to implement an interrupt controller simulator which handles the ISR


Recommended Posts

I am on the implementation of an interrupt controller simulator, which will take signals from other rest of the HW modules in simulation and run the ISR.

Below is the systemC code roughly made to get the concept clear. In this case, we need ISR to be handled in a way that, even if the FW_main is stuck inside while(1) loop.

With the below implementation the context is inside FW_main loop only. Adding a wait in FW_main is not the one we want. We need the correct interrupt controller functionality. Any ideas to get rid of this problem? Please share your inputs. Thanks in advance.

 

SC_MODULE (processor)
{
    sc_in < bool > interrupt;

    void ISR(void)
    {
        cout << "i am in ISR\n";
    }
    
    void FW_main(void)
    {
        while(1)
        {
            cout << "i am in FW_main\n";
        }
    }
    
    SC_CTOR (processor) 
    {
        SC_METHOD(ISR);
        sensitive << interrupt;
        SC_THREAD(FW_main);
    }
    
};

Link to post
Share on other sites

In a cooperative multitasking environment (e.g. SystemC), it is impossible to have an infinite loop without yielding. The only yielding method available in SystemC threads is the wait() method; therefore, you have self-defined an impossible problem.

SystemC processes (SC_THREAD and SC_METHOD) are NOT the same concept as OS processes or threads. They are constructs of the discrete event driven simulator known as SystemC.

Now it is possible in some cases to trick the code, which I have used for some cases. For example, if your FW_main code where to attempt some I/O with a common method, then you could have that method call wait(). This works well when modeling an embedded system using an RTOS and you can modify one of the drivers minimally (i.e. to insert wait()).

Link to post
Share on other sites

Thanks for your response.

We need to simulate a processor in which the ISR will be invoked even though the FW code is in an infinite loop. Even if we call wait in FW_main, the correct functionality what an interrupt controller is capable of will not be achieved. So I may need to look for something else.

Link to post
Share on other sites

Hi David,

I am seeing an option for enabling posix pthread for the creation of SC_THREAD. What is your opinion on the same to get the context switch without a wait method?

Can you please reply with what all differences --enable-pthreads will make in SC_THREAD, SC_CTHREAD, SC_METHOD internal implementation.

Thank you,

Jomon

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...