REDSTONEPEDIA › Circuits › Memory and counters

Copies its input on each clock pulse when enabled (D flip-flop with enable)

reacts in 6 ticks (0.3 s) · 12 blocks

At each clock pulse, if E is on, the output takes the value of D; otherwise it keeps its value.

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

Clocked memory with enableClocked memory with enable3D view loading (or not available in this browser)

Try it

Use the CLK, 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 flip-flop with enable, 12 blocks: the 9-block flip-flop (two repeaters with lock repeaters beside them; the master's lock reads the clock block, a wall torch on that block feeds the slave's) plus one more lock on the slave's other side, fed by a wall torch on the enable block.

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

a D flip-flop with an enable input: on the clock's edge it takes the data input only while the enable input is powered, otherwise it keeps its value

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; press and hold the E button of the bar (or the cell tagged E) 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).

CLKDEOUTticks050100150200250300350400450500550600650700750800

Swipe the diagram sideways: the whole sequence lasts 841 ticks (42.05 s).

Step by step (40 lines)
M 1 d=1 clk=0 e=1: 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 e=1: 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 e=0: q = 0
M 3 clk rises: q = 0
M 3 d=1 clk=1: q = 0
M 3 clk falls: q = 0
M 4 d=0 clk=0 e=1: q = 0
M 4 clk rises: q = 0
M 4 d=0 clk=1: q = 0
M 4 clk falls: q = 0
M 5 d=1 clk=0 e=0: q = 0
M 5 clk rises: q = 0
M 5 d=0 clk=1: q = 0
M 5 clk falls: q = 0
M 6 d=1 clk=0 e=1: q = 0
M 6 clk rises: q = 1 after 6 ticks (0.3 s)
M 6 d=1 clk=1: q = 1
M 6 clk falls: q = 1
M 7 d=0 clk=0 e=0: q = 1
M 7 clk rises: q = 1
M 7 d=0 clk=1: q = 1
M 7 clk falls: q = 1
M 8 d=0 clk=0 e=1: q = 1
M 8 clk rises: q = 0 after 6 ticks (0.3 s)
M 8 d=1 clk=1: q = 0
M 8 clk falls: q = 0
M 9 d=1 clk=0 e=0: q = 0
M 9 clk rises: q = 0
M 9 d=1 clk=1: q = 0
M 9 clk falls: q = 0
M 10 d=1 clk=0 e=1: q = 0
M 10 clk rises: q = 1 after 6 ticks (0.3 s)
M 10 d=0 clk=1: q = 1
M 10 clk falls: q = 1

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

Notes from its designer

D flip-flop with enable, 12 blocks: the 9-block flip-flop (two repeaters with lock repeaters beside them; the master's lock reads the clock block, a wall torch on that block feeds the slave's) plus one more lock on the slave's other side, fed by a wall torch on the enable block. A repeater is locked if EITHER side is powered, so while e is off the slave stays locked through any clock edge and q holds; no AND gate is needed.

Properties

StudyMemory and counters
KindCopies its input on each clock pulse when enabled (D flip-flop with enable)
Blocks placed12 (not counting the input levers or buttons and the lamp the view adds)
Box2×2×5 (20 blocks of space)
Made of (the blocks that change state)redstone torch, repeater
Inputs / outputsCLK (repeater), D (repeater), E (repeater) / OUT
Design filedffe-lock

The design file

on GitHub

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