CPSC 121: Models of Computation. Module 1: Propositional Logic

Similar documents
The reduction in the number of flip-flops in a sequential circuit is referred to as the state-reduction problem.

CPSC 121: Models of Computation Lab #5: Flip-Flops and Frequency Division

Section 6.8 Synthesis of Sequential Logic Page 1 of 8

CPSC 121: Models of Computation Lab #5: Flip-Flops and Frequency Division

Chapter 3. Boolean Algebra and Digital Logic

1. True/False Questions (10 x 1p each = 10p) (a) I forgot to write down my name and student ID number.

Switching Circuits & Logic Design, Fall Final Examination (1/13/2012, 3:30pm~5:20pm)

Combinational Logic Design

To design a sequential logic circuit using D-Flip-flop. To implement the designed circuit.

Sequential Logic Notes

CSE221- Logic Design, Spring 2003

4:1 Mux Symbol 4:1 Mux Circuit

CS302 - Digital Logic Design FAQs By

CS 61C: Great Ideas in Computer Architecture

11.1 As mentioned in Experiment 10, sequential logic circuits are a type of logic circuit where the output

Contents Circuits... 1

Synchronous Sequential Logic

Digital Circuits ECS 371

Introduction to Digital Electronics

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

ELEC 204 Digital System Design LABORATORY MANUAL

Minnesota State College Southeast

LAB 3 Verilog for Combinatorial Circuits

The word digital implies information in computers is represented by variables that take a limited number of discrete values.

Chapter 3: Sequential Logic Systems

EXPERIMENT 13 ITERATIVE CIRCUITS

EECS 140 Laboratory Exercise 7 PLD Programming

Chapter 5 Sequential Circuits

CPS311 Lecture: Sequential Circuits

North Shore Community College

Logic. Andrew Mark Allen March 4, 2012

EE292: Fundamentals of ECE

PHYSICS 5620 LAB 9 Basic Digital Circuits and Flip-Flops

COMP12111: Fundamentals of Computer Engineering

Chapter 5: Synchronous Sequential Logic

Logic Design II (17.342) Spring Lecture Outline

8/30/2010. Chapter 1: Data Storage. Bits and Bit Patterns. Boolean Operations. Gates. The Boolean operations AND, OR, and XOR (exclusive or)

Laboratory Sequential Circuits

How to Design a Sequential Counter

LAB 3 Verilog for Combinational Circuits

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

Part I: Graph Coloring

10.1 Sequential logic circuits are a type of logic circuit where the output of the circuit depends not only on

UNIT 1: DIGITAL LOGICAL CIRCUITS What is Digital Computer? OR Explain the block diagram of digital computers.

Laboratory Sequence Circuits

VLSI System Testing. BIST Motivation

Lecture 8: Sequential Logic

MODULE 3. Combinational & Sequential logic

LAB #4 SEQUENTIAL LOGIC CIRCUIT

Section 001. Read this before starting!

EECS 270 Homework the Last Winter 2017

Quiz #4 Thursday, April 25, 2002, 5:30-6:45 PM

Digital Logic. ECE 206, Fall 2001: Lab 1. Learning Objectives. The Logic Simulator

Good Evening! Welcome!

CHAPTER 4: Logic Circuits

Digital Networks and Systems Laboratory 2 Basic Digital Building Blocks Time 4 hours

Find the equivalent decimal value for the given value Other number system to decimal ( Sample)

Department of CSIT. Class: B.SC Semester: II Year: 2013 Paper Title: Introduction to logics of Computer Max Marks: 30

AM AM AM AM PM PM PM

NAND/NOR Implementation of Logic Functions

Where Are We Now? e.g., ADD $S0 $S1 $S2?? Computed by digital circuit. CSCI 402: Computer Architectures. Some basics of Logic Design (Appendix B)

Chapter 4. Logic Design

MC9211 Computer Organization

COMP2611: Computer Organization. Introduction to Digital Logic

Step 1 - shaft decoder to generate clockwise/anticlockwise signals

Individual Project Report

Assignment 2b. ASSIGNMENT 2b. due at the start of class, Wednesday Sept 25.

