Main Content

coder.hdl.constrainlatency

Specify the minimum and maximum acceptable hardware latency for a MATLAB function for SystemC code generation

Description

example

coder.hdl.constrainlatency(minimum_latency, maximum_latency) pragma is created that enables the user to specify the desired hardware latency range for a block of code for SystemC code generation.

Examples

collapse all

Consider the MATLAB functions hdltest and region1. The latency of the region1 function is constrained between 0 and 2 clock cycles in the generated SystemC code.

function y = hdltest(a,b)
    u = a+8;
    v = b+6;
    y = region1(u,v);
end

function z = region1(a,b)
    % Optional comment between function defination and pragma
    coder.hdl.constrainlatency(0,2);
    m = a+1;
    n = b+2;
    z = m*n;
end

The following is the generated SystemC code.

#pragma once

#include "rtwtypes.hpp"

class hdltestClass
{
    public: 
    int8_T hdltest(int8_T a,int8_T b)
    {
        int8_T y;
        int8_T u;
        int8_T v;
        int8_T m;
        int8_T n;
        u = (sc_fixed<8,8,SC_TRN,SC_SAT>)((sc_int<9>)a + sc_int<9>(8.0));
        v = (sc_fixed<8,8,SC_TRN,SC_SAT>)((sc_int<9>)b + sc_int<9>(6.0));

    {
        /* Optional comment between function defination and pragma */
        HLS_CONSTRAIN_LATENCY(0,2,"region1");
        m = (sc_fixed<8,8,SC_TRN,SC_SAT>)((sc_int<9>)u + sc_int<9>(1.0));
        n = (sc_fixed<8,8,SC_TRN,SC_SAT>)((sc_int<9>)v + sc_int<9>(2.0));
        y = (sc_fixed<8,8,SC_TRN,SC_SAT>)(m*n);
    }

    return y;
    }
};

Input Arguments

collapse all

Minimum latency, specified as a positive integer.

Example: 4

Maximum latency, specified as a positive integer.

Example: 10

Version History

Introduced in R2022a

See Also