Setup Time
A flip-flop’s hold time is the minimum amount of time after the clock’s rising edge that the data input to a flip-flop must remain stable.
\begin{document} \begin{tikzpicture}[scale=1, transform shape] % Draw the waveform \draw[thick] (0,0) node[left, at start] {t=0} -- (1,0) -- (1,1) -- (3,1) -- (3,0) -- (5,0) -- (5,1) -- (7,1) -- (7,0) -- (9,0); % Label setup times \draw[<->, thick, orange] (4, -0.5) -- (5, -0.5) node[midway, below, align=center] {Setup \\ Time}; \draw[<->, thick, orange] (0, -0.5) -- (1, -0.5) node[midway, below, align=center] {Setup \\ Time}; % Label setup times \draw[<->, thick, purple] (5, 1.5) -- (6, 1.5) node[midway, above, align=center] {Hold \\ Time}; \draw[<->, thick, purple] (1, 1.5) -- (2, 1.5) node[midway, above, align=center] {Hold \\ Time}; \end{tikzpicture} \end{document}If the clock signal above has a hold time of 1 ns, then any change to the input 1 ns after the rising edge will result in a hold-time violation, causing the output to become undefined.
Understanding
The hold time of a flip-flop ensures that the data captured by the flip-flop is correctly latched and not corrupted by changes in the input signal immediately following the clock edge. Violating the hold time can result in incorrect data being stored in the flip-flop.
Examples
Plotting 's Waveform
Consider the plot of a register’s output that we constructed in 5.2a.2 and updated to account for hold time in 5.2b.1. If the register also has a hold time of 1 ns, then there is a hold-time violation at , as it is ns after the clock’s rising edge:
\usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ width=12cm, height=6cm, xlabel={Time (ns)}, ylabel={}, ymin=-0.5, ymax=3, xmin=0, xmax=28, xtick={0,2,4,6,8,10,12,14,16,18,20,22,24,26,28}, ytick={0.25, 1.25, 2.25}, yticklabels={Q, D, clk}, grid=major, grid style={dotted, gray}, xmajorgrids=true, ymajorgrids=false, extra y ticks={0, 0.5, 1, 1.5, 2, 2.5}, extra y tick labels={}, extra y tick style={grid=major}, ] % Clock signal \addplot[thick, black] coordinates {(0, 2) (2, 2) (2, 2.5) (4, 2.5) (4, 2) (6, 2) (6, 2.5) (8, 2.5) (8, 2) (10, 2) (10, 2.5) (12, 2.5) (12, 2) (14, 2) (14, 2.5) (16, 2.5) (16, 2) (18, 2) (18, 2.5) (20, 2.5) (20, 2) (22, 2) (22, 2.5) (24, 2.5) (24, 2) (26, 2) (26, 2.5) (28, 2.5)}; % D signal \addplot[thick, blue] coordinates {(0, 1.5) (4, 1.5) (4, 1) (7.5, 1) (7.5, 1.5) (8.5, 1.5) (8.5, 1) (11, 1) (11, 1.5) (12, 1.5) (12, 1) (13, 1) (13, 1.5) (16, 1.5) (16, 1) (17.5, 1) (17.5, 1.5) (24, 1.5) (24, 1) (26.5, 1) (26.5, 1.5) (28, 1.5)}; % Q signal \addplot[thick, red] coordinates {(3, 0.5) (7, 0.5) (7, 0) (15, 0) (15, 0.5) (19, 0.5)}; \addplot[thick, red] coordinates {(23, 0.5) (27, 0.5) (27, 0) (28, 0)}; % Circling the time violations. \draw[orange, thick] (axis cs: 17.75, 1.75) ellipse [x radius=0.5cm, y radius=1.25cm]; \draw[purple, thick] (axis cs: 26.25, 1.75) ellipse [x radius=0.5cm, y radius=1.25cm]; \end{axis} \end{tikzpicture} \end{document}We must then fix the output waveform by accounting for the unknown output during the hold-time violation. Since the clk-to-q delay is 1 ns, the hold-time violation will reflect in ‘s waveform 1 ns late, at . We do not know when the output reappears, since our input waveform ends at .
\usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ width=12cm, height=6cm, xlabel={Time (ns)}, ylabel={}, ymin=-0.5, ymax=3, xmin=0, xmax=28, xtick={0,2,4,6,8,10,12,14,16,18,20,22,24,26,28}, ytick={0.25, 1.25, 2.25}, yticklabels={Q, D, clk}, grid=major, grid style={dotted, gray}, xmajorgrids=true, ymajorgrids=false, extra y ticks={0, 0.5, 1, 1.5, 2, 2.5}, extra y tick labels={}, extra y tick style={grid=major}, ] % Clock signal \addplot[thick, black] coordinates {(0, 2) (2, 2) (2, 2.5) (4, 2.5) (4, 2) (6, 2) (6, 2.5) (8, 2.5) (8, 2) (10, 2) (10, 2.5) (12, 2.5) (12, 2) (14, 2) (14, 2.5) (16, 2.5) (16, 2) (18, 2) (18, 2.5) (20, 2.5) (20, 2) (22, 2) (22, 2.5) (24, 2.5) (24, 2) (26, 2) (26, 2.5) (28, 2.5)}; % D signal \addplot[thick, blue] coordinates {(0, 1.5) (4, 1.5) (4, 1) (7.5, 1) (7.5, 1.5) (8.5, 1.5) (8.5, 1) (11, 1) (11, 1.5) (12, 1.5) (12, 1) (13, 1) (13, 1.5) (16, 1.5) (16, 1) (17.5, 1) (17.5, 1.5) (24, 1.5) (24, 1) (26.5, 1) (26.5, 1.5) (28, 1.5)}; % Q signal \addplot[thick, red] coordinates {(3, 0.5) (7, 0.5) (7, 0) (15, 0) (15, 0.5) (19, 0.5)}; \addplot[thick, red] coordinates {(23, 0.5) (27, 0.5)}; % Circling the time violations. \draw[orange, thick] (axis cs: 17.75, 1.75) ellipse [x radius=0.5cm, y radius=1.25cm]; \draw[purple, thick] (axis cs: 26.25, 1.75) ellipse [x radius=0.5cm, y radius=1.25cm]; \end{axis} \end{tikzpicture} \end{document}