Skip to content
BetterDL

Up/down counter

Also called: bidirectional counter, reversible counter, U/D counter

A counter with a direction input, often called U: when U = 1 it counts up at each clock edge, and when U = 0 it counts down.

An up/down counter combines a binary up counter and a down counter in one circuit. A control input U picks the direction at every edge: U = 1 counts up, U = 0 counts down.

With T flip-flops, each T input is an OR of the two toggle conditions, each gated by the direction:

  • T0 = 1 (Q0 toggles either way)
  • T1 =
  • T2 =

The U term is the up rule (every lower bit is 1); the term is the down rule (every lower bit is 0). Only one of them can be active at a time.

U is sampled at each clock edge, just like a data input, so the direction can change from one edge to the next. U must be stable for the setup time before the edge. Up/down counters are used for position tracking (a rotary encoder turning either way), stack pointers and up/down timers.

T2T1
00011
00100
01001
01100
10000
10101
11000
11111

Worked examples

Example

Changing direction

A 3-bit up/down counter starts at 110 (6). U at the next six edges is 1, 1, 0, 0, 0, 1.

  1. 1.

    U = 1: 6 → 7 (111).

  2. 2.

    U = 1: 7 → 0 (000), wrapping up.

  3. 3.

    U = 0: 0 → 7 (111), wrapping down.

  4. 4.

    U = 0: 7 → 6 (110).

  5. 5.

    U = 0: 6 → 5 (101).

  6. 6.

    U = 1: 5 → 6 (110).

Example

Checking the T inputs

The counter holds 100 with U = 0. Use the equations to find the next state.

  1. 1.

    T0 = 1 → Q0 toggles 0 → 1.

  2. 2.

    T1 = = 0 + 1·1 = 1 → Q1 toggles 0 → 1.

  3. 3.

    T2 = = 0 + 1·1·1 = 1 → Q2 toggles 1 → 0.

  4. 4.

    Next state 011 = 3 = 4 − 1 ✓.

Common mistakes

  • Writing T1 = and forgetting the down term. With U = 0 that never toggles Q1, so the counter can't count down.

  • Using only the next bit down in the down term. T2 needs , both lower bits 0.

  • Expecting a change of U to act mid-cycle. Like every input of a synchronous counter, it only matters at the edge.

Practice Up/down counter

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Up/down counter is taught in Counters.