Odd value counter

AMD

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 signal

  • reset β€” 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 = 1 at 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 (cnt_o)

↑

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 (#) or initial blocks in user code

  • Counter 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.

Output

Output goes here...