Building a Computer: Understanding Switches, Gates, and Logic Circuits, Study notes of Programming Languages

An introduction to building a computer, focusing on the role of switches and gates in implementing logic functions. Topics covered include basic switches and gates, mos transistors, inverters, and logic gates such as and, or, nand, and nor. Demorgan's laws are also discussed. Useful for students in computer science or electrical engineering, particularly those studying computer organization and digital logic.

Typology: Study notes

Pre 2010

Uploaded on 08/19/2009

koofers-user-ntw
koofers-user-ntw 🇺🇸

10 documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 350
Computer Organization & Assembly
Language Programming
Spring 2009
Notes 04, 2009-02-02
1
Basic Switches and Gates
2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Building a Computer: Understanding Switches, Gates, and Logic Circuits and more Study notes Programming Languages in PDF only on Docsity!

CS 350

Computer Organization & Assembly

Language Programming

Spring 2009

Notes 04, 2009-02-

1

Basic Switches and Gates

• You need a lot of switches

• Switches are combined to implement

logic functions

- AND, OR, NOT, NAND, NOR ….

• Which are combined to build higher-level

structures

- Adder, multiplexor, decoder, register, memory

- [We'll study these later]

How to Build a Computer

3

How to Build a Computer

• These higher-level structures are used to

build a processor.

- Decode and act on instructions

+ Keep track of where next instruction is

- Do arithmetic

- Do tests ("is this = 0?")

- Go to some instruction

+ Change where next instruction comes from

CMOS (Complementary

MOS)

• The p- and n-type transistors are

complements of each other.

• CMOS circuit: Uses p- and n-type

transistors.

• We combine them to implement logical

functions AND, OR, NOT

7

Inverter (NOT Gate)

• NOT^ gate: Device that takes an input

voltage and produces an output voltage

so that the voltages of the input/output

are opposite.

- Input: 0V; Output: 2.9V

- Input: 2.9V; Output: 0V

- Treat 0V, 2.9V as representing bits 0, 1 resp.

- Gate also needs to be connected to power

and ground.

Inverter Uses 2 Switches

• The bar at the top is

connected to voltage, the arrow at bottom is connected to ground.

• If input has voltage, we

want output to be connected to ground.

• If input is connected to

ground, we want output to be connected to voltage. 9

Inverting Input 0

• If the input is 0, then the

p-type switch on top is closed but the n-type switch below is open.

• Output is connected to

voltage and not to ground.

• (If output were

connected to both voltage and input, you'd have a short circuit.)

Other Gates

• Similar but more-complicated collections

of switches can be used to form devices

that take 2 inputs and produce 1 output

that is the AND, OR, NAND, or NOR of

the inputs

• On next slide, note use of + for OR,

juxtapositioning for AND, and overbar for

NOT. (A common notation.)

13

Basic Logic Gates

Logic Gate Symbols

15

• Note use of small circle to show negation

DeMorgan's Laws

• DeMorgan's laws show how^ AND/OR,

NAND/NOR, and NOT are interrelated:

- A^ B =^ A^ + B^ [NOT^ (A^ AND B) = NOT^ A^ OR NOT^ B]

- A^ + B =^ A^ B^ [NOT^ (A^ OR B) = NOT^ A^ AND NOT^ B]

- To negate an^ AND, negate the operands and

change the AND to an OR

- To negate an OR, negate the operands and

change the OR to an AND

Combining Gates to Form

Circuits

19

Two Kinds of Circuits

• We can identify two kinds of logic circuits

- Combinatorial logic circuits

+ Are pure functions

+ Outputs depend only on the inputs

+ Are stateless = have no internal state

- Sequential logic circuits

+ Do have an internal state, which can change

+ Output depends on state and inputs

Some Combinatorial Logic

Circuits

• Decoder (has n inputs, 2

n outputs)

- The n inputs correspond to a binary number

- Each output corresponds to one binary

number.

• Example:^ A^ 2-bit decoder has inputs^ A, B

and 4 outputs

- Think of^ A, B as forming a 2-bit number, then

output number (A followed by B) will be 1

21

2-Bit Decoder

Note circles

on inputs;

shorthand for

NOT gates

Half Adder

25

• A^ Half-Adder takes two

bits and produces two bits of output, a carry- out bit and a sum bit.

• If we want to add two

binary numbers, the rightmost column can use a half-adder.

• But the other columns

may have a carry-in. A B Cout Sum 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0

Full Adder

• A^ full adder takes two

bits to add, plus a carry- in bit, and it produces a carry out bit and sum.

• A^ half adder can be

done as a full adder with a 0 for the carry in. A B Cin Cout Sum 0 0 0 0 0 0 1 0 0 1 1 0 0 0 1 1 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1

Four-bit Adder

• A!A"A#A$^ + B!B"B#B$^ = Cout^ S!S"S#S$.

27

Any Combinatorial Circuit

• A^ combinatorial circuit

takes some input bits and produces some output bits.

• Each row corresponds

to the AND of

- A^ or its negation

- B or its negation

- C or its negation

A B C Selector 0 0 0 A B C 0 0 1 A B C 0 1 0 A B C 0 1 1 A B C 1 0 0 A B C 1 0 1 A B C 1 1 0 A B C 1 1 1 A B C