35
1 Digital Logical Digital Logical Structures Structures Patt and Patel Ch. 3 Patt and Patel Ch. 3

1 Digital Logical Structures Patt and Patel Ch. 3

Embed Size (px)

Citation preview

Page 1: 1 Digital Logical Structures Patt and Patel Ch. 3

1

Digital Logical Structures Digital Logical Structures

Patt and Patel Ch. 3Patt and Patel Ch. 3

Page 2: 1 Digital Logical Structures Patt and Patel Ch. 3

2

Transistor:Transistor: Building Block of ComputersBuilding Block of Computers

Microprocessors contain millions of Microprocessors contain millions of transistorstransistors

– Intel Pentium 4 (2000): 48 million– IBM PowerPC 750FX (2002): 38 million– IBM/Apple PowerPC G5 (2003): 58 million

Page 3: 1 Digital Logical Structures Patt and Patel Ch. 3

3

Logically, each transistor acts as a switchLogically, each transistor acts as a switch

– Combined to implement logic functions •AND, OR, NOT

– Combined to build higher-level structures•Adder, multiplexer, decoder, register, …

– Combined to build processor•LC-3

Transistor

Page 4: 1 Digital Logical Structures Patt and Patel Ch. 3

4

Simple Switch CircuitSimple Switch CircuitSwitch Switch openopen::

– No current through circuit– Light is off

– Vout is +2.9V

Switch Switch closedclosed::– Short circuit across switch– Current flows– Light is on

– Vout is 0VSwitch-based circuits can easily represent two

states:on/off, open/closed, voltage/no voltage.

Transistor

Page 5: 1 Digital Logical Structures Patt and Patel Ch. 3

5

n-type MOS Transistorn-type MOS Transistor

MOSMOS = Metal Oxide Semiconductor = Metal Oxide Semiconductor– two types: n-type and p-type

•n-typen-type

– when Gate has positive voltage,short circuit between #1 and #2(switch closed)

– when Gate has zero voltage,open circuit between #1 and #2(switch open)

Gate = 1

Gate = 0

Terminal #2 must beconnected to GND (0V).

Transistor

Page 6: 1 Digital Logical Structures Patt and Patel Ch. 3

6

p-type MOS Transistorp-type MOS Transistor

p-typep-type is is complementarycomplementary to n-type to n-type

– when Gate has positive voltage,open circuit between #1 and #2(switch open)

– when Gate has zero voltage,short circuit between #1 and #2(switch closed)

Gate = 1

Gate = 0

Terminal #1 must beconnected to +2.9V

in this example.

Transistor

Page 7: 1 Digital Logical Structures Patt and Patel Ch. 3

7

Logic GatesLogic GatesUse switch behavior of MOS transistors to implement logical Use switch behavior of MOS transistors to implement logical functions: AND, OR, NOT.functions: AND, OR, NOT.

Digital symbols:Digital symbols:

– recall that we assign a range of analog voltages to eachdigital (logic) symbol

– assignment of voltage ranges depends on electrical properties of transistors being used

• typical values for "1": +5V, +3.3V, +2.9V• from now on we'll use +2.9V

Logic Gates

Page 8: 1 Digital Logical Structures Patt and Patel Ch. 3

8

CMOS CircuitCMOS Circuit

•ComplementaryComplementary MOS MOS

•Uses both Uses both n-typen-type and and p-typep-type MOS transistors MOS transistors

– p-type•Attached to + voltage•Pulls output voltage UP when input is zero

– n-type•Attached to GND•Pulls output voltage DOWN when input is one

Logic Gates

Page 9: 1 Digital Logical Structures Patt and Patel Ch. 3

9

Inverter (“NOT” Gate)Inverter (“NOT” Gate)

InIn OutOut0 V0 V 2.9 V2.9 V

2.9 V2.9 V 0 V0 V

InIn OutOut00 11

11 00

“Truth Table”

Logic Gates

Page 10: 1 Digital Logical Structures Patt and Patel Ch. 3

10

““NOR” GateNOR” Gate

AA BB CC

00 00 11

00 11 00

11 00 00

11 11 00

Note: Serial structure on top, parallel on bottom.

Logic Gates

Page 11: 1 Digital Logical Structures Patt and Patel Ch. 3

11

