41
CSC258: Computer Organization Combinational Logic 1

CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

  • Upload
    lylien

  • View
    231

  • Download
    1

Embed Size (px)

Citation preview

Page 1: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

CSC258: Computer Organization

Combinational Logic

1

Page 2: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Clear your desk!

• Please protect your work.

• Keep your own eyes on your paper or stare up to the sky.

• When you’re done, fold your paper with the answer inside.

• Please write legibly.

• I have awful handwriting, too, but that doesn’t help me read bad handwriting.

2

Page 3: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Week 3 Quiz

The schematic on the left is from Ex.1.88in your textbook.

1. Provide the sum-of-products boolean equation for the function implemented in the schematic.

2. Provide a truth table for the boolean equation: Y = AB + B ̅

3. In one sentence, describe what operation a 2-1 multiplexer performs.

3

Page 4: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

4

Page 5: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Week 2 Quiz Notes

1. Add the 6-bit 2’s complement numbers 001011 and 111000. Please show your work but circle your result.

Several students responded “1000011”. You should discard the “1” at the beginning, because the response needs to be in 6-bit 2’s complement.

5

Page 6: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Anonymous: Structure and Questions

• “... you cover the topics that are important rather than us asking about what we don't understand. That way we know what we need to focus on instead of spending a lot of time in class on minor topics that we may have trouble with, but aren't that important.”

• I feel like you’re saying, “Please guide us. We don’t know what’s important.”

• And I agree, knowing what’s important is hard.

• But it’s also a goal of the course:If you can identify what’s important, you can learn on your own.

6

Page 7: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Anonymous: Structure and Questions

• I know that you’ll need some structure. I’m asking for something very difficult.

• The reading guides, including the exercises, tell you what to focus on. Prep those for lecture.

• Don’t worry about “unimportant” material or asking the “wrong” question. I’m filtering and rephrasing questions people ask.

• ... not that any of the material is “unimportant”. :-)

7

Page 8: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Anonymous: Asking Questions

• “People will only ask questions if they actually spent some time on the subject. I ... won't ask any questions other than please be the textbook unless I read it.”

• Exactly! And that’s the key in this course:

I’m asking you to spend some time on reading and exercises before class, so that you’re ready to ask the difficult questions.

• Why focus on questions? It’s an important, hard skill. It reflects that you know what is important and what you don’t understand.

8

Page 9: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Goals of this Course

• Those were great comments. They tie into what this course is about.

• Yes, we’re learning CS material: logic, computer architecture, assembly programming.

• But we’re also learning how to be independent professionals.That means learning ...

• how to read technical material

• how to identify when you’re stumped

• how to ask the questions you need answered.9

Page 10: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

No Response to Email?

• Please make sure you’re using my correct email address: andrew.petersen @ utoronto.ca

• Andrew PetersOn is a student who is probably frustrated to be getting so much email for me.

10

Page 11: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

11

Page 12: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Why Karnaugh Maps?

• Applying simplification rules to a formula is an awful way to find a minimum circuit

• Simplification takes trial and error.

• There’s no guarantee that you’ve found the minimal circuit.

• Checking your simplification requires enumeration on a truth table.

• The (partial) solution: Karnaugh maps12

Page 13: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Gray Codes

• “Gray codes” were developed for error-prone systems

• Named after Frank Gray, one of the developers of the television

• The idea: encoding in which only one bit changes at a time

2-bit 3-bit

00 000

01 001

11 011

10 010

110

111

101

10013

Page 14: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Karnaugh Maps

• Karnaugh maps represent logic formula

• To optimize a formula, draw the biggest rectangles you can!

• Results in the optimal formula

¬X X

¬Y

Y

1 1

1

¬Y + X

14

Page 15: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

What is “Optimal”?

• K-maps don’t necessarily create the smallest circuits.

• Instead, they create small circuits that optimize latency:

“How long must we wait for a circuit to complete its computation?”

• Each transistor adds latency, since it takes a small amount of time to switch.

• Hence, each gate in series adds delay, so deeper circuits are slower.

• 2-level circuits, like those corresponding to sum-of-products or product-of-sums forms, are fast circuits.

15

Page 16: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

A 4-variable K-map

16

Page 17: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

