1 Problem: Problem: 7-Segment LED Display 7-Segment LED Display - - PDF document

1
SMART_READER_LITE
LIVE PREVIEW

1 Problem: Problem: 7-Segment LED Display 7-Segment LED Display - - PDF document

snick Outline snack Learning Goals Problems and Discussion CPSC 121: Models of Computation Side note: numbers from Booleans 2016W2 Expressiveness of Propositional Logic Propositional Logic, Continued Next Lecture Notes


slide-1
SLIDE 1

1

snick  snack

CPSC 121: Models of Computation 2016W2

Propositional Logic, Continued Steve Wolfman, based on notes by Patrice Belleville and others

1

This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Outline

  • Learning Goals
  • Problems and Discussion

– Side note: numbers from Booleans

  • Expressiveness of Propositional Logic
  • Next Lecture Notes

2

Learning Goals: In-Class

By the end of this unit, you should be able to:

– Build combinational computational systems using propositional logic expressions and equivalent digital logic circuits that solve real problems, e.g., our 7- or 4-segment LED displays (using a “DNF” or any other successful approach).

3

Where We Are in The Big Stories

Theory How do we model computational systems? Now: learning the underpinnings of all our models (formal logical reasoning with Boolean values). Hardware How do we build devices to compute? Now: establishing

  • ur baseline tool

(gates), briefly justifying these as baselines, and designing complex functions from gates.

4

Outline

  • Learning Goals
  • Problems and Discussion

– Side note: numbers from Booleans

  • Expressiveness of Propositional Logic
  • Next Lecture Notes

5

Problem: 7-Segment LED Display

Problem: Design a circuit that displays the numbers 0 through 9 using seven LEDs (lights) in the shape illustrated above.

6

slide-2
SLIDE 2

2 Problem: 7-Segment LED Display

Problem: Design a circuit that displays the numbers 0 through 9 using seven LEDs (lights) in the shape illustrated above.

Understanding the story: How many inputs to our circuit are there?

  • a. One
  • b. Seven
  • c. Ten
  • d. Sixteen
  • e. None of these

7

Problem: 7-Segment LED Display

Problem: Design a circuit that displays the numbers 0 through 9 using seven LEDs (lights) in the shape illustrated above.

First: what’s the circuit’s job?

8

Problem: 7-Segment LED Display “Input Symbols”

Problem: Design a circuit that displays the numbers 0 through 9 using seven LEDs (lights) in the shape illustrated above.

How many different messages (values) must the circuit understand?

  • a. One
  • b. Seven
  • c. Ten
  • d. Sixteen
  • e. None of these

9

Problem: 7-Segment LED Display “Input Lines”

Problem: Design a circuit that displays the numbers 0 through 9 using seven LEDs (lights) in the shape illustrated above.

How many different wires carry those messages?

  • a. One
  • b. Seven
  • c. Ten
  • d. Sixteen
  • e. None of these

10

A bit like a parameter like in CPSC 110, but we only get 1/0 parameters (Booleans).

Side Note: Truth Tables and Numbers

If we agree on a convention for the rows of a truth table, we can assign a number to each row…

# a b c F F F 1 F F T 2 F T F 3 F T T 4 T F F 5 T F T 6 T T F 7 T T T

Of course, as Epp says, we could agree on a different convention.

11

Representing Positive Integers

This is the convention we use for the positive integers 0-9, which requires (at least) 4 variables:

Notice the order: Fs first.

# a b c d F F F F 1 F F F T 2 F F T F 3 F F T T 4 F T F F 5 F T F T 6 F T T F 7 F T T T 8 T F F F 9 T F F T ...

12

slide-3
SLIDE 3

3 Problem: 7-Segment LED Display

Problem: Design a circuit that displays the numbers 0 through 9 using seven LEDs (lights) in the shape illustrated above.

Understanding the story: How many outputs from our circuit are there?

  • a. One
  • b. Seven
  • c. Ten
  • d. Sixteen
  • e. None of these

13

BEFORE we answer it: Is that a good question?

Exercise: Human Circuit

Let’s simulate the display with people. If you’re not at the front, pick one person and think about what their algorithm is.

14

Exercise: Human Circuit

Which other people’s algorithms does your person need to know about?

  • a. No one else’s
  • b. Only their neighbours’
  • c. Everyone else’s
  • d. Some other group

15

Analyzing One Segment

What’s the truth table for the lower-left segment?

# a b c d F F F F 1 F F F T 2 F F T F 3 F F T T 4 F T F F 5 F T F T 6 F T T F 7 F T T T 8 T F F F 9 T F F T

  • ut

F T F T F T F T F T

a. b. c. d.

  • e. None of

these.

  • ut

2 6 8

  • ut

T F T F F F T F T F

  • ut

F T F T T T F T F T

16

Analyzing One Segment

From the truth table, we can make an expression for each true row and OR them together.

