Odd value counter

Problem Description
π§ Problem: Odd Value Counter
An odd value counter generates a sequence of odd numbers starting from 1.
On every rising edge of the clock, the counter increments by 2.
When reset is asserted, the counter must restart from 1.
π₯ Inputs
clkβ Clock signalresetβ Synchronous, active-high, and sampled on the rising edge of the clock
π€ Output
cnt_o [3:0]β 3-bit odd value counter output
β Functional Requirements
Counter starts from 1
On every positive edge of the clock, increment by 2 from previous value.
When
reset = 1at a rising clock edge, counter resets to 1.Once couner reaches its max value, it should start from 3 again
Sequence generated:
1, 3, 5, 7, 9, ...
π Example
Clock Edge | Reset | Output ( |
|---|---|---|
β | 1 | 1 |
β | 0 | 3 |
β | 0 | 5 |
β | 0 | 7 |
β | 0 | 9 |
β | 0 | b |
β | 0 | d |
β | 0 | f |
β | 0 | 3 |
β | 0 | 5 |
β | 0 | 7 |
β | 1 | 1 |
β | 0 | 3 |
β | 0 | 5 |
π¨βπ» User Code Information
Implement only the logic inside the given module
Do not modify module name, ports, or signal widths
Use posedge clocked logic
Do not use delays (
#) orinitialblocks in user codeCounter must be reset-safe
Solution will be evaluated using a self-checking testbench
Verilog
Code Editor Access
Log in to write, run and submit your solution to this interview question. It's free.
