Main Content

hdlcoder.TimingGenerator Class

Namespace: hdlcoder

Base class to implement custom tool and device support for critical path estimation reporting

Since R2024a

Description

The hdlcoder.TimingGenerator class is an abstract base class you can use to implement custom tool and device support for critical path estimation reporting. You can use instances of this class as the input to the genhdltdb function.

Because the hdlcoder.TimingGenerator class is an abstract class, you cannot create an instance of this class directly. You use the handle class to derive other classes, which can be concrete classes whose instances are handle objects.

To define a handle class, derive your class from hdlcoder.TimingGenerator using the syntax in this classdef code.

classdef MyHandleClass < hdlcoder.TimingGenerator
    ...
end

When you create a derived class object from hdlcoder.TimingGenerator, HDL Coder™ generates a comma-separated file called timing_info.txt. The file contains timing details related to the operation undergoing a timing analysis.

The hdlcoder.TimingGenerator class is a handle class.

Class Attributes

Abstract
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Events

Event NameTriggerEvent DataEvent Attributes
ObjectBeingDestroyedTriggered when the handle object is about to be destroyed, but before calling the delete method. event.EventData

NotifyAccess= private

ListenAccess=public

Examples

collapse all

In this example, you examine a custom timing generator subclass designed for Xilinx® Vivado® hardware. This class uses the synthesizeRTL method to run synthesis and timing analysis, and uses the hasDSPs method to characterize the DSPs on your device. If your device does not have DSPs or if you do not want to characterize them, set hasDSPs to false. After you create the class, you can pass the hdlcoder.TimingGenerator.XilinxVivado class as a name-value argument to the genhdltdb function to generate a timing database. To view the shipping custom class, at the MATLAB® Command Line, enter:

edit hdlcoder.TimingGenerator.XilinxVivado

XilinxVivado custom class definition.

classdef XilinxVivado < hdlcoder.TimingGenerator
%

%   Copyright 2023 The MathWorks, Inc.
    
   

The synthesizeRTL method calls the project creation, synthesis, and timing analysis TCL scripts.

function [status, logTxt] = synthesizeRTL(obj)
            % add code for project creation, synthesis and timing analysis
            end

The postProcessTimingInfo method further processes the timing information reported by the synthesis tool. For example, you can use this method to remove setup and clock-to-Q delays. Use this method when TCL scripts cannot handle removing setup and hold delays that are not required.

function timingInfo = postProcessTimingInfo(obj, timingInfo)
            % add code here for your custom timing information analysis
end

These methods account for and characterize the DSPs on the device.:

  • The hasDSPs method is set to true to characterize the DSPs on the device

  • The countDSPs method counts and returns the number of DSPs during device synthesis

  • the dspSynthesisAttribute method uses name-value arguments in cell arrays to specify attributes to apply during HDL code generation

  • the dontTouchSynthesisAttribute method uses name-value arguments in cell arrays to specify attributes to apply during HDL code generation

function val = hasDSPs(~)
            val = true;
        end

        function val = countDSPs(~, synthesisLogText)
            val_str = regexp(synthesisLogText, '|DSP.\S*\s*\|\s*(\d+)', 'tokens', 'lineanchors');
            assert(isscalar(val_str));
            val = str2double(val_str{1}{1});
        end

        function val = dspSynthesisAttribute(~)
            val = {'USE_DSP', 'yes'};
        end

        function val = dontTouchSynthesisAttribute(~)
            val = {'DONT_TOUCH', 'TRUE'};
        end

Generate a timing database by using the genhdltdb function and passing the XilinxVivado class as a name-value argument to the function.

tg = XilinxVivado;
genhdltdb("SynthesisDeviceConfiguration",{"Zynq","xc7z020","clg484","-1"}, ...
    "TimingDatabaseDirectory","C:\Work\database\", ...
    "TimingGenerator",tg);

In this example, you examine a custom timing generator subclass designed for Cadence® Genus hardware. This class uses the synthesizeRTL method to run synthesis and timing analysis and uses the hasDSPs method to characterize the DSPs on the device. If your device does not have DSPs or if you do not want to characterize them, set hasDSPs to false. If you set hasDSPs to true, you must define the countDSPs, dspSynthesisAttribute, and dontTouchSynthesisAttribute methods. After you create the class, you can pass the hdlcoder.TimingGenerator.CadenceGenus class as a name-value argument to the genhdltdb function to generate a timing database. To examine the completed custom class, at the MATLAB command line, enter:

edit hdlcoder.TimingGenerator.CadenceGenus

CadenceGenus custom class definition.

classdef CadenceGenus < hdlcoder.TimingGenerator
 %
 % Copyright 2024 The MathWorks, Inc.
   

The synthesizeRTL method calls the project creation, synthesis, and timing analysis TCL scripts.

function [status, logTxt] = synthesizeRTL(obj)
% add code here for project creation, synthesis, and timing analysis            
        end

The useSynchronousReset method tells HDL Coder to specify what to set the global reset options to. For example, Cadence Genus supports asynchronous resets, so useSynchronousReset is set to false to perform asynchronous resets.

function val = useSynchronousReset(~)
            val = false;
        end

In this example, this class targets a device that does not have DSPs. The hasDSPs method is set to false.

function val = hasDSPs(~)
            val = false;
        end

Generate a timing database by using the genhdltdb function. Pass the CadenceGenus class as a name-value argument to the function.

tg = CadenceGenus;
genhdltdb("SynthesisDevicePart","tutorial.lib", ...
    "TimingDatabaseDirectory","C:\Work\database\", ...
    "TimingGenerator",tg);

More About

expand all

Version History

Introduced in R2024a