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

Up/Down Counter: Overflow and Underflow Detection

MediumLogic CircuitBuild

Multi-stage bidirectional systems like CNC position trackers and digital volume controls rely on cascaded counters to track large values. Overflow and underflow detection enables this cascade: the carry-out of one stage directly drives the count-enable of the next stage.

Design a 4-bit synchronous up/down counter that accurately signals when it reaches its terminal bounds. The counter maintains a 4-bit state Q and updates on the rising clock edge based on the active-high enable EN and direction control DIR.

| EN | DIR | RST | Action | |------|-------|-------|--------| | X | X | 1 | Q becomes 0 | | 0 | X | 0 | Q holds state | | 1 | 1 | 0 | Q increments | | 1 | 0 | 0 | Q decrements |

The circuit must provide two strictly combinational status flags: COUT asserts HIGH when the counter is at its maximum value (15) AND the direction is set to UP (DIR = 1). BOUT asserts HIGH when the counter is at its minimum value (0) AND the direction is set to DOWN (DIR = 0).

Constraints

  • Implement a 4-bit synchronous counter with an active-high synchronous reset.
  • COUT and BOUT must be completely combinational and gate their respective terminal counts with the DIR signal.
  • Do not assert COUT when counting down from 15, and do not assert BOUT when counting up from 0.

Topics

Sequential LogicCountersState Machines

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