““OR” GateOR” Gate

Add an inverter to a NOR gate.

AA BB CC

00 00 00

00 11 11

11 00 11

11 11 11

Logic Gates

Page 12: 1 Digital Logical Structures Patt and Patel Ch. 3

12

NAND Gate (“NOT-AND”)NAND Gate (“NOT-AND”)

AA BB CC

00 00 11

00 11 11

11 00 11

11 11 00

Note: Parallel structure on top, serial on bottom.

Logic Gates

Page 13: 1 Digital Logical Structures Patt and Patel Ch. 3

13

““AND” GateAND” Gate

Add an inverter to a NAND.

AA BB CC

00 00 00

00 11 00

11 00 00

11 11 11

Logic Gates

Page 14: 1 Digital Logical Structures Patt and Patel Ch. 3

14

Basic Logic GatesBasic Logic GatesLogic Gates

Page 15: 1 Digital Logical Structures Patt and Patel Ch. 3

15

DeMorgan's LawDeMorgan's Law

• Converting AND to OR (with some help from NOT)Converting AND to OR (with some help from NOT)

• Consider the following gate:Consider the following gate:

AA BB

00 00 11 11 11 00

00 11 11 00 00 11

11 00 00 11 00 11

11 11 00 00 00 11

BA BA BA

Same as A OR B = A + B

To convert AND to OR (or vice versa),

invert inputs and output.

(A + B)’ = A’B’ conversely (AB)’ = A’ + B’

Page 16: 1 Digital Logical Structures Patt and Patel Ch. 3

16

More than 2 Inputs?More than 2 Inputs?• AND/OR can take any number of inputs.AND/OR can take any number of inputs.

– AND = 1 if all inputs are 1.– OR = 1 if any input is 1.– Similar for NAND/NOR.

• Can implement with multiple two-input gates,Can implement with multiple two-input gates,or with single CMOS circuit.or with single CMOS circuit.

Page 17: 1 Digital Logical Structures Patt and Patel Ch. 3

17

SummarySummary• MOS transistors are used as switches to MOS transistors are used as switches to implement logic functions.implement logic functions.

– n-type: connect to GND, turn on (with 1) to pull down to 0– p-type: connect to +2.9V, turn on (with 0) to pull up to 1

• Basic gates: NOT, NOR, NANDBasic gates: NOT, NOR, NAND– Logic functions are usually expressed with AND, OR, and

NOT

• DeMorgan's LawDeMorgan's Law– Convert AND to OR (and vice versa) by inverting inputs and

output

Page 18: 1 Digital Logical Structures Patt and Patel Ch. 3

18

Building Functions from Building Functions from Logic GatesLogic Gates

•Combinational Logic CircuitCombinational Logic Circuit

– output depends only on the current inputs– stateless

•Sequential Logic CircuitSequential Logic Circuit

– output depends on the sequence of inputs (past and present)

– stores information (state) from past inputs

We'll first look at some useful combinational circuits, then show We'll first look at some useful combinational circuits, then show how to use sequential circuits to store information.how to use sequential circuits to store information.

Page 19: 1 Digital Logical Structures Patt and Patel Ch. 3

19

DecoderDecodernn inputs, inputs, 22nn outputs outputs

– exactly one output is 1 for each possible input pattern

“2-bitDecoder”

Combinational Logic

Page 20: 1 Digital Logical Structures Patt and Patel Ch. 3

20

Multiplexer (MUX)Multiplexer (MUX)

nn-bit selector and -bit selector and 22nn inputs, one output inputs, one output– output equals one of the inputs, depending on selector

“4-to-1 MUX”

Combinational Logic

Page 21: 1 Digital Logical Structures Patt and Patel Ch. 3

21

Full AdderFull AdderAdd two bits and carry-in,Add two bits and carry-in,produce one-bit sum and carry-out.produce one-bit sum and carry-out. AA BB CCinin SS CCoutout

00 00 00 00 00

00 00 11 11 00

00 11 00 11 00

00 11 11 00 11

11 00 00 11 00

11 00 11 00 11

11 11 00 00 11

11 11 11 11 11

Combinational Logic

Page 22: 1 Digital Logical Structures Patt and Patel Ch. 3

22

Four-bit AdderFour-bit Adder

Combinational Logic

