How reliable is the fixed point conversion of the Matlab HDL coder?

1 view (last 30 days)
Hello,
I am just wondering why i need that 27-bit Integer size for my frequency counter? [Quote] 3. Set the proposed type of the freqCounter variable to unsigned 27-bit integer by entering numerictype(0, 27, 0) in its 'Proposed Type' column [/Quote] At first I forgot to change that parameter in the workflow and the program was not working on the FPGA. Is this the normal case that I have to adjust the fixed point types by myself?
How can I shift out such fixed point conversion failure?
Best Regards,
Florian

Answers (1)

Tim McBrayer
Tim McBrayer on 15 Oct 2015
The float to fixed-point conversion in HDL Coder works by analyzing your design, using several different methods including simulation, to determine the range for each variable in your design. As such, the proposed types are only as good as the input data from your testbench. The proposed types will be able to store any values that can be computed by the code, given the ranges of the inputs, any explicit types, and so forth.
This capability does not mean that a suitable type for every variable can be computed for circumstances not covered by the testbench. Take look at freqCounter in the example code, and particularly all its uses. It is, as its name states, a counter. There is no indication in the code how high the counter might count.
The testbench only runs for 16 iterations, with two invocations of mlhdlc_turnkey_led_blinking per iteration, for a total of 32 invocations. Since freqCounter starts at 0 and is incremented 32 times, a type that can contain the range[0, 32] is proposed. Since this is far too small of a range for the set of blink rate values stored in the LookupTable function, the design does not function as expected. Once freqCounter is set to a data size large enough to count up to all values stored in LookupTable, the fixed-point converted design works as expected.
  1 Comment
Florian Volk
Florian Volk on 21 Oct 2015
Is there any need to change the proposed fixed point types if some are slightly red? I have got a SimMax of 999999.23 and the proposed type is 0,14,-6 for that variable.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!