220.127.116.11. Output Data Types on Primitive Blocks
For example, a Mult block with both input data types specified as sfix16_En15 naturally has an output type of sfix32_En30. The specified output data type has two fewer fractional bits than the natural input data type. Therefore, if you specify the output data type as sfix32_En28, the output numerical value is effectively multiplied by four, and a 1*1 input gives an output value of 4.
If you specify output data type of sfix32_En31, the output numerical value is effectively divided by two and a 1*1 input gives an output value of 0.5.
If you want to change the data type format in a way that preserves the numerical value, use a Convert block, which adds the corresponding hardware. Adding a Convert block directly after a Primitive library block allows you to specify the data type in a way that preserves the numerical value. For example, a Mult block followed by a Convert block, with input values 1*1 always gives output value 1.
To reinterpret the bit pattern and also discard bits, if the type you specify with the Output data type is smaller than the natural (inherited) output type, DSP Builder discards the MSBs (most significant bits).
Never set Specify via dialog to be bigger than the natural (inherited) bit pattern—DSP Builder performs no zero-padding or sign extension, and the result may generate hardware errors due to signal width mismatches. Use the Convert block for any sign extension or zero padding.
If you want to use sign extends and zero pads to reinterpret the bit pattern, you can combine these methods.
To set a specific format so that DSP Builder can resolve types, for example, in feedback loops, set Specify via dialog on an existing Primitive library block or insert a zero-cycle sample delay (which generates no hardware and just casts the type interpretation).
To ensure the data type is equal to some other signal data type, force the data type propagation with a Simulink data type propagation block.