# a b c d out 0 F F F F T 1 F F F T F 2 F F T F T 3 F F T T F 4 F T F F F 5 F T F T F 6 F T T F T 7 F T T T F 8 T F F F T 9 T F F T F

17

(??)  (??)  (??)  (??) See Epp (4th ed) Example 2.4.5! (3rd ed Example 1.4.5) Let’s try one!

Analyzing One Segment

From the truth table, we can make an expression for each true row and OR them together.

# a b c d out 0 F F F F T 1 F F F T F 2 F F T F T 3 F F T T F 4 F T F F F 5 F T F T F 6 F T T F T 7 F T T T F 8 T F F F T 9 T F F T F

18

Which logical statement is true

  • nly in this row?
  • a. ~a  ~b  c  ~d
  • b. a  b  c  d
  • c. ~a  ~b  c  ~d
  • d. a  b  ~c  d
  • e. None of these
slide-4
SLIDE 4

4 Analyzing One Segment

From the truth table, we can make an expression for each true row and OR them together.

# a b c d out 0 F F F F T 1 F F F T F 2 F F T F T 3 F F T T F 4 F T F F F 5 F T F T F 6 F T T F T 7 F T T T F 8 T F F F T 9 T F F T F

19

(~a  ~b  ~c  ~d)  (~a  ~b  c  ~d)  (~a  b  c  ~d)  ( a  ~b  ~c  ~d)

Designing the Expression with Many Ts

Let’s try another LED: the upper-right. With eight Ts, we’d need eight expressions! Too bad we can’t model Fs rather than Ts!

# a b c d

  • ut

F F F F T 1 F F F T T 2 F F T F T 3 F F T T T 4 F T F F T 5 F T F T F 6 F T T F F 7 F T T T T 8 T F F F T 9 T F F T T

20

Designing the Expression with Many Ts

We can by negating statement we construct! (Instead of building out, we build ~out and then negate it.)

# a b c d

  • ut

F F F F T 1 F F F T T 2 F F T F T 3 F F T T T 4 F T F F T 5 F T F T F 6 F T T F F 7 F T T T T 8 T F F F T 9 T F F T T

Which of these correctly models the LED? a. ~(~a  b  ~c  d)  ~(~a  b  c  ~d) b. ~(a  ~b  c  ~d)  ~(a  ~b  ~c  d) c. ~[(~a  b  ~c  d)  (~a  b  c  ~d)] d. ~[(a  ~b  c  ~d)  (a  ~b  ~c  d)] e. None of these

21

Problem: 7-Segment LED Display

Problem: Design the seven LED display circuit. Approach: Solve each of the seven outputs separately and put the whole thing together. Here’s the two LEDs we’ve solved, simplified:

22

PRACTICE Exercise for NEXT UNIT (logical equiv)

Prove that our solution for the upper-right LED is logically equivalent to the corresponding circuit

  • n the previous slide.

Prove that our solution for the lower-left LED is not logically equivalent to the corresponding circuit

  • n the previous slide, and explain why not.

Note: to disprove a logical equivalence, you must give truth values for the inputs that yield different

  • utputs.

23

PRACTICE Exercise for Circuit Design

Finish the problem!

24

slide-5
SLIDE 5

5 Concept Q: 7-Segment LED

Imagine we were solving for an LED in a display for “Brahmi” numerals. Which of these is most likely to make our problem easier?

  • a. More entries in that LED’s column of the truth

table that are true (turn some Fs into Ts).

  • b. Fewer entries in that LED’s column of the truth

table that are true (turn some Ts into Fs).

  • c. More legal input symbols (e.g., 0-15 instead of 0-9).
  • d. Fewer legal input symbols (e.g., 0-4 instead of 0-9).
  • e. None of these will make the problem easier.

25

Outline

  • Prereqs, Learning Goals, and Quiz Notes
  • Problems and Discussion

– Side note: numbers from Booleans

  • Expressiveness of Propositional Logic
  • Next Lecture Notes

26

Expressiveness of Propositional Logic

Problem: Is propositional logic (and combinational circuits) universal for Boolean functions—able to implement a truth table with any number of columns and list of T and F in the output?

a b c d

  • ut

F F F F F F F F T T F F T F T F F T T F F T F F T

...

?

27

Expressiveness of Propositional Logic

Problem: Is propositional logic universal for Boolean functions? Yes! We’ve already given an algorithm to turn any truth table into a corresponding propositional logic statement. Universality is a pretty cool result for our very first model!

28

Outline

  • Prereqs, Learning Goals, and Quiz Notes
  • Problems and Discussion

– Side note: numbers from Booleans

  • Expressiveness of Propositional Logic
  • Next Lecture Notes

29

Learning Goals: In-Class

By the end of this unit, you should be able to:

