Lab 12 of 15 · rank 11

4-bit counter

Inputs CLK and EN. Outputs Q0–Q3 (Q0 the lowest bit), starting at 0. On each rising edge of CLK, if EN is 1, Q goes up by one, wrapping from 15 to 0. If EN is 0, Q holds.

← All labsNext lab →
  1. 1
    Build itPorts named CLK, EN and Q0, Q1, Q2, Q3
  2. 2
    Pass the truth table22 rows checked
  3. 3
    Etch it (optional)a verified die in your project
⊼
Cellsclick one, then click the canvas

Build your die

Turn logic into a permanent, verifiable part.

NAND used0 / par 20
LATCH used0 / par 8
Ainput · pin0Youtput · pin
Pick a cell on the left, click to place it · drag from an output pin to an input pin to wire · click a wire to remove it · click a cell to rename it
→ Y=0

What it should do

CLK ENQ0 Q1 Q2 Q3
0 counted pulses of 0 → Q=00 0 0 0
1 counted pulse of 1 → Q=11 0 0 0
2 counted pulses of 2 → Q=20 1 0 0
3 counted pulses of 3 → Q=31 1 0 0
4 counted pulses of 4 → Q=40 0 1 0
5 counted pulses of 5 → Q=51 0 1 0
6 counted pulses of 6 → Q=60 1 1 0
7 counted pulses of 7 → Q=71 1 1 0
8 counted pulses of 8 → Q=80 0 0 1
9 counted pulses of 9 → Q=91 0 0 1
10 counted pulses of 10 → Q=100 1 0 1
11 counted pulses of 11 → Q=111 1 0 1
12 counted pulses of 12 → Q=120 0 1 1
13 counted pulses of 13 → Q=131 0 1 1
14 counted pulses of 14 → Q=140 1 1 1
15 counted pulses of 15 → Q=151 1 1 1
16 counted pulses of 16 → Q=00 0 0 0
17 counted pulses of 17 → Q=11 0 0 0
0 counted pulses of 3 → Q=00 0 0 0
3 counted pulses of 5 → Q=31 1 0 0
5 counted pulses of 8 → Q=51 0 1 0
16 counted pulses of 18 → Q=00 0 0 0

Stuck?

A chain of half adders adds EN to Q (bit 0 gets EN, each next bit gets the carry below). Four DFFs clocked by CLK store the sums.

Par is 20 NAND and 8 LATCH. Using more still passes here. To etch it as a verified die that mines, keep it within 72 NAND-equivalent (a LATCH counts 2): the verifier refuses bigger designs, so padding can't buy mining weight.

Etch it as a die (optional)

Turn this circuit into a verified die you own. It burns 0 NAND. Get materials at the Foundry.

connect a wallet to pick a project