Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
    • Flip-Flops and Registers
      • Edge-Triggered State Elements
      • D Flip-Flop with Asynchronous Reset
      • Synchronous Reset and Register Enable
      • Clock Enable vs Gated Clock
      • A Hold Violation, Worked
    • Counters and Timers
    • Shift Registers and LFSRs
    • Pipelining
    • Stalls, Bubbles and Hazards
    • Retiming
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
  • Glossary and Notation
Loading lesson

‹Sequential Design
  1. Topics
  2. RTL Design
  3. Sequential Design
  4. Flip-Flops and Registers

Part 3 · Sequential · Intermediate

Flip-Flops and Registers

Flip-flops sample data at the clock edge, with reset, enable, and clock-gating options.

  • 5topics
  • 5lessons

Topics in this section

  1. 1Edge-Triggered State Elements1 lesson
  2. 2D Flip-Flop with Asynchronous Reset1 lesson
  3. 3Synchronous Reset and Register Enable1 lesson
  4. 4Clock Enable vs Gated Clock1 lesson
  5. 5A Hold Violation, Worked1 lesson
On this page

    Sequential logic stores state in flip-flops. A flop samples its data input at the active clock edge and holds it until the next edge.

    A flip-flop with data, clock, reset and enable inputs and a Q output.
    The inputs of a typical register: data, clock, optional reset and optional enable.

    Lessons in this topic

    5 lessons, about 25 min

    1. 1Edge-Triggered State ElementsYou can state what a D flip-flop does at an edge, define setup, hold and clock-to-Q, and compute the minimum clock period for a register-to-register path.3 min
    2. 2D Flip-Flop with Asynchronous ResetYou can write a flop with asynchronous reset, explain recovery and removal, and draw the reset synchroniser that gives asynchronous assertion with synchronous release.4 min
    3. 3Synchronous Reset and Register EnableYou can code a register with synchronous reset and enable, put reset first, and explain which registers need a reset at all.4 min
    4. 4Clock Enable vs Gated ClockYou can choose between a clock enable and clock gating, and explain why a gating enable must be latched while the clock is high.6 min
    5. 5A Hold Violation, WorkedYou can compute hold slack from clock-to-Q, wire delay, hold time and skew, place the arrival on a timeline, size a fix, and explain recovery and removal for a reset release.8 min
    Check yourself A flip-flop with a 0.05 ns hold time sees D change 0.1 ns after the active clock edge. Which value does it capture?

    The old value, the one present at the edge. The change arrives after the 0.05 ns hold window, so it leaves the sample alone and waits for the next edge. A change inside the hold window can take the wrong value or cause metastability. Ideal RTL simulation assumes zero delay unless a hold time is given.

    Interview

    “Draw the timing diagram of a D flip-flop”, “synchronous vs asynchronous reset”, and “clock enable vs clock gating” appear in almost every RTL interview. Each has a lesson here.

    Revision sheet

    The whole topic on one page, taken from each lesson's Remember box. Read it before an interview, or print it.

    Edge-Triggered State Elements

    • After edge n, Q holds the D value from just before that edge. Use a nonblocking assignment in always_ff.

    • D must be stable for setup before the edge and hold after it; a change inside the window can capture the wrong value or cause metastability.

    • A slower clock cures setup violations but not hold violations.

    Rule of thumb: a flop passes data only at the edge; a latch passes it while its enable is active.

    D Flip-Flop with Asynchronous Reset

    • Asynchronous reset clears Q at once, without waiting for a clock edge.

    • Release has recovery and removal times, like setup and hold; RTL simulation does not model them.

    • Never build a reset from combinational logic. Use one reset synchroniser per clock domain.

    Rule of thumb: assert asynchronously, release synchronously.

    Synchronous Reset and Register Enable

    • A synchronous reset is ordinary D logic; the sensitivity list holds the clock alone.

    • Reset is written first so it wins over enable and works even when the enable is low.

    • Reset only control state, valid bits and pointers. A synchronous reset needs a running clock.

    Rule of thumb: reset comes first in the priority chain.

    Clock Enable vs Gated Clock

    • A clock enable reloads Q every edge and the clock tree keeps toggling; a gated clock stops the edges.

    • Write plain enables; in an ASIC flow, synthesis inserts ICG cells on banks that share an enable. On FPGAs use clock enables.

    • Gating adds glitch, skew and scan-test constraints on the clock path.

    Rule of thumb: never gate a clock with a bare AND; use a latch or an ICG cell.

    A Hold Violation, Worked

    • Hold slack = t_cq,min + t_logic,min - (t_hold + skew). The clock period is not in it.

    • Positive skew (capture clock late) pushes the hold window later and eats hold slack; direct flop-to-flop links are the usual victims.

    • Recovery and removal are setup and hold for the release of an asynchronous reset; release it from a flop on the same clock.

    Rule of thumb: if a hold fix involves the clock period, it is not a hold fix.

    Practise it

    • Mini project: a programmable timer with prescaler, compare and interrupt

    • Practice question: Synchronous D flip-flop with reset

    • Code lab: 8-bit D flip-flop

    • Practice question: Asynchronous-reset flip-flop: glitch-free reset and metastability

    • Practice question: Debugging metastability from asynchronous reset deassertion

    • Code lab: D flip-flop with asynchronous reset

    • Interview: run a mock interview on this topic

    PreviousNext: Edge-Triggered State Elements

    Up next

    Up nextEdge-Triggered State Elements

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Counters and Timers
    • Shift Registers and LFSRs
    • Pipelining