# Memory (one-step delay) (`memory`)

> Outputs its input as it was at the previous solver step.

![memory](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/memory.svg)

[Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/memory/)

**Group:** Control · **Kind:** `{"block":"memory","kind":"control"}`

## When to use it

Use it for a difference equation over the solver's steps: a counter, an edge detector (the input and its value one step ago), or a loop that needs a delay to have no algebraic loop. It is what a PLECS Memory block imports as. Use Sample Delay or zDelay for a delay of one sample period.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `in` | signal | Signal to delay |
| `out` | signal | The input at the previous solver step |

## Common parameters

- `x0`: Initial output (Default: 0)

## Parameters

| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
| `x0` | — | 0 |  | Initial output |

_Parameter descriptions are in English in both languages._

## Model

out(k) = in(k-1), where k counts the accepted solver steps; before the first step the output is x0. The input is taken after every other block has run at a step, so the delay is one step whether or not the block sits in a loop, and the block has no direct feedthrough, so a loop through it is not an algebraic loop.

## Common mistakes

- The delay is one solver step, not a fixed time: with a variable step it changes with the step, and a smaller maxStep makes it shorter. For a delay in seconds use Transport Delay, and for one sample period Sample Delay.
- Code generation leaves it out: firmware has no solver step. At a sample time use zDelay.

Problems rules: `compile.error`

## Datasheet and sources

There is no datasheet.

## Example

Open the example with the command `file.openExample` and the name `demo:memory`.

---
Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand.
