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

  • Logic Synthesis Glossary
  • Logic Synthesis Cheatsheet
  • Synthesis Foundations14
  • Logic Optimisation and Mapping20
  • Constraints and Timing15
  • Sequential, FSM and Memory19
    • Flops, Resets and Enables
      • D Flop Inference
      • Enables: Mux or Clock Enable
      • Synchronous and Asynchronous Reset
      • Reset-less Flops and Initial Values
      • Mapping Flops to Library Cells
    • FSM Synthesis
    • Memory and Macro Inference
    • Retiming and Pipelining
  • Datapath Synthesis14
  • Area, Power and Test14
  • Verification, ECO and Handoff15
  • Flows and Debugging15
  • Interview and Judgment11
Loading lesson

‹Flops, Resets and Enables
  1. Topics
  2. Logic Synthesis
  3. Sequential, FSM and Memory
  4. Flops, Resets and Enables
  5. Enables: Mux or Clock Enable

Part 4 · Sequential, FSM and Memory · Intermediate

Enables: Mux or Clock Enable

Enabled flops infer $dffe, built from a mux or a clock-enable cell.

On this page

    The enabled flop idiom

    Guarding the load with if (en) infers an enabled flop. When the enable is low the flop keeps its value.

    Spelling the same behaviour as q <= en ? d : q infers the same cell. The tool recognizes the feedback-mux pattern in both forms.

    What Yosys builds

    The script below infers a one-bit enabled flop and pins its family. It asserts one $dffe cell and no plain or reset variants.

    yosys
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    read_verilog <<EOV
    module top(input clk, input en, input d, output reg q);
    always @(posedge clk) if (en) q <= d;
    endmodule
    EOV
    hierarchy -check -top top
    proc
    opt
    select -assert-count 1 t:$dffe
    select -assert-none t:$dff
    select -assert-none t:$adff
    select -assert-none t:$sdff
    log PASS: enabled flop infers one $dffe cell

    Mux feedback or clock enable

    Two structures implement the enable. A mux recirculates the output when disabled, while a clock-enable cell keeps the clock pin toggling but blocks internal capture when disabled, saving data switching rather than pin toggling.

    Structure

    Logic

    Trade-off

    Mux feedback

    DFF plus a MUX2 per bit

    Works in every library; the clock still toggles each cycle.

    Clock-enable cell

    A flop with an enable pin

    Less internal switching when idle; needs care in the clock tree.

    The teaching library offers no clock-enable cell, so an enabled flop maps to a DFF plus feedback logic here. Libraries with such a cell map $dffe to it instead, so the mapping varies.

    Diagram
    course.lib EXAMPLE areas: DFF = 8 units, MUX2 = 5 units
    mux-feedback enable, per bit: 8 + 5 = 13 units
    8-bit enabled register here: 8 x 13 = 104 units

    Common mistakes

    Gating the clock signal with logic (clk & en) is not an enable. It builds a skewed derived clock that static timing cannot treat as data.

    Common pitfall

    A hand-built gated clock and a clock-enable cell look similar in RTL but differ in hardware. Write if (en) inside the clocked block and let the tool pick the cell; never AND the clock net yourself.

    Interview

    Likely probes: $dffe spelling and the mux-versus-cell choice.

    • if (en) around the load infers an enabled flop: $dffe with no reset.

    • Mux feedback works everywhere and keeps the clock toggling.

    • A clock-enable cell blocks internal capture when disabled, saving data switching rather than pin toggling.

    Check yourself An enabled flop sits in a library with no clock-enable cell. What does the tool build?

    A DFF plus per-bit feedback mux logic. The $dffe behaviour stays identical; only the structure differs.

    Check yourself Why is if (en) q <= d preferred over ANDing the clock with en?

    The first is data timed like any synchronous input. The second builds a new clock that needs its own tree and timing treatment.

    Testbench

    The testbench below checks hold-when-disabled and load-when-enabled across four clock edges.

    en_flop.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    module en_flop (
      input logic clk, input logic rst, input logic en, input logic d, output logic q
    );
      always @(posedge clk) begin
        if (rst) q <= 1'b0;
        else if (en) q <= d;
      end
    endmodule
    
    module tb_en_flop;
      logic clk = 0, rst = 1, en = 0, d = 0;
      logic q;
      en_flop dut (.*);
      always #5 clk = ~clk;
      int errors = 0;
      initial begin
        #12; rst = 0; #1;
        if (q !== 1'b0) errors++;
        d = 1; en = 0; @(posedge clk); #1;
        if (q !== 1'b0) errors++;
        en = 1; @(posedge clk); #1;
        if (q !== 1'b1) errors++;
        en = 0; d = 0; @(posedge clk); #1;
        if (q !== 1'b1) errors++;
        if (errors == 0) $display("PASS: enabled flop holds without enable and loads with it");
        $finish;
      end
    endmodule

    Related topics

    • D Flop Inference

    • Synchronous and Asynchronous Reset

    • Clock Gating and Low Power

    Previous

    53 / 139

    Next: Synchronous and Asynchronous Reset

    Up next

    Up nextSynchronous and Asynchronous Reset

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Reset-less Flops and Initial Values
    • Mapping Flops to Library Cells