Compiling fixedpt converted code into VHDL

1 view (last 30 days)
Anze Slosar
Anze Slosar on 22 Feb 2023
Commented: Anze Slosar on 22 Feb 2023
We have a matlab code that we compile into VHDL. We have a make file that did this programmatically using something like
codegen -float2fixed fixptcfg -config hdlcfg -args {...} function_name
Since we need more control over fixedpt conversion, we now first run the script made by
fixedPointConverter -tocode spectrometer -script fixpt_conversion
and then we directly compile the generated code with something like:
addpath('./codegen/spectrometer/fixpt')
codegen -config hdlcfg -args {int16(0),int16(0)} spectrometer_fixpt
I have three questions:
  1. Is this the right way to do it?
  2. How does it deal with test_bench? The supplied test_bench of course calls spectrometer, not spectrometer_fixpt. Would it automatically adapt it? Or do I need to manually create a version of test bench that calls spectrometer_fixpt?
  3. How can I compile a subroutine inside spectrometer_fixpt? spectrometer calls function, I want to compile them individually, without having to rerun fixpt converson manually for each of them. Is that possible?

Answers (1)

Kiran Kintali
Kiran Kintali on 22 Feb 2023
Generate HDL Code from MATLAB Code Using the Command Line Interface
This example shows how to use the HDL Coder™ command line interface to generate HDL code from MATLAB® code, including floating-point to fixed-point conversion and FPGA programming file generation.
  1 Comment
Anze Slosar
Anze Slosar on 22 Feb 2023
Following that example is how we did it earlier. But that seemed to have very little options to finetune fixed point conversion.
But now I see that configuation options for
fiaccel -float2fixed
are exactly the same object as for codegen, so I can just use addTypeSpecification to set some fixed points manually. Which is what I was kinda looking for, thanks.

Sign in to comment.

Categories

Find more on Code Generation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!