Jump to content

Sensitive List


Aaron Yang

Recommended Posts

Hey, question about the sensitive list, I got this error: 

fir.h:79:23: error: no match for 'operator<<' (operand types are 'sc_core::sc_sensitive' and 'sc_core::sc_vector<sc_dt::sc_fixed<16, 2> >::element_type {aka sc_dt::sc_fixed<16, 2>}')
             sensitive << in_val;

Here is the fir.h 

sc_vector<sc_fixed<din_size, din_int>> in_val{"in_val", din_num_samples};
void fir_comb();
SC_HAS_PROCESS(fir); // The combination of SC_HAS_PROCESS and a normal constructor replaces the use of SC_CTOR

    fir(sc_module_name name_, bool debug_ = false):
        sc_module(name_), debug(debug_)
        {
			SC_THREAD(fir_comb);
            for( unsigned i= 0; i<in_val.size(); ++i )
            sensitive << in_val[i];

Anything wrong with it?

Thank you in advance.

Link to comment
Share on other sites

31 minutes ago, Aaron Yang said:

fir.h:79:23: error: no match for 'operator<<' (operand types are 'sc_core::sc_sensitive' and 'sc_core::sc_vector<sc_dt::sc_fixed<16, 2> >::element_type {aka sc_dt::sc_fixed<16, 2>}')
             sensitive << in_val;

Compiler tells you exactly what is wrong. You can't make a process sensitive to a plain (non-channel) variable. Because plain variable has no value changed event.

Here is the list of overloads:

    sc_sensitive& operator << ( const sc_event& );
    sc_sensitive& operator << ( const sc_interface& );
    sc_sensitive& operator << ( const sc_port_base& );
    sc_sensitive& operator << ( sc_event_finder& );

So you can make process sensitive to event,  sc_interface and it's derived classes (sc_signal for example),  sc_port,  and sc_event_finder (this is what  sc_in<bool>::pos() returns).

Probably what you really want is sc_vector of signals? :

sc_vector<sc_signal<sc_fixed<din_size, din_int>>> in_val{"in_val", din_num_samples};

This will work.

Also making process sensitive to all elements in vector is such a common thing, so I recommend you to create a special overload for this case. For example:

template <typename T>
sc_sensitive& operator << ( sc_sensitive& sensitive, const sc_vector<T>& vec ) {
    for (auto & el : vec)
        sensitive << el;
    return sensitive;
}

struct dut : sc_module {
    sc_vector<sc_in<int>>  in_vector{"in_vector", N_PORTS};
    SC_CTOR(dut) {
        SC_METHOD(test_method);
        sensitive << in_vector;
    }
    void test_method();
};

 

Link to comment
Share on other sites

5 minutes ago, Aaron Yang said:

Thank you for the explanation, where should I put this overload? In the systemc.h? 

I usually have a project-wide header that includes systemc.h together with some utilities like this one. And then I include it everywhere instead of systemc.h. 

You should not modify systemc.h since it's a 3rd party code.

Link to comment
Share on other sites

Hello @Aaron Yang,

The sc_fixed is a datatype, which is evident from the error message you are getting:

sc_dt::sc_fixed<16, 2> 
   ^
   |
This denotes the sc_fixed is from the sc_datatype namespace.

As @Roman Popov has mentioned in his answer you cannot make the process sensitive to a non-channel variable.

Changing the line:

sc_vector<sc_fixed<din_size, din_int>> in_val{"in_val", din_num_samples};

To:

sc_vector<sc_signal<sc_fixed<din_size, din_int> > > in_val{"in_val", din_num_samples};
  
  // or this
// since it is not clear where the fir_main thread exists.
sc_vector<sc_in<sc_fixed<din_size, din_int> > > in_val{"in_val", din_num_samples};
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// For this you will need to bind it with sc_vector of sc_signals of the datatype
// sc_fixed< > type at the parent level module.

At the core of the implementation the SystemC sensitive only takes in only sc_events.

8 minutes ago, Aaron Yang said:

Thank you for the explanation, where should I put this overload? In the systemc.h? 

As for the overload it is better to create a utility header for development purposes which you can include in your project for development purposes.

Better not to disturb the systemc.h header file inadvertently making it unusable due to bad edits.

Hope this helps.

Regards,

Ameya Vikram Singh

 

Link to comment
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...