Main Content

coder.hdl.pipeline

Insert pipeline registers at output of MATLAB expression

Description

example

out = coder.hdl.pipeline(expr) inserts one pipeline register at the output of expr in the generated HDL code. This pragma does not affect MATLAB® simulation behavior.

Use this pragma to specify exactly where to insert pipeline registers. For example, in a MATLAB assignment statement, you can specify the coder.hdl.pipeline pragma:

  • On the entire right side of the assignment statement.

  • On a subexpression.

  • By nesting multiple pragmas.

  • On a call to a subfunction, if the subfunction returns a single value. You cannot specify the pragma for a subfunction that returns multiple values.

If you enable distributed pipelining, HDL Coder™ can move the pipeline registers to break the critical path.

HDL Coder cannot insert a pipeline register at the output of a MATLAB expression if any of the variables in the expression are:

  • In a loop.

  • A persistent variable that maps to a state element, like a state register or RAM.

  • An output of a function. For example, in the following code, you cannot add a pipeline register for an expression containing y:

    function [y] = myfun(x)
    y = x + 5;
    end

  • In a data feedback loop. For example, in the following code, you cannot pipeline an expression containing the t or pvar variables:

    persistent pvar;
    t = u + pvar;
    pvar = t + v;

You cannot use coder.hdl.pipeline to insert a pipeline register for a single variable or other no-op expression. To learn how to insert a pipeline register for a function input variable, see Port Registers.

example

out = coder.hdl.pipeline(expr,num) inserts num pipeline registers at the output of expr in the generated HDL code. This pragma does not affect MATLAB simulation behavior.

Use this pragma to specify exactly where to insert pipeline registers. For example, in a MATLAB assignment statement, you can specify the coder.hdl.pipeline pragma:

  • On the entire right side of the assignment statement.

  • On a subexpression.

  • By nesting multiple pragmas.

  • On a call to a subfunction, if the subfunction returns a single value. You cannot specify the pragma for a subfunction that returns multiple values.

If you enable distributed pipelining, HDL Coder can move the pipeline registers to break the critical path.

HDL Coder cannot insert a pipeline register at the output of a MATLAB expression if any of the variables in the expression are:

  • In a loop.

  • A persistent variable that maps to a state element, like a state register or RAM.

  • An output of a function. For example, in the following code, you cannot add a pipeline register for an expression containing y:

    function [y] = myfun(x)
    y = x + 5;
    end

  • In a data feedback loop. For example, in the following code, you cannot pipeline an expression containing the t or pvar variables:

    persistent pvar;
    t = u + pvar;
    pvar = t + v;

You cannot use coder.hdl.pipeline to insert a pipeline register for a single variable or other no-op expression. To learn how to insert a pipeline register for a function input variable, see Port Registers.

Examples

collapse all

At the output of a MATLAB expression, a + b * c, insert a single pipeline register.

y = coder.hdl.pipeline(a + b * c);

At the output of a MATLAB expression, a + b * c, insert three pipeline registers.

    y = coder.hdl.pipeline(a + b * c, 3);

For a MATLAB expression, a + b * c, after the computation of b * c, insert five pipeline registers.

    y = a + coder.hdl.pipeline(b * c, 5);

At an intermediate stage and at the output of a MATLAB expression, use nested coder.hdl.pipeline pragmas to insert pipeline registers.

For a MATLAB expression, a + b * c, after the computation of b * c, insert five pipeline registers, and insert two pipeline registers at the output of the whole expression.

    y = coder.hdl.pipeline(a + coder.hdl.pipeline(b * c, 5),2);

Input Arguments

collapse all

MATLAB expression to pipeline. At the output of this expression in the generated HDL code, insert pipeline registers.

Example: a + b

Number of pipeline registers to insert at the output of expr in the generated HDL code, specified as a positive integer.

Example: 3

Introduced in R2015a