1 of 70

Introduction to Digital Logic�using TinkerCAD

Nick Carter

5/26/2020

2 of 70

What we will cover

  • Introduction to TinkerCAD
  • What is logic – showing simple TRUE/FALSE logical combinations in TinkerCad
  • Simplest Logic - AND, OR, NOT
  • More complex logic – NAND, NOR
  • Using a Transistor to make - NOT
  • Graphical Representations - symbols
  • Integrated circuit logic – 74HC00/74HC02 (Logic Family)
  • Simple Arithmetic - Binary numbers
  • What a computer has to do
  • Example - 4 bit ADDER
  • How to remember data - Sequential Logic
  • Logic Gates in Computers

3 of 70

Getting Started – make an account

  • Go to web page “www.tinkercad.com”
  • Register for an account – non adults please talk to your parents about what information to put in. They may want to put their information in for you to use.
  • If you are under 13 you will need a parent or guardian to sign up for you
  • Parents should look at the privacy statement and depending on age, some activities or access require parents involvement. Parents should read Children’s Privacy Policy at https://www.autodesk.com/company/legal-notices-trademarks/terms-of-service-autodesk360-web-services/terms-of-service-for-tinkercad
  • Click “Sign up” at top right of home page.
  • You will need a username and password, an age and an email address.
  • They also ask for other information but I don’t think you need to put that.
  • Other people can see your user name and your circuits but not much else.
  • You can choose to share your circuits and also see, copy and tinker with other people’s shared circuits.

4 of 70

What is a Simulator?

  • An Engineering Simulator lets you build things and test them using computer models.
  • Games like Minecraft let you build computer models too.
  • Circuit Simulators have models of Electronic components that you can connect together and see what happens when you apply electricity or signals or programs to them.

Arduino

5 of 70

How do you see what happens?�The same as in real life!

  • You can see physical changes:
    • If it is a motor it will move
    • If it is a lamp/LED it will glow
    • If it is a text display you will (hopefully) see text
  • You can measure circuit parameters like current, voltage and resistance
  • You can graph voltage changes over time with an Oscilloscope
  • You can use a voltage detecting input on a microcontroller to “see” what voltage is on the input. (Not covered here - you will have to write a program for this - or use examples).
  • It may not be good with complicated circuits as the remote simulator has to do a lot of calculating.

6 of 70

Nova Labs Electronics Bench

7 of 70

Real Life – After Corona Virus

  • In real life you can use the Nova Labs Electronics Bench
    • Soldering stations/Tools
    • Components/Wire
    • Test Equipment
  • Look for Open Electronics on Thursday evenings in Meetup.
    • Knowledgeable folks to talk to - also see Electronics Steward
  • Get Green certification but it helps to take a soldering course. Or look at mine on NL Wiki. See Classes - Nick
  • Until Then use TinkerCAD or buy parts online to build stuff at home. Online - Adafruit , parts and good tutorials/Video
  • Attend free Arduino Meetup – 3rd Tuesday each month
    • check Nova Maker’s Meetup Calendar
  • Look for other Nova Labs Classes on Meetup

8 of 70

Starting in TinkerCAD

  • LOG IN
  • SELECT “CIRCUITS”
  • CLICK ON “CREATE NEW CIRCUIT”

9 of 70

Using TinkerCAD�After you click “Create new Circuit”�

Most icons will tell what they are if you hover cursor over.

Centers the circuit in the window

For Arduino

programming

To get a component, move cursor over it and click and

hold left mouse button then drag it where you want it.

When the component is selected you see a popup box

to change things

To connect 2 components click on a terminal and drag the wire to where you want it to go then click again. You can pin it to a bend location by clicking for clear routing.

A component terminal may have useful information when you hover the cursor over it.

10 of 70

What is there to build from�Click “All” on the Component menu and scroll up and down

  • Basic components
  • Components for Input
  • Components for Output
  • Power Components
  • Breadboards
  • Premade Circuit Assemblies
  • Microcomputers
  • Test Instruments

11 of 70

TinkerCAD Tips

  • If you want to cancel wiring you are making use ESC key
  • TinkerCAD gives the circuit a weird name, BUT you can change this – but not when you are tinkering it. Click on the TINKERCAD at top left and the click on the circuit and then the gear. Then you can change the name and other things about the circuit in Properties.
  • Sometimes it takes 2 keystrokes to make changes.
  • Because TinkerCAD program is on a remote computer, and communicates through the Internet and your WiFi, it can be slow to respond sometimes.
  • Arduino programs run slower than real time.

