Jump to content
Sign in to follow this  
zareie.ehsan

user defined data type signal assignment

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?

Share this post


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;

}

 

 

Share this post


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

Share this post


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

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
Sign in to follow this  

×