---
url: /dyad/stable/stdlib/DiscreteComponents/components/NDelay.md
description: 'Dyad NDelay docs.  A delay block that delays its input by n timesteps.  '
---

# `NDelay` {#NDelay}

A delay block that delays its input by `n` timesteps.

Always initializes the intermediate timesteps with `initial_condition`. Clock-agnostic.

## Usage {#Usage}

`DiscreteComponents.NDelay(initial_condition=0)`

## Parameters: {#Parameters:}

|                Name |                                 Description | Units | Default value |
| -------------------:| -------------------------------------------:| -----:| -------------:|
|                 `n` |           The number of samples to delay by |     – |               |
| `initial_condition` | The initial condition of the delayed signal |     – |             0 |

## Connectors {#Connectors}

* `u` - This connector represents a real signal as an input to a component ([`RealInput`](/stdlib/Dyad/connectors/RealInput#RealInput))

* `y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Behavior {#Behavior}

Behavior of this component cannot be rendered because it includes `path` variables.

## Source {#Source}

```dyad
"""
A delay block that delays its input by `n` timesteps.  

Always initializes the intermediate timesteps with `initial_condition`.
Clock-agnostic.
"""
component NDelay@[input clk extends Discrete]
  "The input signal to delay"
  u = RealInput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -40, "y1": 450, "x2": 60, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "The delayed output signal"
  y = RealOutput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 960, "y1": 450, "x2": 1060, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "The number of samples to delay by"
  structural parameter n::Integer
  "The initial condition of the delayed signal"
  parameter initial_condition::Real = 0
relations
  y = u@(clk-n)
  for i in 1:n
    initial u@(clk-i) = initial_condition
  end
metadata {"Dyad": {"doc": {"behavior": false}}}
end
```

```dyad
"""
A delay block that delays its input by `n` timesteps.  

Always initializes the intermediate timesteps with `initial_condition`.
Clock-agnostic.
"""
component NDelay
  "The input signal to delay"
  u = RealInput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -40, "y1": 450, "x2": 60, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "The delayed output signal"
  y = RealOutput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 960, "y1": 450, "x2": 1060, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "The number of samples to delay by"
  structural parameter n::Integer
  "The initial condition of the delayed signal"
  parameter initial_condition::Real = 0
relations
  y = u@(clk-n)
  for i in 1:n
    initial u@(clk-i) = initial_condition
  end
metadata {"Dyad": {"doc": {"behavior": false}}}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`TestNDelay`](NDelay.md)