12 of 70

What is a circuit?

  • A circuit is a conductive path that allows electricity to flow from one place to another. Flow of electricity is called “Current”
  • For electricity to flow there has to be a difference in voltage potential between the two locations. How much current, depends on the voltage and the path resistance.
  • Assume (in TinkerCAD) wires have no resistance and all resistance in the circuit is in the resistor component.

+

-

9 v olts difference

Current flow

No current flow

A circuit is connected

A circuit is not connected

+

-

13 of 70

Let’s Measure a Resistor

Get the Components:

  • Find, click on and drag a Resistor and a Multimeter onto the workplace.

(Click on it once to select it and then drag then click again to drop it)

A Multimeter lets us measure resistance, voltage and current

Connect the wires:

  • Hover the cursor over the component terminal, click once, then drag the wire to another terminal and click to secure it.
  • Wires can be routed by clicking to make a movable anchor point at any location.

14 of 70

Select Component Parameters

  • Click on the component to select it and get properties pop-up. You can change things – e..g. the Name, the Value, the Mode.
  • Try this for the resistor, multi-meter and wire

15 of 70

Change and Simulate your circuit

  • Click on each component in turn and see the box that pops up. See what you can change and try changing things.
  • Set the Multimeter to “Resistance”
  • Change your wire colors using number keys.
  • Rotate the components.
  • Click the “Start Simulation” button.
    • This turns the Electricity on and off to the circuit.
    • See what you can change while simulation is ON.
    • Turn off simulation to add or delete components
  • What does the multi-meter read in other modes? Why?
  • What changes on the resistor if you change its value? Why?
  • The Multimeter measures the resistance by applying a voltage across it and measuring the current.
  • You can verify this using another Multimeter to measure the Voltage.

16 of 70

Multimeters�(In normal times you get to try these)

ANALOG and DIGITAL

17 of 70

Both Measure, Volts AC and DC, Current Amps, Resistance Ohms, Connection Buzzer

USE THE OFF SWITCH POSITION!!!

18 of 70

Features

  • High input resistance
  • Internal amplifier
  • All scales need battery
  • Auto Zero Adjust
  • Auto Range change
  • Reading Hold Button
  • Backlight
  • Pointer driven by electromagnetism
  • Low internal resistance – target drives needle
  • Manual Zero Adjust – pointer and Ohms
  • Manual Range change
  • Battery for Ohms only
  • Different scales per measurement class
  • Mirror – enables alignment of pointer over scale for best reading

ANALOG DIGITAL

19 of 70

What is BOOLEAN LOGIC?�It comes from Mathematics

  • BOOLEAN LOGIC
    • Developed from BOOLEAN ALGEBRA
    • It is a way to describe logical operations similar to the way Elementary Algebra describes numerical operations
    • We will see some symbols for this
    • George Boole, published a book on this in 1847
    • This is used to design Digital Logic in Electronics

20 of 70

What is DIGITAL LOGIC?�As used in Computers

  • TRUE or FALSE , YES or NO
    • Two possible answers, states or values
    • This is called binary, - “bi” means 2
    • This is also known as Binary Logic – 2 possible values
    • In computers these values are called “0” and “1”
    • “1” represents TRUE, “0” represents FALSE
  • These Answers, States or Values can be combined to create new states
    • The new states are TRUE or FALSE depending on some combination of the input STATES
    • If outputs only depend on INPUTS this is called COMBINATORIAL LOGIC
      • The output is a combination of the inputs.
    • If outputs depend also on prior outputs, this is called SEQUENTIAL LOGIC – some states are remembered internally
  • To combine logic signals we use GATES – some signals open and shut pathways /gates for others.

21 of 70

How Do We Combine Them?�We implement logical functions

  • In arithmetic we OPERATE on numbers using
    • addition (+), subtraction (-), multiplication (*), and division (/)
  • In logic we also have OPERATORS that operate on logical values using
    • AND, OR, NOT – these are basic operators
    • Other functions can be made by combining these e.g.
      • NAND (AND + NOT)
      • NOR (OR + NOT)

22 of 70

