In digital signal processing systems, data is represented in fixed-point in most cases. However, since DSP often uses multipliers, the bit width of the number after multiplying two fixed-point numbers will be the sum of the bit widths of the two operands. For example, A*B, the bit width of A is (1,7,4), and the bit width of B is (1,9,5). The result after multiplication will become (1,16,9), and the data bit width of the multiplication result has reached 16 bits. If this result needs to be multiplied again in the future, the bit width will be expanded. The resources occupied by the multiplier basically account for a large proportion in the digital signal processing system. The larger the bit width of the multiplier, the more partial products there are, and the more levels of the addition tree, which directly affects the Fmax (timing) and resources of the system. Therefore, in the actual fixed-point simulation stage, the algorithm design will comprehensively consider the system performance (because truncation of data will affect system performance and accuracy) and implementation resources, and perform rounding or saturation on the multiplication results at certain times. So how does rounding work? For example, there is a number, and the result after multiplication is represented as (1,16,12), that is, the first 0 to 11 bits are decimal places, the 12 to 14 bits are integer places, and the 15th bit is the sign bit. If you want to round the number to (1,10,7), that is, only 10 bits are used to represent it, the 0 to 6 bits are decimal places, the 7 to 8 bits are integer places, and the 9th bit is the highest bit. What is the rounding rule at this time? Taking the above example, assuming A = 1010'1011'1111'1111, then when truncating, the 0 to 4 bits are truncated, and the 4th bit is 1, so a carry is required when truncating, that is, B = 101'0101'1111 + 1'b1. There is a problem that needs to be noted at this time. Since 4 rounding is required after truncation, a carry is required, so in fact the bit width of B needs to be expanded by one bit. Since A is a signed number, it needs to be extended according to the sign bit when truncating and rounding, that is, the bit should be expanded to the original sign bit. Take the above example B = 1101'0110'0000. At this time, the bit width of B is 12 bits, but our goal is to round the number to 10 bits. So what should we do next? In fact, our decimal places are already 7 bits, and we cannot truncate them. At this time, we should perform saturation on the integer bits: that is, if it is greater than the maximum number that can be expressed, make it the maximum number, and if it is less than the minimum number that can be expressed, make it the minimum number. Taking B as an example again, since our goal is to change B to (1,10,7), and B is (1,12,7) at this time, there are two more integer bits, so the integer bits need to be truncated. If B(1,12,7) exceeds 1'1111'1111 or is less than 100'000'0000, then it is all represented as 01'1111'1111 or 100'000'0000. This is a saturation operation. There is a little trick when doing a saturation operation, that is, compare the extended sign bit of B(1,12,7) with the 11th and 10th bits (the sign bit of the rounding target number). If they are the same value, that is, both are 0 or both are 1, then just intercept the 11th and 12th bits, because there is no carry in the rounding. If they are different, it means that a carry has occurred. At this time, according to whether the highest bit is 0 or 1, the target number after rounding should be changed to 01'1111'1111 or 100'000'0000. In the above example, the values from the 12th to the 10th bits are different, so we know that a 10-digit number cannot express the number, so we can only choose saturation, and the saturated value is 10'0000'0000.