Codiode
All tracks
Circuit Lab · Intermediate

Latches and Flip-Flops

Add memory to your circuits. Understand every latch and flip-flop type, timing constraints and type conversions.

PrerequisitesGate-Level Logic
What you will learn

Flip-flops are the memory elements behind every register and processor. This track covers:

  • SR latch using NOR and NAND gates
  • Gated SR latch, D latch
  • D, T and JK flip-flops (edge-triggered)
  • Master-slave flip-flop
  • Synchronous and asynchronous reset variants
  • Flip-flop type conversions: D to T, D to JK, T to JK
  • Setup time, hold time, propagation delay and metastability
126 problems in 13 sections
126 problems in 13 sections
Section 1

SR Latch (NOR Gates)

8
01SR NOR Latch: Basic ConstructionBuild10 GE02SR NOR Latch: Normal Operation Waveform TraceTiming10 GE03SR NOR Latch: Forbidden State BehaviorTiming15 GE04SR NOR Latch: Race Condition on Simultaneous Forbidden-State ReleaseTiming25 GE05SR NOR Latch: Memory Phase Duration VerificationTiming15 GE06SR NOR Latch: Q_bar Polarity and Active LevelBuild15 GE07SR NOR Latch: Missing Cross-Coupling Wire DebugDebug15 GE08SR NOR Latch: Set-Dominant ConfigurationBuild15 GE
Section 2

SR Latch (NAND Gates)

6
09SR NAND Latch: Active-Low Input ConstructionBuild10 GE10SR NAND Latch Active-Low OperationTiming10 GE11SR NAND Latch: Forbidden StateTiming15 GE12SR NAND Latch: Simultaneous Forbidden-State Release RaceTiming25 GE13NOR vs. NAND Latch InterfaceBuild15 GE14SR NAND Latch Stuck Forbidden State DebugDebug15 GE
Section 3

Gated SR Latch

8
15Gated SR Latch: 4-NAND ConstructionBuild15 GE16Gated SR Latch: Transparency Window TraceTiming10 GE17Gated SR Latch: Glitch Propagation During Enable WindowTiming15 GE18Gated SR Latch: Forbidden State During Enable WindowTiming25 GE19Gated SR Latch: Output Holds When Enable Drops Mid-StateTiming15 GE20Gated SR Latch: Active-Low EnableBuild15 GE21Gated SR Latch: Enable Connected to Wrong NAND Input DebugDebug25 GE22Gated SR Latch: Enable Gate AdditionBuild10 GE
Section 4

D Latch

8
23D Latch: Construction from Gated SR LatchBuild10 GE24D Latch: 4-NAND Direct ConstructionBuild15 GE25D Latch: Transparency Window TraceTiming10 GE26D Latch: Late Glitch Captured at Enable Falling EdgeTiming15 GE27D Latch: Transparency Hazard with Combinational GlitchesTiming25 GE28D Latch: Asynchronous Preset and Clear InputsBuild15 GE29D Latch vs. D Flip-FlopTiming15 GE30D Latch: Permanently-Enabled Latch DebugDebug15 GE
Section 5

D Flip-Flop (Edge-Triggered)

11
31Positive Edge-Triggered DFF: Master-Slave ConstructionBuild10 GE32Negative Edge-Triggered DFF: CLK Polarity SwapBuild10 GE33DFF: Edge-Triggered Capture vs. Level-Sensitive TransparencyTiming10 GE34DFF: Mid-Cycle Input ChangeTiming15 GE35DFF: Setup Time ViolationTiming15 GE36DFF: Clock-to-Q Propagation Delay on WaveformTiming10 GE37DFF with Clock EnableBuild15 GE38Two DFFs in Series: Pipeline LatencyTiming15 GE39DFF: Setup and Hold ViolationsTiming25 GE40DFF: Propagation Delay Accumulation in 4-FF Ripple ChainTiming25 GE41DFF: Reset Priority vs. Data PriorityTiming15 GE
Section 6

T Flip-Flop

10
42T Flip-Flop: Construction from DFF via Excitation EquationBuild10 GE43T Flip-Flop: Toggle and Hold Waveform TraceTiming10 GE44T Flip-Flop: T=1 Permanent (Frequency Division by 2)Timing10 GE45T Flip-Flop: 2-Bit Binary Ripple Counter WiringBuild15 GE46T Flip-Flop: Which T Value Is Captured When T Changes at the Clock EdgeTiming15 GE47T Flip-Flop with Synchronous ClearBuild15 GE48T Flip-Flop: Propagation Delay Accumulation in 3-Stage Ripple CounterTiming15 GE49T Flip-Flop Conversion to JKBuild25 GE50T Flip-Flop: Divide-by-3 Counter DesignBuild25 GE51T Flip-Flop: Reset-Then-Toggle Interaction at Adjacent EdgesTiming25 GE
Section 7

JK Flip-Flop

11
52JK Flip-Flop: Construction from DFF via Excitation EquationBuild10 GE53JK Flip-Flop: All Four Input CombinationsTiming10 GE54JK Flip-Flop: Toggle Input Stable Value Governs BehaviorTiming15 GE55JK Flip-Flop: Construction Directly from SR NAND LatchBuild25 GE56JK Flip-Flop: Race-Around Condition in Pulse-Triggered VersionTiming25 GE57JK Flip-Flop: J and K Input Swapped DebugDebug25 GE58JK Flip-Flop with Synchronous EnableBuild15 GE59JK Flip-Flop: Self-Feedback Sequence GeneratorTiming15 GE60JK Flip-Flop: Hold Violation Risk from Toggle OperationTiming25 GE61JK Flip-Flop with Asynchronous Preset and ClearBuild15 GE90SR Flip-Flop from JK Flip-FlopBuild25 GE
Section 8