How do Logical Operators Work?

  • AND
    • If EVERY input is TRUE or “1” the output is “1”
    • If ANY INPUT is FALSE or “0” the out put is “0”
  • OR
    • If ANY input is TRUE or “1” the output is “1”
    • If EVERY input is FALSE or “0” the output is “0”
  • NOT
    • If the INPUT is TRUE the output is FALSE
    • If the INPUT is FALSE the output is TRUE
  • TRUE or FALSE can be represented in various ways in hardware
    • In Electronics, usually – TRUE is Positive Voltage, FALSE is ZERO voltage – called Positive Logic
    • Some implementations use different representation.
    • LOGIC functions do not depend on implementation

23 of 70

How can you make logic circuits

  • There are many ways, using different components:
    • with advantages and disadvantages
  • No NOT function
    • Resistors and Diodes
  • With NOT Function
    • Resistors, Diodes and Transistors
    • Bipolar or MOS Transistors
    • Relay switches
    • Vacuum Tubes (Old)
    • Mechanical Devices (Not Electronic)
  • We will look at Resistors first – using a Switch as Input

  • You can also use prebuilt gates on multiple gate arrays and program their connections – but not in TinkerCAD.

24 of 70

LOGIC with Resistor/Switch�OR function

Make This Circuit

Try using the switches to see what combination lights the LED

In Circuits LEDs are included to indicate TRUE when ON (Our convention)

A

B

Q

Logical Statement

A + B = Q

Truth Table – examines all input combinations

Our convention is

Switches will be “TRUE when ‘UP” and FALSE when “down”

Symbol

A

0

0

1

1

B

0

1

0

1

Q=A+B

A

0

0

1

1

B

0

1

0

1

Q=A+B

0

A

0

0

1

1

B

0

1

0

1

Q=A+B

0

1

A

0

0

1

1

B

0

1

0

1

Q=A+B

0

1

1

A

0

0

1

1

B

0

1

0

1

Q=A+B

0

1

1

0

25 of 70

LOGIC with Resistor/Switch�AND function

Make This Circuit

Try using the switches to see what combination lights the LED

In our Circuits LEDs are included to indicate TRUE when ON (Our convention)

A

B

Q

Logical Statement

A . B = Q

Truth Table – examines all input combinations

Our convention is

Switches will be “TRUE when ‘UP” and FALSE when “down”

Symbol

A

0

0

1

1

B

0

1

0

1

Q=A+B

A

0

0

1

1

B

0

1

0

1

Q=A+B

0

A

0

0

1

1

B

0

1

0

1

Q=A+B

0

0

A

0

0

1

1

B

0

1

0

1

Q=A+B

0

0

0

A

0

0

1

1

B

0

1

0

1

Q=A+B

0

0

0

1

26 of 70

LOGIC with switches in TinkerCAD

  • ON/OFF Switches can only make AND and OR functions
  • In TinkerCAD we can represent the Logical State by the switch position (Left/Right, UP/Down)
  • To make a NOT function we need an Active Component where an input CONTROLS an output
    • Generally requires a semiconductor component.
    • We will use a Transistor switch
    • We will use the Transistor to provide NOT function

(Transistors can be used without NOT function too)

27 of 70

Make a Transistor “NOT” Inverter

Make This Circuit

Try using the switch to see what state lights the LED

Symbol

Q

A

In our Circuits LEDs are included to indicate TRUE when ON (Our convention)

Truth Table – examines all input combinations

Logical Statement

A = Q

A

0

1

Q

1

0

C

B

E

28 of 70

LOGICAL SYMBOLS in a CIRCUIT�How Do We Write Them

  • AND
    • Both

  • OR
    • Either�

  • NOT
    • Inverse

  • XOR
    • Exclusive OR

FLAT FRONT = AND

CURVED FRONT = OR

LINE OVER VALUE = NOT

NOT TRUE = FALSE

CIRCLE = NOT

2 CURVES at FRONT = XOR

29 of 70

Why NAND and NOR�Look for the circle!

  • NAND

  • NOR

  • You can use them to build anything else
  • NOR can use one Transistor only but in practice, circuits use more transistors.
  • The small circle indicates inverted logic

30 of 70

LOGIC with Diode/Transistor�NAND function – separate inputs

Make This Circuit

  • Try using the switches to see what combination lights the LED
  • Separate inputs means we could connect these to gate outputs

