Embedded Target for Texas Instruments C6000 DSPs    

Q Format Notation

The position of the binary point in a fixed-point number determines how you interpret the scaling of the number. When it performs basic arithmetic such as addition or subtraction, hardware uses the same logic circuits regardless of the value of the scale factor. In essence, the logic circuits have no knowledge of a binary point. They perform signed or unsigned integer arithmetic--as if the binary point is to the right of b0. Therefore, you, the programmer, determine the binary point.

In the the C62x DSP Library, the position of the binary point in the signed, fixed-point data types is expressed in and designated by Q format notation. This fixed-point notation takes the form

where

In Q format, the most significant bit is always designated as the sign bit. Representing a signed fixed-point data type in Q format always requires m+n+1 bits to account for the sign.

Example--Q.15

For example, a signed 16-bit number with n = 15 bits to the right of the binary point is expressed as

in this notation. This is (1 sign bit) + (m = 0 integer bits) + (n = 15 fractional bits) = 16 bits total in the data type. In Q format notation the m = 0 is often implied, as in

In the Fixed-Point Blockset, this data type is expressed as

or

In the Filter Design Toolbox, this data type is expressed as

Example--Q1.30

Multiplying two Q.15 numbers yields a product that is a signed 32-bit data type with n = 30 bits to the right of the binary point. One bit is the designated sign bit, thereby forcing m to be 1:

m+n+1 = 1+30+1 = 32 bits total

Therefore this number is expressed as

In the Fixed-Point Blockset, this data type is expressed as

In the Filter Design Toolbox, this data type is expressed as

Example--Q-2.17

Consider a signed 16-bit number with a scaling of 2(-17). This requires n = 17 bits to the right of the binary point, meaning that the most significant bit is a sign-extended bit.

Sign extension fills additional bits with the value of the MSB. For example, consider a 4-bit two's complement number 1011. When this number is extended to 7 bits with sign extension, the number becomes 1111101 and the value of the number remains the same.

One bit is the designated sign bit, forcing m to be -2:

Therefore this number is expressed as

In the Fixed-Point Blockset, this data type is expressed as

In the Filter Design Toolbox, this data type is expressed as

Example--Q17.-2

Consider a signed 16-bit number with a scaling of 2^(2) or 4. This means that the binary point is implied to be 2 bits to the right of the 16 bits, or that there are n = -2 bits to the right of the binary point. One bit must be the sign bit, thereby forcing m to be 17:

Therefore this number is expressed as

In the Fixed-Point Blockset, this data type is expressed as

In the Filter Design Toolbox, this data type is expressed as


  Signed Fixed-Point Numbers Building Models