Jump to content
Aaron Yang

Sensitive List

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.

Share this post


Link to post
Share on other sites

To be more concrete, I have another thread called fir_main and 

in_val = din.read();

In this example, I want to trigger fir_comb by adding the in_val(updated in the fir_main) to its sensitive list.

Share this post


Link to post
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();
};

 

Share this post


Link to post
Share on other sites
11 minutes ago, Roman Popov said:

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

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

Share this post


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

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×