In Circuits LEDs are included to indicate TRUE when ON (Our convention)

A

B

Q

Logical Statement

A . B = Q

Truth Table – examines all input combinations

Symbol

A

0

0

1

1

B

0

1

0

1

Q=A.B

A

0

0

1

1

B

0

1

0

1

Q=A.B

1

A

0

0

1

1

B

0

1

0

1

Q=A.B

1

1

A

0

0

1

1

B

0

1

0

1

Q=A.B

1

1

1

A

0

0

1

1

B

0

1

0

1

Q=A.B

1

1

1

0

31 of 70

NAND is a Universal GATE�look what you can make

32 of 70

Prebuilt Electronic GATES

  • The most popular Logic component family is the 7400 series.
  • First released by Texas Instruments in 1964
  • Dual Inline pin components were in 1966
  • 14/16/20 pins accommodated
    • multiple GATES
    • Power and ground pins
    • Multiple Gate Types
  • SPOT or Mark shows which end has pins 1/14

1

33 of 70

4 Gates in a Package�(TinkerCAD has these, and more)

NOTICE DIFFERENCE IN PIN ASSIGNMENTS (PINOUT) _ DO NOT ASSUME!

34 of 70

Grab a Gate Package and test it.

  • You can use any gate but look at the description.
  • Hover over the pin – it will tell you which gate in the package and what function on that gate.
  • Use a 4.5V battery (3 cells)
  • Use a multi-meter to Negative or LED/Resistor combination to Positive to measure or show the output and switch and resistor on input.
  • You can also connect one gate output to the input of another gate.
  • You can connect inputs together but NOT outputs.

35 of 70

2 input NAND Test Circuit

Make an example like this.

Try connecting the output to another gate input and measure the output of that,

36 of 70

RTL - Resistor Transistor Logic�DTL- Diode Transistor Logic

  • The simplest Transistor gates are made with Transistors and Resistors – this is called RTL
    • Used on Apollo mission electronics
    • Uses more power than other implementations
    • Limited input and output connections
    • Easy to make in TinkerCAD
    • Simple functions
    • Inputs not isolated
  • DTL Diode Transistor Logic
    • Diode isolates inputs
    • More inputs possible
    • More noise immunity

Integrated Circuit Top View

37 of 70

TTL - Transistor Transistor Logic

  • The 7400 series is made with more transistors and is more reliable and immune to electrical noise. This is called TTL.
  • TTL gates in TinkerCAD are ones made using High speed CMOS transistors, and are designated with HC like 74HC00.
    • We can use the prebuilt packages in TinkerCAD
    • Power and Ground are usually at the corners –
      • e.g. pins 7 (G). 14 (+V)
    • Packages include quite complex functions.
    • Simple packages have 14 pins
    • More complex - have 16 or 20 pins
    • Superseded RTL and DTL

Integrated Circuit Top View

38 of 70

Hex (Six) Inverters in a package - 7404

  • You can see how 14/16 pins is very convenient to get a small number of functions in a package
  • You can see in TinkerCAD these and many more complicated functions

39 of 70

USING 7400 CHIPS

  • Parameters to be aware of:
    • Fan In - depends on implementation 1 – 8.
      • Number of gate inputs. Gates with more inputs are generally slower.
    • Fan Out – Gate Output – usually 10
      • The number of inputs of the same logic family type that can be connected to an output and function properly
    • Delay
      • Elapsed Time between changing from 0🡪1 or 1🡪0 on an Input and the time for the Output to change as a result.
      • Changing from 0🡪1 or from 1🡪0 may have different delays
    • Unused Inputs
      • Unused inputs should not be left unconnected – always connect them to a voltage that guarantees a 1 or 0 state depending on the gate function. This protects against noise.
      • When connecting to +V, TTL are generally connected via a resistor, CMOS can be connected directly. When connecting to 0V/GND, they can be connected directly
      • They can be connected to other inputs on the same gate, if delay is not critical, and it does not impair function.
    • There are multiple types of 74xx families
      • e.g. 74HC like TinkerCAD has. HC means High
      • Data sheet. https://www.futurlec.com/74HC/74HC00.shtml
      • HC family is nice, they have a wide range of power supply voltage (2 – 6 Volts) so can work with 3.3V or 5V powered microcontrollers.
    • DO NOT JOIN 2 OUTPUTS TOGETHER

