zareie.ehsan Posted October 20, 2013 Report Share Posted October 20, 2013 I'm new to SystemC and I have problem with signal assignment. I defined a new data type "digit" : class digit { public: sc_uint<4> dt; ///////constructor///////// digit (sc_uint<4> d=0) { dt=d; } digit& operator =(const digit& d) { dt=d.dt; return(*this); } } here is the code I tried to assign a signal which is in digit type digit t1(3); sc_signal <digit> d1; d1.write(t1); I also tried d1=t1 (operator= is overloaded in class digit) but signal d1 does not take the value of t1 would you pleas help me? Annossyenudge 1 Quote Link to comment Share on other sites More sharing options...
apfitch Posted October 20, 2013 Report Share Posted October 20, 2013 How do you know the assignment is not working? When are you printing out the assigned value? Remember that you must wait at least a delta for a primitive channel to update. There's more about user defined types and sc_signal here http://www.doulos.com/knowhow/systemc/faq/#q1 regards Alan SiGa and Philipp A Hartmann 2 Quote Link to comment Share on other sites More sharing options...
zareie.ehsan Posted October 20, 2013 Author Report Share Posted October 20, 2013 when I debug the program using F10 line by line and check the value of the signals I found the value does not change after d1. write. also with this below main() value is 0; int sc_main(int argc,char* argv[]) { digit t1(8); sc_signal <digit> d1; d1.write(t1); cout<<"value:"<<d1<<endl; } Quote Link to comment Share on other sites More sharing options...
kocha Posted October 20, 2013 Report Share Posted October 20, 2013 Hi, zareie Is digit class have "ostream& operator << ( ostream& os, MyType const & v )" ? Quote Link to comment Share on other sites More sharing options...
zareie.ehsan Posted October 20, 2013 Author Report Share Posted October 20, 2013 yes it has operator<< Quote Link to comment Share on other sites More sharing options...
kocha Posted October 20, 2013 Report Share Posted October 20, 2013 Hi, zareie I have fixed the problem. Please try the following program. int sc_main(int argc,char* argv[]) { digit t1(8); sc_signal <digit> d1; d1.write(t1); sc_start(10, SC_NS); // <- add cout<<"value:"<<d1<<endl; } Best regards, Kocha Quote Link to comment Share on other sites More sharing options...
apfitch Posted October 20, 2013 Report Share Posted October 20, 2013 when I debug the program using F10 line by line and check the value of the signals I found the value does not change after d1. write. also with this below main() value is 0; int sc_main(int argc,char* argv[]) { digit t1(8); sc_signal <digit> d1; d1.write(t1); cout<<"value:"<<d1<<endl; } Hi Zarie, that's what I meant by "you must wait a delta". If no time passes, a primitive channel does not update. Kocha's solution will work (adding a call to sc_start - in fact even sc_start(SC_ZERO_TIME) should work. regards Alan SiGa 1 Quote Link to comment Share on other sites More sharing options...
zareie.ehsan Posted October 21, 2013 Author Report Share Posted October 21, 2013 thank you guys for your guide, it works Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.