When I fix inputs in the matlab testbench (for hdl code conversion) , is the hdl code generated based on those inputs only?

1 view (last 30 days)
I am converting a matlab code to hdl. For that I have to give a testbench and thus my input values become fixed. Suppose I have an AND gate as my matlab function and in the testbench I put one of the inputs as 0. Will the generated HDL Code have an AND gate or it will wipe off the logic based on the inputs.

Accepted Answer

Tim McBrayer
Tim McBrayer on 21 Jan 2014
HDL Coder will generate your DUT as stand-alone from the test bench. It will not fold the constant values from the testbench into the DUT. It will fold constants within your DUT as much as possible during the optimization process.
A testbench that provides constant inputs is not a best practice, particularly if you are using float to fixed-point conversion. F2F can use the range of supplied testbench values as data to determine the desired data types for the inputs. It will propagate the type data throughout the design as well. If your testbench does not cover the full range of values that you expect your hardware to be able to handle, HDL Coder cannot create HDL code that will accurately respond to the full desired range of inputs.
  2 Comments
Tim McBrayer
Tim McBrayer on 22 Jan 2014
The most obvious way is to call your function repeatedly in a loop. There is a lot of HDL Coder documentation that discusses this point. For a succinct discussion on creating a helpful testbench, see this answer.

Sign in to comment.

More Answers (0)

Categories

Find more on Code Generation in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!