# Flip-Flop **A synchronous [[Level and Edge-Triggering#^8b1bab|edge-triggered]] storage element.** A **flip-flop** is a storage element which has *two stable states* and *stores one state indefinitely* until it is triggered by a clock signal to change. The input equations for a flip-flop are derived from [[State Table|state tables]]. [[Excitation Table|Excitation tables]] are used to derive the output combinational circuit. > [!Input equation derivation example]- > For a [[Flip-Flop#T flip-flip|T flip-flop]] circuit, the extended state table derived from an excitation table is: > >| Present<br>state | | Inputs | | Next<br>state | | Flip-flop<br>inputs | | |:--------------------:|:---:|:--------:|:--------:|:-----------------:|:--------:|:-----------------------:|:-----:| | $A$ | $B$ | $S$ | $F$ | $A(t+1)$ | $B(t+1)$ | $T_A$ | $T_B$ | | $0$ | $0$ | $0$ | $0$ | $0$ | $0$ | $0$ | $0$ | | $0$ | $0$ | $\times$ | $1$ | $0$ | $1$ | $0$ | $1$ | | $0$ | $0$ | $1$ | $\times$ | $1$ | $0$ | $1$ | $0$ | | | | | | | | | | | $0$ | $1$ | $0$ | $0$ | $0$ | $1$ | $0$ | $0$ | | $0$ | $1$ | $\times$ | $1$ | $1$ | $0$ | $1$ | $1$ | | $0$ | $1$ | $1$ | $\times$ | $1$ | $1$ | $1$ | $0$ | | | | | | | | | | | $1$ | $1$ | $0$ | $0$ | $1$ | $1$ | $0$ | $0$ | | $1$ | $1$ | $\times$ | $1$ | $0$ | $0$ | $1$ | $1$ | | $1$ | $1$ | $1$ | $\times$ | $0$ | $1$ | $1$ | $0$ | | | | | | | | | | | $1$ | $0$ | $0$ | $0$ | $1$ | $0$ | $0$ | $0$ | | $1$ | $0$ | $\times$ | $1$ | $1$ | $1$ | $0$ | $1$ | | $1$ | $0$ | $1$ | $\times$ | $0$ | $0$ | $1$ | $0$ | > > Note that for this particular circuit, $S=F=1$ is not a possible combination. To derive the flip-flop input equations, [[Karnaugh Map|K-maps]] can be used. > > ![[LightControllerTAKMap.svg|400]] > *** > ![[LightControllerTBKMap.svg|400]] > > Thus, the flip-flop input equations are >$\begin{align*} T_{A}&=BF+S \\ T_{B}&=F \\ \end{align*}$ ## Types ### D flip-flop ![[DFlipFlop.svg|250]] A *data* or *delay* flip-flop is the most fundamental flip-flop and is the flip-flop that uses the *least* amount of gates. Other flip-flops can be constructed using D flip-flops and additional combinational logic. A D flip-flop is constructed from two [[Latch#D latch|D latches]] and inverters. A *positive-edge* triggered D flip-flop uses two inverters whereas a *negative-edge* triggered one uses one. ![[DFlipFlopConstruction.svg]] In a *positive-edge* triggered D flip-flop: - when *clock* is off, the master latch is enabled and the slave latch is disabled. Thus, $Y=D$. - when *clock* is on, the opposite is true and thus $Q=D$. In a *negative-edge* triggered D flip-flop: - when *clock* is on, the master latch is enabled and the slave latch is disabled. Thus, $Y=D$. - when *clock* is off, the opposite is true and thus $Q=D$. > The *[[Characteristic Equation#Digital Electronics|characteristic equation]]* of a D flip-flop is $Q_{\text{next}}=D$. > The *[[excitation table]]* is: > > | $Q$ | $Q_{\text{next}}$ | $D$ | > |:---:|:-----------------:|:---:| > | $0$ | $0$ | $0$ | > | $0$ | $1$ | $1$ | > | $1$ | $0$ | $0$ | > | $1$ | $1$ | $1$ | ### JK flip-flop ![[JKFlipFlop.svg|250]] A JK flip-flop behaves similarly to an [[Latch#SR latch|SR latch]] but it does permit an input of $J=K=1$, the equivalent to $S=R=1$. > The *characteristic equation* of a JK flip-flop is $Q_{\text{next}}=J\bar{Q}+\bar{K}Q$. > The *characteristic table* is > > | Characteristic | | | | > | :------------: | :-: | :---------------: | :--------: | > | $J$ | $K$ | $Q_{\text{next}}$ | **Action** | > | $0$ | $0$ | $Q$ | Hold | > | $0$ | $1$ | $0$ | Reset | > | $1$ | $0$ | $1$ | Set | > | $1$ | $1$ | $\bar{Q}$ | Toggle | > The *excitation table* is > > | Excitation | | | | | > | :--------: | :---------------: | :------: | :------: | :--------: | > | $Q$ | $Q_{\text{next}}$ | $J$ | $K$ | **Action** | > | $0$ | $0$ | $0$ | $\times$ | Hold | > | $0$ | $1$ | $1$ | $\times$ | Set | > | $1$ | $0$ | $\times$ | $1$ | Reset | > | $1$ | $1$ | $\times$ | $0$ | Hold | ### T flip-flop ![[TFlipFlop.svg|250]] A *toggle* flip-flop toggles its output when triggered. It is the same as a JK flip-flop when $J=K$. > The *characteristic equation* of a T flip-flop is $Q_{\text{next}}=T\bar{Q}+\bar{T}Q$. > The *characteristic table* is > > | Characteristic | | | > |:--------------:|:-----------------:|:----------:| > | $T$ | $Q_{\text{next}}$ | **Action** | > | $0$ | $Q$ | Hold | > | $1$ | $\bar{Q}$ | Toggle | > The *excitation table* is > > | Excitation | | | | > |:----------:|:-----------------:|:---:|:----------:| > | $Q$ | $Q_{\text{next}}$ | $T$ | **Action** | > | $0$ | $0$ | $0$ | Hold | > | $0$ | $1$ | $1$ | Toggle | > | $1$ | $0$ | $1$ | Toggle | > | $1$ | $1$ | $0$ | Hold |