DSP Builder for Intel® FPGAs (Advanced Blockset): Handbook

ID 683337
Date 3/23/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

12.1.12. Scale

The Scale block selects part of a wide input word, performs various types of rounding, saturation and fixed-point scaling, and produces an output of specified precision.

By default, DSP Builder preserves the binary point so that the fixed-point interpretation of the result has the same value, subject to rounding, as the fixed-point interpretation of the input.

You can dynamically perform additional scaling, by specifying a variable number of bits to shift, allowing you to introduce any power of two gain.

Note: Always use Scale blocks to change data types in preference to Convert blocks, because they vectorize and automatically balance the delays with the corresponding valid and channel signals.

The Scale block provides scaling in addition to rounding and saturation to help you manage bit growth. The basic functional modules of a Scale block are shifts followed by rounding and saturation. The multiplication factor (default is 1) is a constant scale to apply to the input.

The number of bits to shift left allows you to select the most meaningful bits of a wide word, and discard unused MSBs. You can specify the number of shifts as a scalar or a vector. The block relies on shift input port to decide which value to use if you specified the number of shifts as a vector. The shift input signal selects which gain to use cycle-by-cycle.

In a multichannel design, changing the shift value cycle-by-cycle allows you to use a different scaling factor for different channels.

A positive number of Number of bits to shift left indicates that the MSBs are discarded, and the Scale block introduces a gain to the input. A negative number means that zeros (or 1 in the signed data case) are padded to the MSBs of the input data signal, and the output signal is attenuated.

Table 55.  Parameters for the Scale Block
Parameter Description
Output data type The type of the result. For example: sfix(16), uint(8).
Output scaling value The scaling of the result if the result type is fixed-point. For example: 2^-15.
Rounding method Specifies one of the following three rounding methods for discarding the least significant bits (LSBs):
  • Truncate: truncates the least significant bits. Has the lowest hardware usage, but introduces the worst bias.
  • Biased: rounds up if the discarded bits are 0.5 or above.
  • Unbiased: rounds up if the discarded bits are greater than 0.5, and rounds to even if the discarded bits equal 0.5.
Multiplication factor Modify the interpreted value by scaling it by this factor. This factor does not affect the hardware generated for the Scale block, but merely affects the interpretation of the result. For example: 1, 2, 3, 4, 8, 0.5.
Saturation method Specifies one of the following three saturation methods for discarding the most significant bits (MSBs):
  • None: no saturation is performed.
  • Asymmetric: the range of the number produced occupies the whole of the two's complement range (for example –1.0 to 0.999). One more negative number is available, which introduces a slight bias.
  • Symmetric: the range of the result is clipped to between symmetrical boundaries (for example -0.999 and 0.999), whichensure that no bias enters the dataflow.
Number of bits to shift left A scalar or a vector that determines the gain of the result. A positive number indicates that the scale block introduces a gain to the input. A negative number means that the output signal is attenuated. A vector of gains allows the shift input signal to select which gain to use on a cycle per cycle basis. The value of the shift input performs zero-based indexing of the vector.
Table 56.  Port Interface for the Scale Block
Signal Direction Description
a Input The fixed-point data input to the block. If you request more channels than can fit onto a single bus, this signal is a vector. The width in bits is inherited from the input wire.
a_v Input Indicates the validity of the data input signals. If a_v is high, the data on the a wire is valid.
a_chan Input Indicates the channel of the data input signals. If a_v is high, a_chan indicates to which channel the data corresponds.
shift Input Indicates which element of the zero-based shift vector to use.
q Output The scaled fixed-point data output from the block. If you request more channels than can fit onto a single bus, this signal is a vector. The width in bits is calculated as a function of the input width in bits and the parameterization.
q_v Output Indicates the validity of the data output signals.
q_chan Output Indicates the channel of the data output signals.
q_exp Output Indicates whether the output sample has saturated or overflowed.

After you run a simulation, DSP Builder updates the help pages with specific information about each instance of a block.

Table 57.  Messages for the Scale Block
Message Example Description
Written on Tue Feb 19 11:25:27 2008 Date and time when this file ran.
Number of physical buses: 4 Depending on the input data rate, the number of data wires needed to carry the input data may be more than 1.
Calculated bit width of output stage: 16 The width in bits of the (vectorized) data output.
Latency is 2 The latency introduced by this block.
Parameters table Lists the current rounding and saturation modes.
Port interface table Lists the port interfaces to the Scale block.