flipflop

A D flip-flop: on each rising edge of its clock, its output q takes the level at its d.

flipflopNode
On this page
A D flip-flop marked D, CLK, Q and Q-bar, with switches on D and the clock and a lamp on Q.A D flip-flop marked D, CLK, Q and Q-bar, with switches on D and the clock and a lamp on Q.

#Attributes

value
The level q starts at, 0 or 1.
colourAnimatable
A hue that tints the box's fill and deepens its stroke.
paint
Also written: color
hiddenAnimatable
Declares the flip-flop without drawing it or giving it room.
Defaultfalse

#Derived attributes

Computed while the element renders — read one with #id.name in attribute position or {{#id.name}} in prose, never set.

levelDerived
The level of q.

#Allowed content

Body { }Words set inside the box; usually empty

#Allowed in

#Examples

Three frames of the first step: the clock low, then a cue raises it and Q starts to take the level at D, then Q lit.Three frames of the first step: the clock low, then a cue raises it and Q starts to take the level at D, then Q lit.
logic{
    switch#d{$D$}(value: 1)
    switch#clk{Clock}(value: 0 !cue.to{1}(at: 1 + 300ms))
    flipflop#ff{}(value: 0)
    lamp#q{$Q$}
    wire(from: #d; to: #ff.d)
    wire(from: #clk; to: #ff.clock)
    wire(from: #ff.q; to: #q)
}

#Notes

  • Power-up is not an edge.
  • qbar is the complement of q.
  • Its ports are marked inside it — D and CLK on its back, Q and Q̄ on its front — and clk, q-bar and nq name them too.
  • Wires that name no port land on d and then clock, and leave from q.
  • A wire may return to the same flip-flop: wire(from: #ff.qbar; to: #ff.d) divides its clock by two.

Last updated