How reliable is the fixed point conversion of the Matlab HDL coder?
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I am refering to the FPGA Turnkey workflow example: http://de.mathworks.com/help/hdlcoder/examples/getting-started-with-fpga-turnkey-workflow.html
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
0 个评论
回答(1 个)
Tim McBrayer
2015-10-15
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.
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!