Download Version 2.0 User's Guide - Computer Science and Engineering
Transcript
SC_WRAP_SM, n_bits = 1 urated bits are xor-ed with the original value of the least significant saturated bit and the inverse value of the original sign bit. SC_WRAP_SM, n_bits = 3 Examples For this example the original number is a 9 bit number and the result will be 5 bits. Parameter n_bits is equal to 3. This will cause the first 3 MSBs of the new value to be saturated to MAX or MIN. Here’s the starting value. sc_ufixed<9,9> x; sc_ufixed<5,5,SC_TRN,SC_WRAP_SM,3> y; x = 234; y = x; // overflow processing occurs here 011101010 (234) This value is first truncated to 5 bits. 01010 (10) The original sign bit (0) is copied to the MSB of the new value. Next bits 4, 3, and 2 are converted to MAX because n_bits is equal to 3. The sign bit is not saturated to 1, because the sign does not change in this mode. 01110 (14) The original value of the bit at position 2 (starting with 0 at right) was 0. The remaining bits at the LSB side (10) are xor-ed with this value and the inverse value of the original sign bit (01). The final result is shown below. 01101 (13) SC_WRAP_SM, n_bits = 1 This overflow mode behaves similarly to the mode where n_bits equals 0 except that positive numbers stay positive and negative number stay negative. The first bit on the MSB side of the new value will receive the sign bit of the original value. The other bits are copied and xor-ed with the original and the new value of the result sign bit. This behavior is shown in the graph below: SystemC 2.0 User’s Guide 135