MATLAB Answers

HDL Coder: Problems with saturation after a product block with divide

8 views (last 30 days)
Roland on 21 May 2013
I'm trying to fix my model so that it works with the HDL coder, but there is one thing i just cannot get working. I have a product block (*/), which divides the first input by the second input and after this product block is a saturation block which saturates it between -1 and 1.
When I check whether the HDL code can be generated it gives the following error:
"Error: Product block with divide input (/) only supports Saturation 'On'".
Should I remove the saturation block and force it to saturate with a matlab function file? Or what would be the best way to get this working?
Thanks in advance!
Kind Regards,

Accepted Answer

Tim McBrayer
Tim McBrayer on 21 May 2013
I don't think this has anything to do with your Saturation block. The issue lies with the Product block. As the message says, you need to enable saturation on the Product block. This is so the HDL implementation and the Simulink implementation have the same semantics. This saturation is to the data type of the Product block's output port and not to any particular numeric range.
If you need additional saturation to the range [-1, 1], then the following Saturation block is the way to go. Alternatively, if you update your Product block to have an output data type of fixdt(1, n, n-1) for a suitable value of n, you can avoid the separate Saturation block. Due to 2's complement numbers, his will limit the range to [-1, 1); the most positive value will never be able to reach 1.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!