Page 23: 1 Digital Logical Structures Patt and Patel Ch. 3

23

Logical CompletenessLogical CompletenessCan implement Can implement ANYANY truth table with AND, OR, NOT. truth table with AND, OR, NOT.

AA BB CC DD00 00 00 00

00 00 11 00

00 11 00 11

00 11 11 00

11 00 00 00

11 00 11 11

11 11 00 00

11 11 11 00

1. AND combinations that yield a "1" in the truth table.

2. OR the resultsof the AND gates.

Combinational Logic

Page 24: 1 Digital Logical Structures Patt and Patel Ch. 3

24

Combinational vs. Combinational vs. SequentialSequential

Combinational CircuitCombinational Circuit

– always gives the same output for a given set of inputs•ex: adder always generates sum and carry, regardless of previous inputs

Page 25: 1 Digital Logical Structures Patt and Patel Ch. 3

25

Sequential CircuitSequential Circuit– stores information– output depends on stored information (state)

plus input• so a given input might produce different

outputs, depending on the stored information

– example: ticket counter• advances when you push the button• output depends on previous state

– useful for building “memory” elements and “state machines”

Combinational vs. Sequential

Page 26: 1 Digital Logical Structures Patt and Patel Ch. 3

26

Gated D-LatchGated D-Latch

Two inputs: D (data) and WE (write enable)Two inputs: D (data) and WE (write enable)– when WE = 1, latch is set to value of D

• S = NOT(D), R = D– when WE = 0, latch holds previous value

• S = R = 1

Sequential Logic: Storage

Page 27: 1 Digital Logical Structures Patt and Patel Ch. 3

27

RegisterRegisterA register stores a multi-bit value.A register stores a multi-bit value.

– We use a collection of D-latches, all controlled by a common WE.– When WE=1, n-bit value D is written to register.

Sequential Logic: Storage

Page 28: 1 Digital Logical Structures Patt and Patel Ch. 3

28

MemoryMemory

Now that we know how to store bits,Now that we know how to store bits,we can build a memory – a logical we can build a memory – a logical k × mk × m array of stored bits.array of stored bits.

•••

k = 2n

locations

m bits

Address Space:number of locations(usually a power of 2)

Addressability:number of bits per location(e.g., byte-addressable)

Sequential Logic: Storage

Page 29: 1 Digital Logical Structures Patt and Patel Ch. 3

29

2222 x 3 Memory x 3 Memory

addressdecoder

word select word WEaddress

writeenable

input bits

output bits

Sequential Logic: Storage

Page 30: 1 Digital Logical Structures Patt and Patel Ch. 3

30

State MachineState Machine

Another type of sequential circuitAnother type of sequential circuit– Combines combinational logic with storage– “Remembers” state, and changes output

(and state) based on inputs and current state

State Machine

CombinationalLogic Circuit

StorageElements

Inputs Outputs

Sequential Logic: State Machine

Page 31: 1 Digital Logical Structures Patt and Patel Ch. 3

31

Combinational vs. Combinational vs. SequentialSequential

Two types of “combination” locksTwo types of “combination” locks

4 1 8 430

15

5

1020

25

CombinationalSuccess depends only onthe values, not the order in which they are set.

SequentialSuccess depends onthe sequence of values(e.g, R-13, L-22, R-3).

Sequential Logic: State Machine

Page 32: 1 Digital Logical Structures Patt and Patel Ch. 3

32

Representing Multi-bit Representing Multi-bit ValuesValues

•Number bits from right (0) to left (n-1)Number bits from right (0) to left (n-1)

– just a convention -- could be left to right, but must be consistent

•Use brackets to denote range:Use brackets to denote range:D[l:r]D[l:r] denotes bit denotes bit ll to bit to bit rr, from , from leftleft to to rightright

A = 0101001101010101

A[2:0] = 101A[14:9] = 101001

015

May also see A<14:9>, especially in hardware block diagrams.

Page 33: 1 Digital Logical Structures Patt and Patel Ch. 3

33

LC-3 Data LC-3 Data PathPath

CombinationalLogic

State Machine

Storage

Page 34: 1 Digital Logical Structures Patt and Patel Ch. 3

34

Questions?Questions?

Page 35: 1 Digital Logical Structures Patt and Patel Ch. 3

35