Q193FreeSystemVerilog
Implement a divide-by-four clock model
Interview prompt
Question
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.
Candidate starting point
Implementation scaffold
module clock_div4 (
input logic clk, rst_n,
output logic clk_div4
);
logic [1:0] count;
always_ff @(posedge clk or negedge rst_n) begin : count_source_edges
// TODO: clear or increment the two-bit counter.
end
always_comb begin : divided_output
// TODO: drive clk_div4 from the specified counter bit.
end
// TODO: state the ASIC generated-clock implementation rule.
endmoduleReviewed example
Trace 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.