Software Engineering 2DA4. Slides 3: Optimized Implementation of Logic Functions

ET398 LAB 4. Concurrent Statements, Selection and Process

CS302 Digital Logic Design Solved Objective Midterm Papers For Preparation of Midterm Exam

Digital Principles and Design

Digital Circuit Engineering

Chapter 7 Counters and Registers

Microcontrollers and Interfacing week 7 exercises

Chapter 5 Synchronous Sequential Logic

EECS 270 Midterm 2 Exam Closed book portion Fall 2014

Computer Systems Architecture

6.3 Sequential Circuits (plus a few Combinational)

Note 5. Digital Electronic Devices

AIM: To study and verify the truth table of logic gates

EXPERIMENT: 1. Graphic Symbol: OR: The output of OR gate is true when one of the inputs A and B or both the inputs are true.

CHAPTER 4: Logic Circuits

DALHOUSIE UNIVERSITY Department of Electrical & Computer Engineering Digital Circuits - ECED Experiment 2 - Arithmetic Elements

Data Representation. signals can vary continuously across an infinite range of values e.g., frequencies on an old-fashioned radio with a dial

Experiment (6) 2- to 4 Decoder. Figure 8.1 Block Diagram of 2-to-4 Decoder 0 X X

Encoders and Decoders: Details and Design Issues

Logisim: A graphical system for logic circuit design and simulation

Digital Circuit And Logic Design I. Lecture 8

Digital Circuit And Logic Design I

MODEL QUESTIONS WITH ANSWERS THIRD SEMESTER B.TECH DEGREE EXAMINATION DECEMBER CS 203: Switching Theory and Logic Design. Time: 3 Hrs Marks: 100

1. a) For the circuit shown in figure 1.1, draw a truth table showing the output Q for all combinations of inputs A, B and C. [4] Figure 1.

A Review of logic design

Laboratory 1 - Introduction to Digital Electronics and Lab Equipment (Logic Analyzers, Digital Oscilloscope, and FPGA-based Labkit)

Good Evening! Welcome!

Laboratory 8. Digital Circuits - Counter and LED Display

Previous Lecture Sequential Circuits. Slide Summary of contents covered in this lecture. (Refer Slide Time: 01:55)

ELCT201: DIGITAL LOGIC DESIGN

Introduction Actel Logic Modules Xilinx LCA Altera FLEX, Altera MAX Power Dissipation

ENGG2410: Digital Design Lab 5: Modular Designs and Hierarchy Using VHDL

DALHOUSIE UNIVERSITY Department of Electrical & Computer Engineering Digital Circuits - ECED 220. Experiment 4 - Latches and Flip-Flops

Transcription:

CPSC 121: Models of Computation Module 1: Propositional Logic

Module 1: Propositional Logic By the start of the class, you should be able to: Translate back and forth between simple natural language statements and propositional logic. Evaluate the truth of propositional logic statements using truth tables. Translate back and forth between propositional logic statements and circuits that assess the truth of those statements. CPSC 121 2018W T1 2

Module 1: Propositional Logic Quiz 1 feedback: Very well done overall. There were two small mistakes made by about 20% of you: One: ~a v b is the same as (~a) v b, not the same as ~(a v b). Two: ~a v ~b is not the same as ~(a v b). ~a ^ ~b is not the same as ~(a ^ b). We will discuss the open-ended question a bit later. CPSC 121 2018W T1 3

Module 1: Coming up... What is coming up? Second pre-class quiz: due tomorrow at 19:00. Assigned reading for the quiz: Epp, 4 th edition: 2.2 Epp, 3 rd edition: 1.2 Rosen, 6 th or 7 th edition: 1.1 from page 6 onwards. Assignment #1 due Monday September 24 th, 2018 at 16:00. CPSC 121 2018W T1 4

Module 1: Coming up... What is coming up? Third pre-class quiz: due Wednesday September 19 th at 19:00. Assigned reading for the quiz: Epp, 4th edition: 2.5 Epp, 3rd edition: 1.5 Rosen, any edition: not much http://en.wikipedia.org/wiki/binary_numeral_system Also read: http://www.ugrad.cs.ubc.ca/~cs121/current/handouts/ signed-binary-decimal-conversions.html CPSC 121 2018W T1 5

