Part of Curriculum: Sequential RTL Design (Module 3: Clock Enables & Clock Gating)
View Full Roadmap →
Level 2 Medium ★ Flagship #19 25 pts ✓ Solved

Clock Enable Generator — Clock Enable Logic

Clocking & Timing · sequential, fsm, counters, medium, clock-division

Generate a single-cycle active-high clock enable pulse (ce) every 4 clock cycles without gating the system clock tree.

Write a synthesizable Verilog module named top_module matching the ports below exactly.
📐 Circuit Schematic Diagram
ince>clkrst_nCLOCK ENABLE GENERATDIGITAL HARDWARE BLOCK
⚡ Timing & Synthesizability Constraints

Timing Contract: Strobe `ce` must be asserted for exactly one clock period every 4 cycles.

RTL Constraints: Do NOT divide the clock net itself. Output `ce` is a synchronous data strobe.

Objective: Understand synchronous clock rate division, avoiding clock skew from gated clocks, and single-cycle strobe generation.

Prerequisites: Synchronous counters, clock domains, clock enable conventions.
NameDirWidthDescription
clkinput1Master high-frequency clock
areset_ninput1Active-low asynchronous reset
ceoutput1Single-cycle enable strobe (active 1 out of 4 cycles)
Expected Waveform (Golden Timing Contract)
💡 Need Guidance? Progressive Hints (3 Levels)
Hint 1: Conceptual Direction & Hardware Primitives
Use a 2-bit counter (`cnt[1:0]`) running on `clk`.
Hint 2: Implementation Architecture & Approach
Assert `ce` whenever the counter reaches its maximum value: `assign ce = (cnt == 2'b11);`.
Hint 3: Edge Cases, Timing & Verilog Syntax
This creates a clean, synchronous 1-in-4 strobe without creating a new asynchronous clock domain.
🔒 Reveal Verified Reference RTL Solution (Click to expand)
⚠️ Self-Discovery Warning: Try solving and simulating first! Viewing the verified reference implementation will bypass the real debugging experience.
Verified Synthesizable RTL
module top_module(
  input   clk,
  input   areset_n,
  output  ce
);
  reg [1:0] cnt;
  always @(posedge clk or negedge areset_n) begin
    if (!areset_n)
      cnt <= 2'b00;
    else
      cnt <= cnt + 1'b1;
  end
  assign ce = (cnt == 2'b11);
endmodule
Verilog-2001 / SV Saved
Font: |
// Click Run Tests (or press Ctrl+Enter) to compile your RTL and simulate against hidden testbenches.
Simulation Timing Diagram (VCD Waveform)
100%
No simulation waveform yet. Run tests to simulate and generate VCD traces.
No compilation run yet. Syntax warnings and elaboration messages will appear here.
No simulation output yet. Raw stdout from vvp will appear here.

RTL Problems / Level 2 · Clocking & Timing

What You Will Learn

By solving Clock Enable Generator — Clock Enable Logic, you will acquire core industry skills:

  • Synthesizable hardware modeling in standard Verilog-2001 / SystemVerilog.
  • Correct handling of interface port contracts, edge-triggered clocks, and active-low/high resets.
  • Simulation waveform interpretation and debugging using timing diagrams (VCD traces).
  • Architectural avoidance of timing violations, glitching hazards, and synthesis warnings.

Problem Statement & Requirements

Generate a single-cycle active-high clock enable pulse (ce) every 4 clock cycles without gating the system clock tree.

Hardware design teams at leading semiconductor firms evaluate these exact port contracts, race-condition assertions, and corner cases during technical design reviews and ASIC engineer interviews.

Objective: Understand synchronous clock rate division, avoiding clock skew from gated clocks, and single-cycle strobe generation.

Prerequisites: Synchronous counters, clock domains, clock enable conventions.

Port List & Interface Timing

The hidden testbench instantiates top_module. Module port names and bit-widths must match the interface contract exactly:

NameDirWidthDescription
clkinput1Master high-frequency clock
areset_ninput1Active-low asynchronous reset
ceoutput1Single-cycle enable strobe (active 1 out of 4 cycles)

Timing Constraints & Synthesizable RTL Rules

⚡ Synthesizable Implementation Guidelines

Timing Contract: Strobe `ce` must be asserted for exactly one clock period every 4 cycles.

Synthesis Constraints: Do NOT divide the clock net itself. Output `ce` is a synchronous data strobe.

Architectural Deep Dive & Implementation Walkthrough

In high-reliability RTL, never generate divided clocks by toggling a flip-flop (`always @(posedge clk) slow_clk <= ~slow_clk;`). Using `slow_clk` as a clock input elsewhere creates multi-clock domain crossing and clock skew issues. The professional industry pattern is to maintain a single unified master clock tree and distribute single-cycle `ce` pulses.

Common RTL Designer Pitfalls

⚠️ Common Mistakes to Avoid

['Creating ripple clocks instead of synchronous enable strobes.', 'Registering `ce` such that it becomes 2 cycles wide instead of exactly 1 cycle.']

Silicon & Hardware Engineering Notes

🛠️ ASIC vs FPGA Hardware Considerations

Synchronous clock enables keep all registers on the same primary low-skew clock distribution network, simplifying static timing analysis (STA).

Starter RTL Code

module top_module(
  input   clk,
  input   areset_n,
  output  ce
);

  // Generate single-cycle pulse every 4 clock cycles

endmodule

Verified Reference Solution

🔒 Reveal Verified Reference RTL Solution
module top_module(
  input   clk,
  input   areset_n,
  output  ce
);
  reg [1:0] cnt;
  always @(posedge clk or negedge areset_n) begin
    if (!areset_n)
      cnt <= 2'b00;
    else
      cnt <= cnt + 1'b1;
  end
  assign ce = (cnt == 2'b11);
endmodule

Related RTL Problems in Level 2

Frequently Asked Questions

What does Clock Enable Generator — Clock Enable Logic require?

Generate a single-cycle active-high clock enable pulse (ce) every 4 clock cycles without gating the system clock tree. Implement it as Verilog module top_module matching the listed ports.

Is this design combinational or sequential?

Tags: sequential, fsm, counters, medium, clock-division. If a clock signal is present in the port table, implement it as sequential logic; otherwise, use continuous assignments or combinational blocks.

How is my solution graded?

A hidden SystemVerilog testbench simulates your module in the cloud judge. You pass when all directed corner cases match the golden model and the VCD timing waveform matches the contract.

How does this challenge help with semiconductor interviews?

Technical interviewers at NVIDIA, Qualcomm, Apple, and Intel routinely ask candidates to code, debug, and explain the timing waveforms of Clock Enable Generator — Clock Enable Logic to assess real-world synthesizability and race-condition awareness.