Jump to content

sc_wrap in SystemC


bennymao

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. 

Link to comment
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.

×
×
  • Create New...