REDSTONEPEDIA › Circuits › Memory and counters

Copies its input on each clock pulse (D flip-flop)

reacts in 6 ticks (0.3 s) · 9 blocks

At each clock pulse the output takes the value of D and keeps it until the next clock pulse.

copies when the clock turns on · made of redstone torch, repeater · fits in 2×2×3

Clocked memoryClocked memory3D view loading (or not available in this browser)

Try it

Use the CLK and D 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 flip-flop, 9 blocks: the data runs through two repeaters, and each has a lock repeater beside it (a locked repeater holds its output).

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: redstone torch repeater stone

Details: how it works, measurements and properties

In depth

on one edge of the clock input the output takes the value of the data input D, and holds it until the next such edge (a D flip-flop)

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: press and hold the CLK button of the bar (or the cell tagged CLK) to power that input; a quick tap sends a short 2-tick pulse; press and hold the D button of the bar (or the cell tagged D) to power that input; a quick tap sends a short 2-tick pulse.

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).

CLKDOUTticks0100200300400500600700800900100011001200130014001500160017001800190020002100

Swipe the diagram sideways: the whole sequence lasts 2211 ticks (1 min 50.55 s).

Step by step (50 lines)
M 1 d=1 clk=0: q = 0
M 1 clk rises: q = 1 after 6 ticks (0.3 s)
M 1 d=0 clk=1: q = 1
M 1 clk falls: q = 1
M 2 d=0 clk=0: q = 1
M 2 clk rises: q = 0 after 6 ticks (0.3 s)
M 2 d=1 clk=1: q = 0
M 2 clk falls: q = 0
M 3 d=1 clk=0: q = 0
M 3 clk rises: q = 1 after 6 ticks (0.3 s)
M 3 d=1 clk=1: q = 1
M 3 clk falls: q = 1
M 4 d=0 clk=0: q = 1
M 4 clk rises: q = 0 after 6 ticks (0.3 s)
M 4 d=0 clk=1: q = 0
M 4 clk falls: q = 0
M 5 d=1 clk=0: q = 0
M 5 clk rises: q = 1 after 6 ticks (0.3 s)
M 5 d=0 clk=1: q = 1
M 5 clk falls: q = 1
M 6 d=0 clk=0: q = 1
M 6 clk rises: q = 0 after 6 ticks (0.3 s)
M 6 d=0 clk=1: q = 0
M 6 clk falls: q = 0
M 7 d=0 clk=0: q = 0
M 7 clk rises: q = 0
M 7 d=1 clk=1: q = 0
M 7 clk falls: q = 0
M 8 d=1 clk=0: q = 0
M 8 clk rises: q = 1 after 6 ticks (0.3 s)
M 8 d=1 clk=1: q = 1
M 8 clk falls: q = 1
S setup-r 8: q = 1, want 1
S setup-r 4: q = 0, want 0
S setup-r 2: q = 1, want 1
S setup-r 1: q = 0, want 0
S setup-r 0: q = 0, want 1  <- no
S setup-f 8: q = 1, want 1
S setup-f 4: q = 0, want 0
S setup-f 2: q = 1, want 1
S setup-f 1: q = 0, want 0
S setup-f 0: q = 1, want 1
S hold-r 8: q = 1, want 1
S hold-r 4: q = 0, want 0
S hold-r 2: q = 1, want 1
S hold-r 1: q = 0, want 0
S hold-f 8: q = 1, want 1
S hold-f 4: q = 0, want 0
S hold-f 2: q = 1, want 1
S hold-f 1: q = 0, want 0

Measurements

metricvaluewhat it means
latency6 ticks (0.3 s)the worst time from an input change to the output's change
edgerisingwhich input edge flips the output: rising = the input turning on, falling = turning off
setup1 tick (0.05 s)
hold1 tick (0.05 s)

Notes from its designer

D flip-flop, 9 blocks: the data runs through two repeaters, and each has a lock repeater beside it (a locked repeater holds its output). The master's lock reads the clock block itself, so the first repeater follows d only while the clock is LOW; a wall torch hanging on that same clock block feeds the slave's lock, so the second repeater passes only while the clock is HIGH. On the rising edge the master freezes on d and the slave opens: q takes d exactly at the edge. No clock wiring at all: the clock block is part of the circuit.

Properties

StudyMemory and counters
KindCopies its input on each clock pulse (D flip-flop)
Blocks placed9 (not counting the input levers or buttons and the lamp the view adds)
Box2×2×3 (12 blocks of space)
Made of (the blocks that change state)redstone torch, repeater
Inputs / outputsCLK (repeater), D (repeater) / OUT
Design filedff-lock

The design file

on GitHub

Design file (20 lines)
# Clocked memory: reacts in 6 ticks (0.3 s) · 9 blocks
# https://vjeux.github.io/redstonepedia/circuits/memory/dff-lock.html
name: dff-lock
circuit: dff
port input.clk: 0 1 2
port input.d: -1 1 0
port output: 2 1 0
origin: 0 0 0
palette:
  A minecraft:repeater[delay=1,facing=south,locked=false,powered=false]
  B minecraft:repeater[delay=1,facing=west,locked=false,powered=false]
  R minecraft:redstone_wall_torch[facing=east,lit=true]
  S minecraft:stone
layer 0:
  SS
  SS
layer 1:
  BB
  AA
  .R