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

HDL Coder

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.

Best Answer

  • 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.