Verify Generated HLS Code Using MATLAB Desktop Host - MATLAB & Simulink (original) (raw)

Main Content

You can verify your generated HLS code by using the MATLAB® Desktop Host as the simulation tool. The verification ensures the generated HLS code for the DUT produces same results as the original MATLAB entry point for the same stimulus in the MATLAB test bench. Using MATLAB desktop host based MEX simulation eliminates the dependency on third-party EDA simulation tools for the verification of the generated HLS code. The following Discrete Cosine Transform (DCT) example shows how to generate HLS code and verify it using MATLAB Host.

Simulate the Generated HLS Code using MATLAB Desktop Host

The DCT example uses mldhlc_dct as the MATLAB® Design and mlhdlc_dct_tb as the MATLAB Test Bench to generate and simulate the code.

hdlsetuphlstoolpath('ToolName','SystemC','SystemCIncludePath', ... 'C:\Users\systemc-2.3.3\systemc-2.3.3\src','SystemCLibraryPath', ... 'C:\Users\systemc-2.3.3\systemc-2.3.3\msvc10\SystemC\x64\Release');

hdlsetuphlstoolpath_output.png

Note: To use MATLAB Host as the simulation tool, the synthesis tool should not be selected.

Command Line Interface

cfg = coder.config('hdl'); cfg.Workflow = "High Level Synthesis"; cfg.TestBenchName = "mlhdlc_dct_tb"; cfg.GenerateHDLTestBench = true; cfg.TreatIOThresholdAs = "None";

cfg.SimulateGeneratedCode = true; cfg.SimulationTool = "MATLAB Host";

codegen("mlhdlc_dct",'-config',cfg,'-report');

hls_code_generation_log.png

HDL Workflow Advisor

coder -hdlcoder -new dct_project

verify_with_hls_test_bench.png

MATLAB Host Simulation Report

In the Verify with HLS Test Bench step, you can view the simulation results in mw_MATLAB_Host_simulation_report.log.

HLS simulation report using MATLAB Desktop Host