Quantcast
Channel: SystemC Language Forum RSS Feed
Viewing all articles
Browse latest Browse all 595

sc_signal & Operator

$
0
0

Hi,

 

I want to pass a sc_signal (the reference of one) of any type to a class as a CTOR-argument. Since i found out, that the &-Operator of the class sc_signal<T> is overloaded, so i don't get the reference of an sc_signal<T> object but instead i get a reference to an Object of type T.

How am i supposed to pass an sc_signal<T> to a function or a class?

 

Example-Code:

#include <systemc.h>

template<typename T>
class TInput{
public:
	typedef sc_signal<T> &TMember;
	TInput(TMember member):member(member){}
	// some functions which use member
private:
	TMember 	member;
};

int sc_main(int argc, char** argv){
	sc_signal<sc_uint<12> >    signal1("signal1");
	TInput<sc_uint<12> >       input(signal1);       // here is the problem, because &signal1 does not return 
	return 0;                                        // its own reference but a const reference to its member
                                                         // so the compiler is telling me, that i want to call a function which does not exist
}

here is a link to sc_signal class of systemc lysium documentation http://www.iro.umontreal.ca/~lablasso/docs/SystemC2.0.1/html/classsc__signal.html

especially this function            operator const T & () const

 

its implementation (of sc_logic) can be found under following link: http://www.lysium.de/docs/systemc-2.2/docs/html/sc__signal_8h-source.html

00132     operator const T& () const
00133     { return read(); } 
00113     // read the current value
00114     virtual const T& read() const
00115     { return m_cur_val; }
00648     sc_dt::sc_logic   m_cur_val;         // current value of object.

I hope there is any solution to my problem and thanks in advance.


Viewing all articles
Browse latest Browse all 595

Trending Articles