Jump to content

Bizarre error when doing wait(&event)


Recommended Posts

I'm new to systemC. My code needs to process some data after reading it from fifo. So I created sc_event tkn_in_fifo_data_written. However compiler produces this error message:

 

Quote

terminate called after throwing an instance of 'sc_core::sc_report'
  what():  Error: (E525) wait(n) is only valid for n > 0: n = 0
 

Can someone please tell me what's wrong? Also perhaps error message should say something else?

template <class T, class M>
class cmod_module: public sc_module {
public:
    sc_fifo_in< T > tkn_in_fifo;
    sc_fifo_out< M > tkn_out_fifo;
    sc_event tkn_in_fifo_data_written;
    int numTknsRcvd;
    int numTknsSent;
    BAYER_TYPE *bayer_444;

    //virtual void ingress(); //get tkn in
    void ingress()
    {
        T tkn;
        while(true) {
            
            while(! hasBufferSpace() )
            {
               // do something 
            }
            tkn_in_fifo.read(tkn);
            processRcvdTkn(tkn);
            numTknsRcvd++;
            cout << name() << " " << numTknsRcvd << " tkns receivedd!" << endl;
            tkn_in_fifo_data_written.notify();
            wait();
        }
    }

    void egress()
    {
        M tkn;
        cout << name() << " " << numTknsSent << " tkns sent!" << endl;
        while(true){
            while (! canSendTkn()) 
            {
                cout << "waiting!" <<endl;
                //wait(tkn_in_fifo.data_written_event());
                wait(tkn_in_fifo_data_written);
            }
            processTknToSend(tkn);
            tkn_out_fifo.write(tkn);
            numTknsSent++;
            cout << name() << " " << numTknsSent << " tkns sent!" << endl;
            wait();
        }
    }
    
    virtual bool hasBufferSpace() = 0;
    virtual bool canSendTkn() = 0;
    virtual void processRcvdTkn(T& tkn) = 0;
    virtual void processTknToSend(M& tkn) = 0;


};

 

Link to post
Share on other sites

The syntax wait(), which calls void sc_core::wait(void), assumes a static sensitivity list, but you have not setup a static sensitivity list that I can see.

Also, you are sending and immediate notification, which I somehow doubt you really grasp the implication thereof.

You need to learn about the fundamentals of the SystemC scheduler to get this working correctly.

Link to post
Share on other sites

 

1 hour ago, Philipp A Hartmann said:

I suggest to move to SystemC 2.3.3, if possible. (The error message indicates, that you seem to be using SystemC 2.3.1). Secondly, can you show the derived class of the fifo as well (including its constructor)?

I'm forced to use whatever systemC version that comes with latest VCS version(vcs_vP-2019.06-SP2). 

 

Here is healer file:

#include "systemc.h"
#include "tkn.h"
#include "cmod_utils.h"
#include <cmod_module.h>
// from Dierke model
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//#include "global.h"
//#include "ISP_Utils.h"
#include "ltm.h"
#include "ltm.HW_MOD_BA.h"
#define CTRL LTM_Ctrl<sc_uint<14>, sc_uint<13>, sc_uint<20>, sc_uint<20> >
#define TKN MDA3_tkn<sc_int<2>,unsigned int >

class ltm_func: public cmod_module<TKN, unsigned int > 
{
public:
    sc_fifo_in< CTRL> params_in_fifo;
    CTRL params;
    hdr_param hdr;
    unsigned int pxl_out;
    virtual bool hasBufferSpace();
    virtual bool canSendTkn();
    virtual void processRcvdTkn(TKN& tkn);
    virtual void processTknToSend(unsigned int& tkn);
    virtual void processParams();

    SC_CTOR(ltm_func)
    {
       numTknsRcvd=0;
       numTknsSent=0;
       SC_THREAD(ingress);
       dont_initialize();
       sensitive << tkn_in_fifo.data_written();
       SC_THREAD(egress);
       sensitive << tkn_in_fifo.data_written() << tkn_out_fifo.data_read();
       dont_initialize();
       //SC_THREAD(params);
       //sensitive << params_in_fifo.data_written();
    }
};

 

ltm_func.cpp

#include    "ltm_func.h"

bool ltm_func::hasBufferSpace()
{
    return true;
}

bool ltm_func::canSendTkn()
{
    return this->numTknsRcvd > this->numTknsSent;
}

void ltm_func::processRcvdTkn(TKN& tkn)
{
    unsigned int Y1;
    ltm_debug debug;
    cout << "result before is::: " << pxl_out << endl;
    LTM_HW_func_BA(tkn.data, &hdr, &Y1, &pxl_out, &debug);
    cout << "result after is::: " << pxl_out << endl;

}

void ltm_func::processTknToSend(unsigned int& tkn)
{
    tkn = pxl_out;
}

void ltm_func::processParams()
{
        while(true){
            while (! canSendTkn()) 
            {
                wait(params_in_fifo.data_written_event());
            }
            params_in_fifo.read(params);
            wait();
        }    
}

 

Link to post
Share on other sites
2 hours ago, David Black said:

The syntax wait(), which calls void sc_core::wait(void), assumes a static sensitivity list, but you have not setup a static sensitivity list that I can see.

Also, you are sending and immediate notification, which I somehow doubt you really grasp the implication thereof.

You need to learn about the fundamentals of the SystemC scheduler to get this working correctly.

what you saw in first post is called pure virtual class. It's inherited by derived class where sensitivity list is supplied. 

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...