# Tiny Tapeout Project: 4-Bit Counter and Registers Demo
This mostly is a placeholder "Hello, World" design that satisfies the following criteria:
- Something a beginner could come up with on their first day
- Reasonably well-documented to be easily understandable
- Includes some very basic state-management,
rather than implementing a simple boolean logic function
- "No innovation": Just basics - nothing that would inherently be regarded
as a novel idea for how to build circuits.
This circuit consists of two parts:
- (Right in the circuit diagram): A simple 4-bit counter.
- (Left in the circuit diagram): Logic to store/lad data, using two 4-bit registers.
## Binary Counter
When a clock signal is applied, the output pins B0, B1, B2, B3
count up in binary. With bits shown in this B0,...B3-order(!),
we cycle through `0000, 1000, 0100, 1100, 0010, ..., 1111`.
Exercise: Delete the "Register" logic and extend the 4-bit counter
circuit to a 6-bit counter.
Question 1: For the 6-bit counter, on a "rising clock edge",
when the D flip-flops "learn" (i.e. "sample") their new state,
what is the "longest" signal pathway - in terms of
"length of the chain of logic gates we have to go through
between a flip-flop output and a flip-flop input"?
Question 2: Suppose this path were much longer - say, 32 gates.
Would you expect the length of this path to have an impact on
the maximal clock frequency we can use this circuit with,
all other things (i.e. transistor sizes) being equal?
What would you expect to happen if one kept increasing the
clock frequency on such a circuit?
## Registers
Using Inputs IN0,IN1,IN2, we can make the circuit "remember"
two different 4-bit values and also show them.
Exercise: Using the DIP switches, first store the value 1110 in register A,
then store the value 0101 in register B, then set the inputs IN3-IN6 to zero
and retrieve first the content of A, then the content of B. Note that this
will require a bit of thinking about the sequence in which to change IN0,IN1,IN2.
# Context
This project is derived from the "Tiny Tapeout Template Project":
https://wokwi.com/projects/354858054593504257
See the description of this template for more context and detail.
Note that all LEDs in the circuit are not part of the "Input to Output pathway".
As such, these will naturally not be part of the synthesized circuit -
they are "for debugging only".
RST
CLK
Universal Principles:
1. "If all lower bits are 1, then we flip in the next step".
2. XOR-gate are used as: "if AND(lower bits) is zero, forward Q, otherwise flip".
switch=left: use clock-generator
switch=right: button sends clock signal
("Debugging" LEDs - only the part between INPUT and OUTPUT will be put onto the chip.)
B0
B1
B2
B3
(click to edit)
B0
B0 AND B1
B0 AND B1 AND B2
B1
B2
B3
"Register B"
IN0 AND IN1 AND IN2 AND (NOT IN7)
This part: A simple 4-Bit Counter
This part: Two "registers":
Setting (IN0, IN1, IN2) to (0,1,1) stores (IN3,IN4,IN5,IN6) in "register A"
Setting (IN0, IN1, IN2) to (1,1,0) stores (IN3, IN4, IN5, IN6) in "register B"
Setting (IN0, IN1, IN2) to (1,1,1) shows either register A or register B
on (OUT4, OUT5, OUT6, OUT7), where IN7 selects between these registers.
IN7=0: Show A, IN7=1: Show B
("4-Bit-Register-Output")
("Counter-Output")
"Register A"
THIS PART: 4-Bit Counter
THIS PART: Two Settable Registers