Jump to content
Sign in to follow this  
bennymao

sc_wrap in SystemC

Recommended Posts

sc_fixed<5,5> sx;
sc_fixed<4,4,SC_TRN,SC_WRAP> sy0;
sc_fixed<4,4,SC_TRN,SC_WRAP,1> sy1;
sc_fixed<4,4,SC_TRN,SC_WRAP,2> sy2;
sc_fixed<4,4,SC_TRN,SC_WRAP,3> sy3;

 

The simulation results are as below.

 

sx = 9;    //sx   = 0b01001
sy0 = sx; //sy0 = 0b1001
sy1 = sx; //sy1 = 0b0001
sy2 = sx; //sy2 = 0b0101
sy3 = sx; //sy3 = 0b0111

 

sx = -5;   //sx   = 0b11011
sy0 = sx; //sy0 = 0b1011
sy1 = sx; //sy1 = 0b1011
sy2 = sx; //sy2 = 0b1011

sy3 = sx; //sy3 = 0b1011 //The definition in IEEE Std 1666™-2011 is "SC_WRAP, (n_bits>1)                         The result number shall get the sign bit of the original number. The saturated bits shall get the inverse value of the sign bit of the original number. The remaining bits shall be copied from the original number". So it seems the result should be sy3=0b1001.Can anybody tell me why the result is 0b1011? Thanks in advance. 

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  

×