CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Sequential Logic

Decade Up/Down Counter

HardLogic CircuitBuild

Digital panel meters and bidirectional event counters require tracking values in human-readable base-10 format. The decade up/down counter handles non-power-of-two modulus arithmetic, requiring distinct wrap-around logic for each direction.

The circuit maintains a 4-bit state (Q3, Q2, Q1, Q0) that updates on the rising edge of the clock. A synchronous rst signal forces the state to 0. The dir signal controls the counting direction: 1 for UP, 0 for DOWN. The terminal flags COUT and BOUT are combinational outputs that assert only when the counter reaches its limit for the active direction.

Combinational Terminal Logic:

| Current State (Q3:Q0) | dir | COUT | BOUT | |---------------------------|-------|--------|--------| | 9 (1001) | 1 | 1 | 0 | | 0 (0000) | 0 | 0 | 1 | | All other valid states | X | 0 | 0 |

Sequential State Transitions:

| rst | dir | Current State | Next State (Q3:Q0) | |-------|-------|---------------|------------------------| | 1 | X | X | 0 (0000) | | 0 | 1 | 0 to 8 | State + 1 | | 0 | 1 | 9 | 0 (0000) | | 0 | 0 | 1 to 9 | State - 1 | | 0 | 0 | 0 | 9 (1001) |

Constraints

  • Implement using D flip-flops for the 4-bit state register.
  • COUT and BOUT must be implemented as purely combinational logic based on the current state and dir.
  • The counter must not enter states 10 through 15 during normal operation.

Topics

CountersState MachinesModulo

Solve this problem

Place the gates, wire them up and watch the signals settle. Every submission runs on the same simulation engine that grades it.

This problem is part of Codiode Pro. The statement above is free to read.

Sign in to solveSee what Pro unlocks

The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.

Related problems

  • 3-bit Ripple Counter from Toggle Flip-FlopsEasy
  • D Latch from a 2:1 MUXEasy
  • 2-bit Ring CounterEasy
  • T Flip-Flop from a D Flip-FlopEasy
  • Handshake Deadlock Due to Early ResetHard
  • Reconvergence of Individually Synchronized BitsHard
  • Debug: Asynchronous Clear GlitchHard
  • Clock Gate Enable Crossing DomainsHard

Browse all problems · Learning tracks