40 of 70

Part Number

No in 14 pin Pack

Inputs

Gate Type

74HC00

4

2

NAND

74HC02

4

2

NOR

74HC04

6

1

NOT (INVERTER)

74HC08

4

2

AND

74HC10

3

3

NAND

74HC11

3

3

AND

74HC20

2

4

NAND

74HC21

2

4

AND

74HC27

3

3

NOR

74HC32

4

2

OR

74HC86

4

2

XOR

74HC14

4

2

NAND Schmitt Trigger*

*74HC137

6

1

NOT Schmitt Trigger*

  • Schmitt-trigger inputs are designed to provide a minimum separation between positive and negative switching thresholds. At 6V this is 0.5-2.5V hysteresis.
  • This allows for noisy or slow inputs that would cause problems such as oscillation or excessive current draw with normal CMOS inputs.

41 of 70

Recommended Design Process

  • Write all the design information down
  • First define what the circuit does in words
  • Make a truth table definition to satisfy the word definition
  • Make the logic circuit by following the table
    • i.e. What are all the combinations of input that will make the output = 1 or 0 as desired
    • Make the inputs and combine them logically .
    • You can use any AND/NAND/OR/NOR/NOT function
  • Draw it and figure which gates in the package you will use
  • Label the pins on the drawing (annotate)
  • Build it
  • Test it to see if it matches the definition

  • Hint – You can add an inversion at any point to make it work.

42 of 70

TINKERCAD GATES NAND and NOR Functionality Test

You can access this design to get your own copy at (or build your own) https://www.tinkercad.com/things/bePGRCSVkfu-demo-of-74hc-logic

  • Test the way it works I used the first gate with pins 1, 2, 3.
  • Find pin 1!

43 of 70

Logical Function and Algebra 1

44 of 70

Logical Function and Algebra 2

45 of 70

Logical Function and Algebra 3

46 of 70

DIGITAL LOGIC Makes Computers Work

  • In computers, the programs and data are represented by “1” and “0” values in electronic components
  • Usually, a “1” is represented by a “HIGH” voltage and a “0” is represented by a “LOW” voltage.
  • This is only a convention for convenience. (In my first job we used 0 and – 12 volts.)
  • What matters is that the logic is consistent and works in logic, storage, and control sequences

47 of 70

Computers DO Arithmetic �- TRUE or FALSE?

  • It is easier to make a circuit that has 2 states – ON and OFF than 10 states. Some people made logic with > 2 states.
  • Circuits that have 2 states can be used to represent LOGIC TRUE and FALSE as well as Binary Numbers
  • Each digit in a binary number is a 1 or a 0 just like every digit in decimal system is a 0, 1, 2, 3, 4, 5, 6 ,7 ,8 or 9.
  • These combinational circuit elements are called GATES
  • Computer Programs use Decimal numbers for human convenience
  • Computers represent the Decimal numbers internally and do arithmetic using BINARY numbers

  • The answer is NO, not “TRUE or FALSE”, but “using TRUE AND FALSE” ☺ ha ha……

48 of 70

Binary Numbering compared to Decimal Numbering

Position 5 4 3 2 1

Value

  • Decimal 10000’s 1000’s 100’s 10’s 1’s
  • Binary 16’s 8’s 4’s 2’s 1’s
  • Adding in Decimal
    • 9+1= 0 and carry 1 to next digit (9+1 = 10, 10 is carried as 1x 10)
  • Adding in Binary
    • Add 1+1 = 0 and carry 1 to next digit ( 1+1 = 2, 2 is carried to be 1x 2)
  • A generic single bit adding block needs
    • 3 inputs – two inputs for the bits to be added and carry from prior digit
    • 2 outputs – the sum and the carry bit for next digit

Single Bit Adder

Input A

Input B

Carry In

Output

CarryOut

49 of 70

74HC283 4 bit Fast Adder Circuit

Example (Arithmetic symbol use):

Decimal 10 +9 =Binary 0 + 1010 + 1001

Sum = Decimal 19 = Binary 1 + 0011

Inputs, A*, B*. Outputs, S*

Carry plus 2^3, 2^2, 2^1, 2^0

^ = OR, + = AND

Single Bit Adder

50 of 70

TinkerCAD 4 Bit Adder

