Main Content

hdlcoder.CodingStandard

Create HDL coding standard customization object

Description

example

cso = hdlcoder.CodingStandard(standardName) creates an HDL coding standard customization object that you can use to customize the rules and the appearance of the coding standard report.

If you do not want to customize the rules or appearance of the coding standard report, you do not need to create an HDL coding standard customization object.

Examples

collapse all

Create an HDL coding standard customization object

Create a coding standard customization object cso

cso = hdlcoder.CodingStandard('Industry');

Customize the Coding Standard Options

  • Do not show passing rules in the coding standard report.

  • Set the maximum if-else nesting depth to 2.

  • Disable the check for line length.

cso.ShowPassingRules.enable = false;
cso.IfElseNesting.depth = 2;
cso.LineLength.enable = false;

Create HDL Codegen Configuration and Coding Standard Customization Object

hdlcfg = coder.config('hdl');

Specify the coding standard and coding standard customization object.

hdlcfg.HDLCodingStandard = 'Industry';
hdlcfg.HDLCodingStandardCustomizations = cso;

Create a temporary folder and copy the MATLAB files

In this case, the design function is mlhdlc_dti.m and the test bench function is mlhdlc_dti_tb.m.

mlhdlc_demo_dir = fullfile(matlabroot, 'toolbox', 'hdlcoder', ...
                                 'hdlcoderdemos', 'matlabhdlcoderdemos');
mlhdlc_temp_dir = [tempdir 'mlhdlc_sfir'];

cd(tempdir);
[~, ~, ~] = rmdir(mlhdlc_temp_dir, 's');
mkdir(mlhdlc_temp_dir);
cd(mlhdlc_temp_dir);

copyfile(fullfile(mlhdlc_demo_dir, 'mlhdlc_dti.m'), mlhdlc_temp_dir);
copyfile(fullfile(mlhdlc_demo_dir, 'mlhdlc_dti_tb.m'), mlhdlc_temp_dir);

Generate HDL code and Test Bench

Specify your test bench function name.

hdlcfg.TestBenchName = 'mlhdlc_dti_tb';

Generate HDL code for the design and check the code according to the customized HDL coding standard rules.

codegen -config hdlcfg mlhdlc_dti
### Begin VHDL Code Generation
### Generating HDL Conformance Report <a href="matlab:web('/tmp/Bdoc20b_1465442_236240/mlhdlc_sfir/codegen/mlhdlc_dti/hdlsrc/mlhdlc_dti_hdl_conformance_report.html')">mlhdlc_dti_hdl_conformance_report.html</a>.
### HDL Conformance check complete with 0 errors, 20 warnings, and 0 messages.
### Working on mlhdlc_dti as <a href="matlab:edit('/tmp/Bdoc20b_1465442_236240/mlhdlc_sfir/codegen/mlhdlc_dti/hdlsrc/mlhdlc_dti.vhd')">mlhdlc_dti.vhd</a>.
### Generating Resource Utilization Report <a href="matlab:web('/tmp/Bdoc20b_1465442_236240/mlhdlc_sfir/codegen/mlhdlc_dti/hdlsrc/resource_report.html')">resource_report.html</a>.
### Industry Compliance report with 0 errors, 1 warnings, 4 messages.
### Generating Industry Compliance Report <a href="matlab:web('/tmp/Bdoc20b_1465442_236240/mlhdlc_sfir/codegen/mlhdlc_dti/hdlsrc/mlhdlc_dti_Industry_report.html')">mlhdlc_dti_Industry_report.html</a>

Create an HDL coding standard customization object

  • Load the sfir_fixed model

  • Create a coding standard customization object cso

load_system('sfir_fixed')
cso = hdlcoder.CodingStandard('Industry');

Customize the coding standard options

  • Do not show passing rules in the report.

  • Set maximum line length to 80 characters.

  • Check that module, instance, and entity names are between 5 and 50 characters long.

cso.ShowPassingRules.enable = false;
cso.LineLength.length = 80;
cso.ModuleInstanceEntityNameLength.length = [5 50];

Generate HDL code for your design

Generate HDL code and check it according to the customized HDL coding standard rules. The DUT subsystem is symmetric_fir.

makehdl('sfir_fixed/symmetric_fir','HDLCodingStandard','Industry',...
        'HDLCodingStandardCustomizations',cso, 'TargetDirectory', 'C:/coding_standard/hdlsrc')
### Generating HDL for 'sfir_fixed/symmetric_fir'.
### Starting HDL check.
### Begin VHDL Code Generation for 'sfir_fixed'.
### Working on sfir_fixed/symmetric_fir as C:\coding_standard\hdlsrc\sfir_fixed\symmetric_fir.vhd.
### Industry Compliance report with 4 errors, 77 warnings, 6 messages.
### Generating Industry Compliance Report <a href="matlab:web('C:\coding_standard\hdlsrc\sfir_fixed\symmetric_fir_Industry_report.html')">symmetric_fir_Industry_report.html</a>
### Creating HDL Code Generation Check Report file://C:\coding_standard\hdlsrc\sfir_fixed\symmetric_fir_report.html
### HDL check for 'sfir_fixed' complete with 0 errors, 0 warnings, and 0 messages.
### HDL code generation complete.

Input Arguments

collapse all

Specify the HDL coding standard to customize. The standardName value must match the HDLCodingStandard property value.

Example: 'Industry'

Output Arguments

collapse all

HDL coding standard customizations, returned as an HDL coding standard customization object.

Introduced in R2014b