K-map Example: Reading XY + XB

17

Page 18: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Overlapping

18

Pick the largest rectangles -- even if they

overlap

Page 19: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

K-Maps Wrap Around

19

Page 20: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

20

An Old Lab Problem ...

Page 21: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Specify the Function on a Truthtable

21

Page 22: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Mapping Minterms to K-Map

22

Page 23: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Extracting (Latency-Minimized) Formula

23

Page 24: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Alternately: Map the 0’s and Negate

24

How does this circuit compare?

Page 25: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Limits to Karnaugh Maps

• Any design with more than 4 variables is difficult to visualize

• Karnaugh maps provide an optimized 2-level circuit, but ...

• If we care about other factors like space efficiency or heat, we need to perform other optimizations.

25

Page 26: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

The Grim Bottom Line

• Very few constraints can be optimized automatically

• Many hardware design problems can only be fully solved by enumeration -- by trying every possibility

• Wire and gate layout

• Modularization

26

Page 27: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Summary of Logic Gates

• Circuits are modeled with Boolean logic

• Functions are represented as formulas or truth tables

• Each logical operator has a corresponding gate

• We have two tools for optimizing circuits:

• Algebraic simplification

• Karnaugh Maps

• Logic design at modern scales is a difficult and expensive proposition

27

Page 28: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Boolean Logic Questions

• How are boolean logic and modern circuits related?

• Can you convert a boolean formula into a circuit and vice-versa?

• Can you convert a boolean fomula into a truth table and vice-versa?

• Can you produce a minimum cost circuit (in terms of latency) using simplification or K-maps?

• Now that we have the ability to create circuits, what basic units do we need to build a computer?

28

Page 29: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

29

Page 30: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Where are we?

• Our goal, eventually, is to build a simple processor.

• For that, we need:

• The ability execute simple operations (like “add”)

• The ability to choose between values.

• Storage for a small number of values (variables)

• A circuit to process instructions from the user.

30

Page 31: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

31

Page 32: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

How do we get there?

• We can already do NAND -- and that’s everything right?

• Can you prove that?

• We’ll look at shifters and adders in a couple of weeks, and we’ll use those to create an ALU.

32

Page 33: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Where are we?

• Our goal, eventually, is to build a simple processor.

• For that, we need:

• The ability execute simple operations (like “add”)

• The ability to choose between values.

• Storage for a small number of values (variables)

• A circuit to process instructions from the user.

33

Page 34: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

34

Page 35: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Multiplexer (Mux)

• Sometimes, we need “select” or “choose”

• A mux takes multiple inputs and a selector input

MUX

Out

D0

D1

D2

D3

D4

D5

D6

D7

A0A1A2

A1 A0 Out0 0 D0

0 1 D1

1 0 D2

1 1 D3

35

Page 36: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

... and the Reverse

• Since we “mux”, we should be able to “demux”

• Take one input and a selector, and produce the input on one of the outputs

• The text also covered encoders and decoders.

• An encoder takes 2N inputs and produces a N-bit (compacted) output

• A decoder takes an N-bit input and produces 2N (extracted) outputs

36

Page 37: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Where are we?

• Our goal, eventually, is to build a simple processor.

• For that, we need:

• The ability execute simple operations (like “add”)

• The ability to choose between values.

• Storage for a small number of values (variables)

• A circuit to process instructions from the user.

37

Page 38: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

How do we get there?

• We need some device that can store data.

• We also need some concept of “time”, so we know when to store new data.

• We’ll start putting together these pieces next week.

38

Page 39: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

39

Page 40: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

Storing Data

• Our circuits so far provide an output given some inputs

• The other half of the equation is storage

• Use feedback to “freeze” a value

• These are SR latches

• They rely on feedback.

S

R

Q

Q’

40

Page 41: CSC258: Computer Organization Combinational Logic · Combinational Logic 1. Clear your desk! ... • The reading guides, including the exercises, ... 101 100 13. Karnaugh Maps

SR Latches

• R is labeled “reset”

• S is labeled “set”

• When R is high, Q becomes 0

• When S is high, Q becomes 1

• Otherwise, Q keeps its previous value.

R S Q ¬Q0 0 Q ¬Q0 1 1 01 0 0 11 1 ? ?

41