Shared as DIGTL7 4 BIT ADDER NOVALABS - Search and try it

51 of 70

Sequential LOGIC Overview

Circuits with Memory

  • Output depends on past OUTPUT/INPUT and present INPUT
  • What makes the output change?
    • Change in state of an input
    • Change in state of a Strobe or Clock signal
  • 1. Event Driven – asynchronous circuits that change state immediately when enabled. The event is a signal transition from 0🡪 1 or 1 🡪 0
  • 2. Clock Driven – synchronous circuits that are synchronized to a specific clock signal. A Clock is a repetitive pulse that gates data into storage on a positive or negative transition.
  • 3.Asynchronous  Pulse Driven – which is a combination of the two that responds to triggering pulses. Asynchronous Pulses are not regularly repetitive like Clock signals

52 of 70

Computer use of Logic Gates

  • Combinatorial logic is used to determine the input states to the Sequential logic. E.g. to select one input from several
  • Computers use Sequential logic storage called Registers to store data for immediate use e.g. connected to an Adder. Inputs and outputs .
  • Computers use bulk storage Random Access Memory (RAM) for longer term storage.
  • Gates are used to direct/route data from RAM to Registers for logical and arithmetic operations

53 of 70

Modern Use of Gates

  • Most gates today are made on Integrated Circuits. (I.C.’s)
  • An early microprocessor, the 4 bit Intel 4004, had 2250 transistors – approximately 700 gates
  • Modern IC’s can have a billions of Gates, a lot of which is memory.
  • These are not designed on by hand but placed by software. Individual gates are designed and automated, and grouped by function in software tools.
  • Multicore processors repeat the same design for each core.
  • Gates can also be made using programmable logic – Field Programmable Gate Arrays. Here, the gates are made already, you program the connections to make your desired circuit.

54 of 70

Moore’s Law

By Max Roser - https://ourworldindata.org/uploads/2019/05/Transistor-Count-over-time-to-2018.png, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=79751151

55 of 70

References

56 of 70

Class Pic

57 of 70

Extra Credit :-D

More things to build and try

58 of 70

Make a Transistor “NOR” gate

Make This Circuit

Try using the switch to see what state lights the LED

Add the resistor and switch

Symbol

In Circuits LEDs are included to indicate TRUE when ON (Our convention)

Truth Table – examines all input combinations

Logical Statement

A + B= Q

A

0

0

1

1

B

0

1

0

1

Q=A+B

A

0

0

1

1

B

0

1

0

1

Q=A+B

1

A

0

0

1

1

B

0

1

0

1

Q=A+B

1

0

A

0

0

1

1

B

0

1

0

1

Q=A+B

1

0

0

A

0

0

1

1

B

0

1

0

1

Q=A+B

1

0

0

1

59 of 70

LOGIC with Resistor/Transistor�NAND function – no separate inputs

Make This Circuit

Try using the switches to see what combination lights the LED

Reconfigure the switches

In Circuits LEDs are included to indicate TRUE when ON (Our convention)

Diodes can be used between the switch and transistor to isolate multiple inputs.

A

B

Q

Logical Statement

A . B = Q

Truth Table – examines all input combinations

Symbol

A

0

0

1

1

B

0

1

0

1

Q=A.B

A

0

0

1

1

B

0

1

0

1

Q=A.B

1

A

0

0

1

1

B

0

1

0

1

Q=A.B

1

1

A

0

0

1

1

B

0

1

0

1

Q=A.B

1

1

1

A

0

0

1

1

B

0

1

0

1

Q=A.B

1

1

1

0

60 of 70

LOGIC with Transistor/Transistor�NAND function – separate inputs

Make This Circuit

  • Try using the switches to see what combination lights the LED
  • Separate inputs means we could connect these to gate outputs

In Circuits LEDs are included to indicate TRUE when ON (Our convention)

A

B

Q

Logical Statement

A . B = Q

A

0

0

1

1

B

0

1

0

1

Q

1

1

1

0

Truth Table – examines all input combinations

Symbol

Function: NOT

Function: AND

61 of 70

