Contenido principal

codegen

R2026b

Generate HDL or High-Level Synthesis (HLS) code from MATLAB code

Description

codegen -config hdlcfg matlab_design_name generates HDL code from MATLAB® code.

example

codegen -config hdlcfg -float2fixed fixptcfg matlab_design_name converts floating-point MATLAB code to fixed-point code, then generates HDL code.

example

codegen -config hlscfg matlab_design_name generates HLS code from MATLAB code.

example

codegen -config hlscfg -float2fixed fixptcfg matlab_design_name converts floating-point MATLAB code to fixed-point code, then generates HLS code.

Note

Use fixptcfg when you want to generate HDL or HLS code from floating-point MATLAB code.

Examples

collapse all

Create a coder.HdlConfig object, hdlcfg.

hdlcfg = coder.config("hdl"); % Create a default "hdl" config

Set the test bench name. In this example, the test bench function name is mlhdlc_dti_tb.

hdlcfg.TestBenchName = "mlhdlc_dti_tb";

Set the target language to Verilog®.

hdlcfg.TargetLanguage = "Verilog";

Generate HDL code from your MATLAB design. In this example, the MATLAB design function name is mlhdlc_dti.

codegen -config hdlcfg mlhdlc_dti

Create a coder.FixptConfig object, fixptcfg, with default settings.

fixptcfg = coder.config("fixpt");

Set the test bench name. In this example, the test bench function name is mlhdlc_dti_tb.

fixptcfg.TestBenchName = "mlhdlc_dti_tb";

Create a coder.HdlConfig object, hdlcfg, with default settings.

hdlcfg = coder.config("hdl");

Convert your floating-point MATLAB design to fixed-point, and generate HDL or HLS code. In this example, the MATLAB design function name is mlhdlc_dti.

codegen -float2fixed fixptcfg -config hdlcfg mlhdlc_dti

Create a coder.HlsConfig object, hlscfg.

hlscfg = coder.config("hls");

Set the test bench name. In this example, the test bench function name is myDesign_tb.

hlscfg.TestBenchName = "myDesign_tb";

Generate HLS code from your MATLAB design. In this example, the MATLAB design function name is myDesign.

codegen -config hlscfg myDesign

Create a coder.FixptConfig object, fixptcfg, with default settings.

fixptcfg = coder.config("fixpt");

Set the test bench name. In this example, the test bench function name is myDesign_tb.

fixptcfg.TestBenchName = "myDesign_tb";

Create a coder.HlsConfig object, hlscfg, with default settings.

hlscfg = coder.config("hls");

Convert your floating-point MATLAB design to fixed-point, and generate HLS code. In this example, the MATLAB design function name is myDesign.

codegen -float2fixed fixptcfg -config hlscfg myDesign

Input Arguments

collapse all

HDL code generation configuration options, specified as a coder.HdlConfig object.

Create a coder.HdlConfig object using the HDL coder.config function.

HLS code generation configuration options, specified as a coder.HlsConfig object.

Create a coder.HlsConfig object using the coder.config function.

Name of top-level MATLAB function for which you want to generate HDL or HLS code.

Floating-point to fixed-point conversion configuration options, specified as a coder.FixptConfig object.

Create a coder.FixptConfig object using the HDL coder.config function.

Version History

Introduced in R2013a

expand all