flipflop

A D flip-flop: on each rising edge of its clock its output q takes the level at its d, and holds it until the next. qbar is the complement of q. Its ports are marked inside it — D and CLK on its back, Q and Q̄ on its front. 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), which divides its clock by two.

flipflopNode
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. Without it q starts unknown.
colourAnimatable
The box fills with the hue's own tint and strokes deeper.
bluelight-bluedark-blueredlight-reddark-redorangelight-orangedark-orangeyellowlight-yellowdark-yellowteallight-tealdark-tealgreenlight-greendark-greenpinklight-pinkdark-pinkpurplelight-purpledark-purplegreylight-greydark-greyneutralhex(…)rgb(…)
Also written: color
hiddenAnimatable
Declared but not drawn, and taking no room while hidden. Animatable.
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: 0, 1, or absent while unknown.

#Allowed content

Body { }Words set inside the box; usually empty

#Allowed in

#Examples

Three frames of the first step: a cue raises the clock, and Q takes the level at D.Three frames of the first step: a cue raises the clock, and Q takes the level at D.
logic{
    switch#d{$D$}(value: 1)
    switch#clk{Clock}(value: 0 !cue.to{1}(at: 1))
    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)
}

Last updated