Hardware interview practice
Implement a divide-by-four clock model
For simulation or FPGA-style RTL, divide clk by four with a resettable two-bit counter. Also state the safe ASIC implementation rule for a generated clock.
Starting point
Question code
input logic clk, rst_n;
output logic clk_div4;Reviewed example
Work through one case
Input
Counter starts at 00; apply four rising edgesExpected output
counter: 01,10,11,00; clk_div4: 0,1,1,0The counter MSB completes one period for every four source-clock periods.
What to cover
Requirements
- Clear the two-bit counter with active-low asynchronous reset.
- Increment it on every rising edge while reset is inactive.
- Drive clk_div4 from counter bit 1 for a 50 percent steady-state duty cycle.
- For ASIC clock consumers, require an approved clock-generation primitive and generated-clock constraint.
