DescriptionQ556
Q556DesignArchAMDASIC interview problem
Enabled modulo-five counter
TechniquesRTL DesignRTL / Microarchitectureenabled modulo-five counter
DifficultyEasy
TopicRTL Design
LanguageSystemVerilog
Requirements4 checkpoints
01
Problem
A controller cycles through five slots only when enable is asserted. Implement the modulo-five counter in synthesizable SystemVerilog.
Starting declarationSystemVerilog
input logic clk, rst_n, enable;
output logic [2:0] count;
output logic wrap;Example input and output
Use this case to check your interpretationInput
Before a rising edge: rst_n=1, count=3, enable=1.Output
After the edge: count=4 and wrap=0.Explanation
The enabled counter increments because the pre-edge value is below the terminal count of four; wrap remains low because no 4-to-0 transition occurred.
02
Requirements (4)
- On an enabled rising edge, count advances 0,1,2,3,4,0; on a disabled edge it holds.
- wrap pulses for exactly the enabled edge that changes count from 4 to 0.
- When rst_n=0 at a rising edge, set count=0 and wrap=0 regardless of enable.
- For all other enabled edges, wrap is zero and count never takes a value above 4.