Module 1: Coming up... Labs start tomorrow. There is a pre-lab that must be completed before the start of your lab session. This will also be true of the other labs. Don't forget about it! CPSC 121 2018W T1 6

Module 1: Propositional Logic CPSC 121: the BIG questions:? We are not yet ready to directly address any of the big questions.??????? But this module lays out the ground work for all of them.???????? CPSC 121 2018W T1 7

Module 1: Propositional Logic By the end of this module, you should be able to: Build computational systems to solve real problems, using both propositional logic expressions and equivalent digital logic circuits, The light switches problem from the 1st pre-class quiz. The 7- or 4-segment LED displays we will discuss in class. CPSC 121 2018W T1 8

Module 1: Propositional Logic Module outline: Writing a truth table From circuits to propositions Light switches 7-segment displays More exercises CPSC 121 2018W T1 9

Module 1.1: Writing a truth table Must the combinations in a truth table be listed in a specific order? Our recommendation: Why? CPSC 121 2018W T1 10

Module 1.1: Writing a truth table We will always start with false (you will see why later). With 3 variables: the first column contains 4 false followed by 4 true. the second column contains 2 false, 2 true, 2 false, 2 true. and the third column alternates false with true. CPSC 121 2018W T1 11

Module 1.2: Writing a truth table With k variables: the first column has 2 k-1 false and then 2 k-1 true the second column has 2 k-2 false and then 2 k-2 true (twice) etc. Another way to get the same list of combinations: Write a truth table with k-1 variables twice. Add false in front of the first copy, and true in front of the second one. CPSC 121 2018W T1 12

Module 1: Propositional Logic Module outline: Writing a truth table From circuits to propositions Light switches 7-segment displays More exercises CPSC 121 2018W T1 13

Module 1.2: From circuits to propositions What does this circuit compute? CPSC 121 2018W T1 14

Module 1.2: From circuits to propositions How do we find the logical expression that corresponds to a circuit's output? First we write the operator for the gate that produces the circuit's output. The operator's left argument is the expression for the circuit connected to the gate's first input. The operator's right argument is the expression for the circuit connected to the gate's second input. This is our first algorithm! CPSC 121 2018W T1 15

Module 1.2: From circuits to propositions Example: What does this circuit compute? CPSC 121 2018W T1 16

Module 1.2: From circuits to propositions What is the simplest logical expression that corresponds to the following circuit? CPSC 121 2018W T1 17

Module 1: Propositional Logic Module outline: Writing a truth table From circuits to propositions Light switches 7-segment displays More exercises CPSC 121 2018W T1 18

Module 1.3: Light switches Consider again: Design a light that changes state whenever any of the switches that control it is flipped. Ideally your solution would work with any number! CPSC 121 2018W T1 19

Module 1.3: Light switches How do we approach this? We first need to make sure we understand what we are designing. Then we use propositional logic to model the circuit s desired output. It s helpful to start with very simple versions of the problem First try 1 switch. Then try 2 switches. Then try 3 switches. Then see if we can generalize to n switches. CPSC 121 2018W T1 20

Module 1.3: Light switches Making sure we understand what we are designing. Which of these would be usable (most useful) as the output of our circuit? a) the switch is flipped b) the switch is on c) the light is on d) the light changed state CPSC 121 2018W T1 21

Module 1.3: Light switches Making sure we understand what we are designing. Which of these would be usable (most useful) as input to our circuit? a) the switch is flipped b) the switch is on c) the light is on d) the light changed state CPSC 121 2018W T1 22

Module 1.3: Light switches One switch: make sure we understand the problem first. Is the light on or off when the switch is on? a) Always on. b) Always off. c) Depends, but a correct solution should always do the same thing. d) Depends, and a correct solution might do different things at different times. CPSC 121 2018W T1 23

Module 1.3: Light switches One switch: Which circuit(s) is/are correct solution(s)? a) b) c) d) two of a, b, c. e) all three of a, b, c. CPSC 121 2018W T1 24