Design an Exclusive Or (XOR) Gate

  • First define what it does
    • Output is TRUE if ONLY ONE input is TRUE
  • Make a truth table definition for a 2 input XOR function
  • Make the logic circuit by following the table
    • i.e. What are all the combinations of input that will make the output = 1
    • Make the inputs and combine them logically .
    • You can use AND/NAND/OR/NOR/NOT function
    • Bonus points for using just NAND.
  • Draw it and figure which gates in the package you will use
  • Label the pins on the drawing (annotate)
  • Build it
  • Test it to see if it matches the definition

  • Hint – You can add an inversion at any point to make it work.

62 of 70

MAKE a Truth Table

  • First, what is the logic function - make a truth table
  • You can make this using any kind of gates and inverters
  • Using only NAND gates, you will need 4 x2 input NAND gates
  • You can look at the function as
    • Q = (XOR(A.B)) = (((NOT A) AND B ) OR ((NOT B) AND A ))
    • Q = (A OR B) AND (NOT (A AND B))
  • HINT – The NAND gate has 2 Functions
    • Q = NOT (A AND B)
    • Q = (NOT A) OR (NOT B)
    • This is an interesting duality
  • Test your function by inserting 1’s and 0’s for A and B
  • Make the logic circuit
  • Test it to see if it matches the definition
  • For more complete Boolean logic see references.

A

0

0

1

1

B

0

1

0

1

Q

0

1

1

0

Circle on pin indicates “NOT”

XOR

63 of 70

Design Process�Make a Truth Table

Input�A

Input�B

Logical Need

Output �Need

But we can also Express it as the Not or opposite of

Logical Output

Input�A

Input�B

 

for "1"

 

 

0

0

 

 

Not This and

0

1

0

A and Not B

either this

 

1

0

1

B and Not A

or this

 

1

1

1

 

 

Not This

0

64 of 70

XOR Function Implementations

There can be more than one way to get the answer.

65 of 70

Using Inverters and OR gates�(but uses 3 packages partially)

INV1

INV2

Input�A

Input�B

Not A

Not B

A and Not B

B and Not A

AND1OUT OR AND2OUT ==

A XOR B

With inverters

 

 

INV1 Out

INV2OUT

AND1OUT

AND2OUT

OR OUT 

 

AND and OR Gates

0

0

1

1

0

0

0

0

1

0

0

1

1

0

1

1

0

1

1

0

0

1

1

1

1

1

0

0

0

0

0

0

AND2

AND1

OR

66 of 70

XOR using NAND Gates

Input�A

Input�B

Output� 1

Output �2

Output �3

Output �4

Logical Need

Ouptput �Need

But we can also Express it as the Not or opposite of

Input�A

Input�B

Not A.B

Not(A.Not(A.B))

Not(B.Not(A.B))

Not(Output3.Output4)

 

for "1"

 

0

0

1

1

1

0

 

 

Not This and

1

0

1

0

1

1

A and Not B

either this

 

0

1

1

1

0

1

B and Not A

or this

 

1

1

0

1

1

0

 

 

Not This

1

2

3

4

Gate numbers chosen for use in truth table not wiring

67 of 70

To Make with NAND gates�we need expression with NOT(A AND B)

Q =(XOR(A.B)) = (((NOT A) AND B ) OR (A AND (NOT B)))

We write this using “.” or “*” for “OR” , and “+” for “AND” and Line over for “NOT”

Q = A.B + A.B

Using NAND gates we have to use the expression A.B for each gate

We can also write the gate function as A + B which we can use to get the NOT A and NOT B inputs to combine with the A and B.

So A.(A + B) = A.A + A.B but A.A = 0

So A.(A + B) = A.B and similarly

B.(A + B) = A.B

So we have to OR these together to get the answer

68 of 70

Logic States in the XOR circuit

= A.B + A.B

A + B

A.B

A.B

= A.B .

A.B

= A.B +

A.B

= A.B

A.A and B.B terms disappear

Two NOTs cancel each other

69 of 70

Label circuit diagram with package pins�also called “schematic”

Assign pins to the gates

Any gate is the same as any other so choose them for least difficulty in wiring. I picked the same as in truth table just because….

Then:

  • Wire it
  • Test it

1

2

3

4

1

2

3

4

5

6

13

12

11

10

9

8

70 of 70

XOR with NAND GATES

You can search for this and find it in TinkerCAD by name and play with it

XOR with Indicators – NOVALABS

or use this link

https://www.tinkercad.com/things/lwPHpsX4i3P-xor-with-indicators-novalabs