– Build combinational computational systems using propositional logic expressions and equivalent digital logic circuits that solve real problems, e.g., our 7- or 4-segment LED displays.

30

slide-6
SLIDE 6

6 Next Lecture Learning Goals: Pre-Class

By the start of class, you should be able to:

– Translate back and forth between simple natural language statements and propositional logic, now with conditionals and biconditionals. – Evaluate the truth of propositional logical statements that include conditionals and biconditionals using truth tables. – Given a propositional logic statement and an equivalence rule, apply the rule to create an equivalent statement.

Example: given (u  s)  s, apply p  q  ~p  q. Note: p maps to (u  s) and q maps to s. Result: ~(u  s)  s

31

Next Lecture Prerequisites

Reread Sections 1.1 and 1.4 (3rd ed) or 2.1 and 2.4 (4th ed). Read Section 1.2 (3rd ed) or 2.2 (4th ed). Complete the open-book, untimed quiz on Vista that’s due before the next class.

32

Motivating Problem

Design a representation (for a digital logic circuit) for the state of a stop light. Design a circuit that takes the current states of a stop light and produces the next state. Design a circuit that takes the current states of two stop lights and produces true if they are “safe in combination” and false otherwise. (By “in combination” we mean that one of the states is the state of the lights along one road at an intersection and the other is the state of the lights along the other road.

33

Try to solve it. Follow along with us if you need help!

Reminder: Motivating Problem

Design a representation for the stop light state. What are the states? Red, yellow, green. How can we represent this in a circuit? We could number them, and we know how to represent numbers. We’ll use (arbitrarily) red = 0, yellow = 1, green = 2. These will be 2-bit values, then, and 3 will be invalid/unused.

34

Reminder: Motivating Problem

Design a circuit that takes the states of two stop lights and produces true iff they are “safe in combination”. How many input lines does this have? Two stop light states, which we decided were 2-bit numbers. So, 2*2 = 4 input lines. How many output lines does it have? We only need to say “true = safe/false = unsafe”; so, one.

35

Reminder: Motivating Problem

Design a circuit that takes the states of two stop lights and produces true iff they are “safe in combination”. What does “safe” really mean here? It’s unsafe if cars can go in both directions. So, at least one direction needs to be red.

36

slide-7
SLIDE 7

7 Reminder: Motivating Problem

Designing a “safe” circuit. R = 00, Y = 01, G = 10. Draw a truth table. We only need R/Y/G, not the invalid values; so, we’ll do a 9-row truth table instead of the full 16-row table (although 16 rows would not be wrong). a and b are our signals. We’ll use colour to track their meaning in the table, but you could also add extra columns with R, Y, G symbols in them!

37

a1 a2 b1 b2 Safe F F F F T F F F T T F F T F T F T F F T F T F T F F T T F F T F F F T T F F T F T F T F F

Reminder: Motivating Problem

Designing a “safe” circuit. From here out we can ignore the domain and solve the logic problem. We just need to model the T rows (or the F ones if we prefer). That’s: (~a1~a2~b1~b2)  (~a1~a2~b1b2)  (~a1~a2b1~b2)  (~a1a2~b1~b2)  (a1~a2~b1~b2) You can then translate this directly to a circuit.

38

a1 a2 b1 b2 Safe F F F F T F F F T T F F T F T F T F F T F T F T F F T T F F T F F F T T F F T F T F T F F

Reminder: Motivating Problem

Here’s a different way to go. Design a circuit that takes the states of two stop lights and produce true iff they are “safe in combination”. What does “safe” really mean here? It’s unsafe if cars can go in both directions. So, at least one direction needs to be red.

39

Reminder: Motivating Problem

What does “safe” really mean here? It’s unsafe if cars can go in both directions. So, at least one direction needs to be red. So, we need a circuit that says “a is red  b is red”. We can then write a circuit that tests whether a light is red as a (pretty easy!) sub-problem, copy that twice (once with a as the input and once with b) and then feed the outputs into an OR gate! Try solving the problem this way!

40

snick  snack

Some Things to Try...

(on your own if you have time, not required)

41

Problem: 4-Segment LED Display

Problem: build a circuit that displays the numbers 1 through 9 represented by four Boolean values p, q, r, and s on a 4- segment Boolean display.

1 2 3 4 5 6 7 8 9

42

slide-8
SLIDE 8

8 Problem: One-Bit Addition

Problem: build a circuit that takes three

  • ne-bit numbers as input and outputs their

sum as a two-bit number.

43

Problem: Updating the “PC”

Problem: Create logic that calculates the amount to increase the PC by, given the values NeedValC and NeedRegIDs.

44

Problem: Updating the “PC”

45

Concept Q: Fetch Logic

What’s the minimum number of Boolean

  • utputs necessary for this circuit?
  • a. 1
  • b. 2
  • c. 3
  • d. 4
  • e. Cannot be determined from the

information given.

46