Jump to content

user defined data type signal assignment


zareie.ehsan

Recommended Posts

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?
Link to post
Share on other sites

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

Link to post
Share on other sites
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

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...