Master-Slave Flip-Flop

7
62D Master-Slave Flip-Flop: Two D Latches ConstructionBuild10 GE63D Master-Slave: Internal Node TraceTiming15 GE64JK Master-Slave: 1s-Catching ProblemTiming25 GE65JK Master-Slave Flip-Flop: ConstructionBuild15 GE66Master-Slave vs. Edge-Triggered DFF: Glitch Rejection ComparisonTiming15 GE67Edge-Triggered DFF from 3 NAND LatchesBuild25 GE68Master-Slave: Internal Node PropagationTiming15 GE
Section 9

DFF with Asynchronous Reset

7
69DFF with Active-Low Asynchronous Reset: ConstructionBuild10 GE70Asynchronous Reset: Immediate Q Clearing Between Clock EdgesTiming10 GE71DFF with Active-High Asynchronous Reset: Gate-Level Polarity ConversionBuild15 GE72DFF with Both PRE and CLRBuild25 GE73Asynchronous Reset: Reset Recovery Time ViolationTiming15 GE74DFF with Asynchronous Reset and Clock EnableBuild15 GE75Asynchronous Reset Release: Which Cycle Does Q Recover?Timing25 GE
Section 10

DFF with Synchronous Reset

6
76DFF with Synchronous Active-Low ResetBuild10 GE77Synchronous Reset: One Clock Cycle Delay WaveformTiming10 GE78Synchronous Reset PriorityTiming15 GE79DFF with Synchronous Set and Reset: Priority-Encoded D PathBuild15 GE80Synchronous Reset Released at Same Edge as DataTiming25 GE81Synchronous Reset Wired to Asynchronous Path DebugDebug15 GE
Section 11

Flip-Flop Type Conversions

12
82D to T ConversionBuild10 GE83T to D Conversion: DFF from T Flip-FlopBuild10 GE84D to JK Conversion: DFF from JK Flip-FlopBuild15 GE85D to SR Conversion: SR Flip-Flop from DFFBuild15 GE86SR to D Conversion: DFF from SR Flip-FlopBuild10 GE87JK to T Conversion: T Flip-Flop from JK Flip-FlopBuild25 GE88T to JK ConversionBuild25 GE89SR to JK ConversionBuild25 GE91D-to-JK ConversionBuild25 GE92Verify D-to-T Conversion: Trace Q Through XOR GateTiming15 GE93Verify T-to-JK Conversion: Trace Feedback PathTiming25 GE94Wrong Conversion Identification: T=D Instead of T=D XOR QTiming15 GE
Section 12

Timing Analysis

16
95Setup and Hold Time Windows: Waveform AnnotationTiming10 GE96Clock-to-Q DelayTiming10 GE97Maximum Clock Frequency: T_min ComputationAnalyze10 GE98Setup Time Constraint: Maximum Allowed Combinational DelayAnalyze15 GE99DFF: Hold Time ViolationTiming15 GE100Critical Path: 4-Stage Pipeline IdentificationTiming15 GE101Clock Skew: Effect on Timing MarginAnalyze15 GE102Metastability: D Transition Inside Setup-Hold WindowTiming25 GE103MTBF Calculation for 2-FF SynchronizerAnalyze25 GE104Propagation Delay Asymmetry: Rising vs. Falling OutputTiming15 GE105Hold Constraint in Zero-Delay Path: Buffer InsertionTiming25 GE106Retiming: Moving a Register to Balance Pipeline StagesTiming25 GE107Timing Margin: Slack Calculation and Sign ConventionAnalyze15 GE108Minimum Pulse Width: Setup Plus Hold ConstraintAnalyze25 GE109Complete Timing Budget: Distributing t_comb Across Multiple Logic StagesAnalyze25 GE110Hold Margin Calculation with SkewAnalyze25 GE
Section 13

Metastability and Synchronization

16
111Async Input Without Synchronizer: Direct DFF ConnectionTiming10 GE1122-FF Synchronizer: Construction and LabelingBuild10 GE113Why One FF Is Insufficient for SynchronizationTiming15 GE114Additional Synchronizer Stages: Probability Reduction, Not EliminationAnalyze15 GE115Pulse SynchronizerBuild25 GE116Gray-Code Counter for Safe Multi-Bit CDCAnalyze25 GE1172-FF Synchronizer: Metastability ResolutionTiming15 GE118Analyze: Simulation Delta CyclesAnalyze25 GE119Debug: Read Before Write In Sequential BlockDebug25 GE120Debug: Polarity Mismatch in Reset ConditionDebug15 GE121Analyze: Array Initialization vs Hardware ResetAnalyze25 GE122Debug: Clock Enable in Sensitivity ListDebug15 GE123Analyze: Missing Else in Edge Triggered BlockAnalyze15 GE124Missing Reset Causing Undefined StateDebug10 GE125SystemVerilog Always Latch vs Always CombAnalyze10 GE126Interpreting Yosys Latch WarningsAnalyze10 GE