REDSTONEPEDIA › Circuits › Memory and counters

Copy-and-hold memory (D latch)

reacts in 4 ticks (0.2 s) · 4 blocks

Two inputs: while the enable input (E) is on, the output copies the data input (D); when E turns off, the output keeps the last value.

copies its input while its lock input is unpowered, holds while powered · made of repeater · fits in 1×2×2

Copy-and-hold memoryCopy-and-hold memory3D view loading (or not available in this browser)

Try it

Use the D and E buttons under the view to drive the inputs: the box marked OUT turns red while the output is on. Press play under the view to watch a demo on a loop; touch any other control to take over.

How this design does it: D latch, 4 blocks: the data input feeds a repeater (on a stone) whose output is q, and the enable input feeds a second repeater pointing into its side.

Build it

Download .litematic Download the design as text

The .litematic opens in Litematica (Minecraft 26.3): every block of the design in one region. The text file is the same build written as plain text, block by block.

Blocks used: repeater stone

Details: how it works, measurements and properties

In depth

A one-bit memory with a data input D and an enable input E. While E is off, the output Q copies D; when E turns on, Q keeps the value D had and ignores D until E is off again (enable low).

How to try it

Press play under the view to watch the demo on a loop (the badge reads demo with the step it is on; the same sequence is drawn as a timing diagram below). Touch any control to stop it and try the circuit yourself.

To try it: tap the D button of the bar (or the cell tagged D) to turn that input on or off (it powers the cell with a redstone block); tap the E button of the bar (or the cell tagged E) to turn that input on or off (it powers the cell with a redstone block).

Inputs are tagged in lime; the output is tagged OUT: the redstone lamp in that cell (the view adds it to show the output) lights while the output is on (the output strip by the demo badge shows its last 40 game ticks, 2 seconds). Drag to look around, pinch or scroll to zoom, step one game tick at a time with the step button.

Inputs and output over time

The inputs follow this schedule (the 3D view's demo plays the same). Lime: an input is on; orange: the output is on (taller = a stronger signal, 1 to 15). Time runs left to right in game ticks (20 ticks = 1 s).

d=1 e=0d=1 e=1d=0 e=1d=1 e=1d=1 e=0d=0 e=0d=0 e=1d=0 e=0d=1 e=0d=1 e=1d=0 e=1d=0 e=0DEOUTticks020406080100120140160180200220240260

Swipe the diagram sideways: the whole sequence lasts 281 ticks (14.05 s).

Step by step (12 lines)
d=1 e=0: q = 1 after 2 ticks (0.1 s)
d=1 e=1: q = 1
d=0 e=1: q = 1
d=1 e=1: q = 1
d=1 e=0: q = 1
d=0 e=0: q = 0 after 2 ticks (0.1 s)
d=0 e=1: q = 0
d=0 e=0: q = 0
d=1 e=0: q = 1 after 2 ticks (0.1 s)
d=1 e=1: q = 1
d=0 e=1: q = 1
d=0 e=0: q = 0 after 4 ticks (0.2 s)

Measurements

metricvaluewhat it means
latency4 ticks (0.2 s)the worst time from an input change to the output's change
enablelowhigh: the latch follows D while E is on; low: while E is off

Notes from its designer

D latch, 4 blocks: the data input feeds a repeater (on a stone) whose output is q, and the enable input feeds a second repeater pointing into its side. While that second repeater is on, the first is locked and holds q; while it is off, q follows d. So it is transparent while e is OFF; for a latch that follows d while e is ON, hang the 1-block NOT (a wall torch) on the enable input and let it feed the side repeater (5 blocks). Latency 4 ticks.

Properties

StudyMemory and counters
KindCopy-and-hold memory (D latch)
Blocks placed4 (not counting the input levers or buttons and the lamp the view adds)
Box1×2×2 (4 blocks of space)
Made of (the blocks that change state)repeater
Inputs / outputsD (repeater), E (repeater) / OUT
Design filed-latch-repeater

The design file

on GitHub

Design file (18 lines)
# Copy-and-hold memory: reacts in 4 ticks (0.2 s) · 4 blocks
# https://vjeux.github.io/redstonepedia/circuits/memory/d-latch-repeater.html
name: d-latch-repeater
circuit: d-latch
port input.d: -1 1 1
port input.e: 0 1 -1
port output: 1 1 1
origin: 0 0 0
palette:
  R minecraft:repeater[delay=1,facing=north,locked=false,powered=false]
  S minecraft:stone
  r minecraft:repeater[delay=1,facing=west,locked=false,powered=false]
layer 0:
  S
  S
layer 1:
  R
  r