Professional Documents
Culture Documents
By Ali El Moselhy,
Sandy Shan,
and Peter He
Table of Contents:
- Introduction
- What is a Circuit?
- What are Logic Gates?
- What are Binary Numbers?
- What is a Comparator?
- What is a Clock?
- What are Flip-Flops?
- Putting it all together…
Introduction
- Our task was to construct a traffic light simulator which operated in three
different modes:
- Blinking red and yellow
- Solid red
- Standard operation (green, yellow and red)
- Here is a picture of the final circuit:
A B X
0 0 0
0 1 0
1 0 0
1 1 1
OR gates
- OR gates output HIGH if any input is HIGH. Otherwise, they output LOW:
A B X
0 0 0
0 1 1
1 0 1
1 1 1
XOR gates
- XOR gates output a HIGH if ONLY ONE input is HIGH. Otherwise, they output
LOW:
A B X
0 0 0
0 1 1
1 0 1
1 1 0
NOR gates
- NOR gates negate the output of an OR gate. They output HIGH when all
inputs are 0. Otherwise, they output LOW:
A B X
0 0 1
0 1 0
1 0 0
1 1 0
Binary Numbers
- Binary numbers are numbers stored in a format that the computer can
understand:
- How can we differentiate between 0, 1, 2, … 8, 9? We can’t…
- We DO have values of either 0 or 1, so we can use a system of binary numbers.
- Each place value in a binary number represents a power of two:
1101 = 1 + 4 + 8 = 13
4th place 1st place
value: 1*23 value: 1*20
- Clock circuit:
What are Flip-Flops?
- Flip-flops are devices which act as basic memory - they can store a single bit
each.
D Input Pin
Q Output
J, K Input Pins
Q Output
- The most useful thing to us is the behavior when both J and K are one: the
chip toggles back and forth between 0 and 1.
Counters
- Think of counting in binary:
- Each digit only changes (toggles) when every preceding digit is 1. (We read left
as the smallest digit, and right as the largest digit.)
- Connecting together the Reset inputs of each flip flop allows us to reset the
entire counter with a single input.
Chained D Flip-Flops
- We handle the ‘chosen’ states as follows:
- Initialize 3 chained D flip-flops in a 1-0-0 format, and connect a button to the
clock input of each:
This construction causes a HIGH signal to propagate through the flip flops each
time we hit the switch.
Streetlight Logic (First Two Cases)
- For the first case (solid red), we connect the output of the first D-flip flop (out
of the 3) to the two red lights.
- For the second case (blinking red and yellow), we used an AND gate to
connect the output of the second D flip-flop to the clock signal:
- Each time both the flip-flop signal is HIGH (the state is correct) and the clock is HIGH (creates
the blinking effect), the LEDs will glow.
Final Case Logic
- For the final case (standard street light operation), all our preceding work
comes in handy:
- We build another 4 chained D flip-flops, in order to track the ‘progress’ of the traffic light
(states 1, 2, 3, 4).
- We build a counter and connect it to two different comparators, one for a small number, and
one for a large number.
- We use AND gates to selectively reset the counter depending on the state
and the comparator output.
- We connect the reset signal
to the counter of the 4 D flip-flops:
Some Hand Waving…
- We hand wave some more complex details (reset input and exact gates), but
at this point, we have 4 (internal) states which light up according to schedule.
- Therefore, we can connect whichever lights we want to the flip-flops and have
them light up according to schedule.
- Final Circuit: