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

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

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...