BitFlow

12-Hour Digital Clock

intermediate · sequential · 200 XP

Sign in to write your solution, run it in the simulator and submit it for grading.

Sign in or create a free account →

Problem

12-Hour Digital Clock Chain BCD decade counters to build a complete **HH:MM:SS digital clock**. This is the capstone of the counter section — it requires parameterised counters, carry chaining, BCD, and rollover logic with non-standard boundaries. **Interface** | Port | Direction | Width | Description | |-----------|-----------|-------|--------------------| | `clk` | input | 1 | 1 Hz clock (1 tick/second) | | `rst` | input | 1 | Synchronous reset | | `s0[3:0]` | output | 4 | Seconds units (0–9) | | `s1[3:0]` | output | 4 | Seconds tens (0–5) | | `m0[3:0]` | output | 4 | Minutes units (0–9) | | `m1[3:0]` | output | 4 | Minutes tens (0–5) | | `h0[3:0]` | output | 4 | Hours units (combined with h1) | | `h1[3:0]` | output | 4 | Hours tens (0 or 1) | **Rollover rules:** - `s0`: 0–9 → carry to s1 - `s1`: 0–5 → carry to m0 (seconds tens max = 5) - `m0`: 0–9 → carry to m1 - `m1`: 0–5 → carry to hours - **Hours: 01–12 → rolls to 01** (never 00, never 13) On reset, clock starts at **12:00:00**. **The 12→01 rollover** is the tricky part. Implement `h1` and `h0` separately. The rollover fires when `h1==1 && h0==2` (i.e. 12) — and rolls to h1=0, h0=1 (01:00:00).

Constraints

  • 00:00:00 must never appear.
  • 13:00:00 must never appear.
  • Hours roll 12→01, not 12→00.
  • Reset must initialise to 12:00:00.
  • s1 and m1 max out at 5 (0–5 only).

Examples

Input: After reset

Output: h1=1, h0=2, m1=0, m0=0, s1=0, s0=0 (12:00:00)

Reset value

Input: At 12:59:59, next clk

Output: h1=0, h0=1 → 01:00:00

12→01 rollover

Input: At 01:00:00, next clk

Output: 01:00:01

Normal increment from 01

Common questions

What does the 12-Hour Digital Clock problem ask you to build?
12-Hour Digital Clock Chain BCD decade counters to build a complete **HH:MM:SS digital clock**. This is the capstone of the counter section — it requires parameterised counters, carry chaining, BCD, and rollover logic with non-standard boundaries.
What constraints does 12-Hour Digital Clock have?
00:00:00 must never appear.; 13:00:00 must never appear.; Hours roll 12→01, not 12→00.; Reset must initialise to 12:00:00.; s1 and m1 max out at 5 (0–5 only).
What is an example input and output for 12-Hour Digital Clock?
Input After reset gives output h1=1, h0=2, m1=0, m0=0, s1=0, s0=0 (12:00:00). Reset value
Which Verilog concepts does 12-Hour Digital Clock practise?
sequential, counter, BCD, capstone, clock.