Module 1.3: Light switches Two switches: make sure we understand the problem first. Is the light on or off when both switches are on? a) Always on. b) Always off. c) Depends, but a correct solution should always do the same thing for a given setting of the switches. d) Depends, and a correct solution might do different things at different times for the same setting of the switches. CPSC 121 2018W T1 25

Module 1.3: Light switches Two switches: which circuit(s) work(s)? a) b) c) d) Both a and b work. e) Both b and c work. CPSC 121 2018W T1 26

Module 1.3: Light switches Circuit design tip: if you are not sure where to start while designing a circuit, First determine the inputs and the output Then build the truth table. Finally turn it into a circuit. For the three switches problem: We can decide arbitrarily what the output is when all three switches are OFF. This determines the output for all other cases! Let's see how... CPSC 121 2018W T1 27

Module 1.3: Light switches What pattern do we observe? The light is ON if Now to generalize to n switches... What do you think the answer is? How can we convince ourselves that it is correct? Mathematical induction CPSC 121 2018W T1 28

Module 1: Propositional Logic Module outline: Writing a truth table From circuits to propositions Light switches 7-segment displays More exercises CPSC 121 2018W T1 29

Module 1.3: 7-segment displays Problem: design a circuit that displays the numbers 0 through 9 using seven LEDs (lights) in the shape illustrated below. CPSC 121 2018W T1 30

Module 1.4: 7-segment displays How do we represent the inputs? Use? logical (true/false) values. Each integer represented by 1 specific combination of input values. Could we do this arbitrarily? Yes! But we won't How many of you know about binary representation? CPSC 121 2018W T1 31

Module 1.4: 7-segment displays Understanding: what is the smallest number of inputs (wires going into the circuit) possible? a) 1 b) 4 c) 7 d) 10 e) None of the above CPSC 121 2018W T1 32

Module 1.4: 7-segment displays Here's how we will do it: Number X1 X2 X3 X4 0 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 CPSC 121 2018W T1 33

Module 1.4: 7-segment displays Understanding: how many outputs (lights) are there? a) 1 b) 4 c) 7 d) 10 e) None of the above CPSC 121 2018W T1 34

Module 1.4: 7-segment displays Let's try it out with a few victims volunteers... Which other person's algorithm do you need to know about? a) No one else's b) Your neighbours c) The person opposite to you d) Everybody else's e) None of the above. CPSC 121 2018W T1 35

Module 1.4: 7-segment displays Let us look at the bottom-left segment. Which is the correct truth table? Number X1 X2 X3 X4 0 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 (a) (b) (c) (d) (e) T T T 0 0 F F F 3 2 T T F 4 6 F F T 8 8 T F T F F F T T F F F F T T T F F F CPSC 121 2018W T1 36

Module 1.4: 7-segment displays From the truth table, we can Write a proposition for each row Connect the propositions together using OR. This works for every truth table, but may give a circuit that is much larger than necessary. CPSC 121 2018W T1 37

Module 1.4: 7-segment displays Which proposition is true only for the red row? a) a ^ b v c ^ d b) ~a v ~b v c v ~d c) ~a ^ ~b ^ c ^ ~d d) a b c d e) None of the above Nb X1 X2 X3 X4 0 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 CPSC 121 2018W T1 38

Module 1.4: 7-segment displays Let us look at the middle segment now: How many rows of the truth table contain T? How can we avoid having that many terms with 4 variables each? CPSC 121 2018W T1 39

Module 1.4: 7-segment displays Looking back at the bottom-left segment: There may be a simpler proposition, which will translate into a smaller circuit. Can you find a pattern in the rows for which the segment should be on? CPSC 121 2018W T1 40

Module 1: Propositional Logic Module outline: Writing a truth table From circuits to propositions Light switches 7-segment displays More exercises CPSC 121 2018W T1 41

Module 1.4: More exercises Prove that our two solutions for the lower-left segment are not logically equivalent. You should do this by providing values for the variables, so the two propositions have different truth values. Why are they both correct solutions, despite that? Finish the problem by building circuits for the other 5 segments. Design a circuit that takes three bits as input, and outputs the binary representation for their sum. CPSC 121 2018W T1 42

Module 1.4: More exercises 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. CPSC 121 2018W T1 43