COS 116 The Computational Universe Laboratory 8: Digital Logic II

Similar documents
COS 116 The Computational Universe Laboratory 7: Digital Logic I

To practice combinational logic on Logisim and Xilinx ISE tools. ...

COMP combinational logic 1 Jan. 18, 2016

Introduction to Computer Engineering (E114)

CARLETON UNIVERSITY. Laboratory 2.0

LECTURE 4. Logic Design

NOTE: This tutorial contains many large illustrations. Page breaks have been added to keep images on the same page as the step that they represent.

CS2630: Computer Organization Homework 3 Combinational logic and Logisim Due October 14, 2016, 11:59pm

CSC 101: Lab #5 Prelab Boolean Logic Practice Due Date: 5:00pm, day after lab session

EE261 Computer Project 1: Using Mentor Graphics for Digital Simulation

Lecture #21 March 31, 2004 Introduction to Gates and Circuits

CS 051 Homework Laboratory #2

NAME EET 2259 Lab 3 The Boolean Data Type

CMSC 201 Fall 2018 Lab 04 While Loops

CSC 101: Lab #5 Boolean Logic Practice Due Date: 5:00pm, day after lab session

Lecture 21: Combinational Circuits. Integrated Circuits. Integrated Circuits, cont. Integrated Circuits Combinational Circuits

Statistics 13, Lab 1. Getting Started. The Mac. Launching RStudio and loading data

Combinational Circuits Digital Logic (Materials taken primarily from:

LAB #3: ADDERS and COMPARATORS using 3 types of Verilog Modeling

Section 1 Microsoft Excel Overview

CSCI 161: Introduction to Programming I Lab 1a: Programming Environment: Linux and Eclipse

How to set up an Amazon Work Profile for Windows 8

FireFox. CIS 231 Windows 10 Install Lab # 3. 1) Use either Chrome of Firefox to access the VMware vsphere web Client.

COS 116 The Computational Universe Laboratory 9: Internet Structure and Congestion Control

Student Success Guide

Name EGR 2131 Lab #6 Number Representation and Arithmetic Circuits

Google Sheets: Spreadsheet basics

Student Number: UTORid: Question 0. [1 mark] Read and follow all instructions on this page, and fill in all fields.

Interactive Tourist Map

CIS 231 Windows 10 Install Lab # 3

Computer Organization and Levels of Abstraction

Lab 1 Modular Design and Testbench Simulation ENGIN 341 Advanced Digital Design University of Massachusetts Boston

CIS 231 Windows 2012 R2 Server Install Lab #1

Solution printed. Do not start the test until instructed to do so! CS 2504 Intro Computer Organization Test 2 Spring 2006.

When you first start OneNote, it creates a sample notebook for you. You can use this notebook or quickly create your own.

FSA Algebra 1 EOC Practice Test Guide

Engin 100 (section 250), Winter 2015, Technical Lecture 3 Page 1 of 5. Use pencil!

HOW TO BUILD YOUR FIRST ROBOT

In Depth: Writer. The word processor is arguably the most popular element within any office suite. That. Formatting Text CHAPTER 23

Lab #9: Introduction to Logisim CS 0447/COE 0147: Spring 2012

Step 3: Type the data in to the cell

Propositional Calculus. Math Foundations of Computer Science

Page 1 of 6. ME 3200 Mechatronics I Laboratory Lab 2: LabView Computer Systems. Introduction

ENGR 1000, Introduction to Engineering Design

How to Use the Explore Service Area Tool: By Geography.

Before you get started, make sure you have your section code since you ll need it to enroll. You can get it from your instructor.

ESE 150 Lab 07: Digital Logic

Verilog Lab. Two s Complement Add/Sub Unit. TA: Xin-Yu Shi

Forces acting at a point

A3 A2 A1 A0 Sum4 Sum3 Sum2 Sum1 Sum

4. Write a sum-of-products representation of the following circuit. Y = (A + B + C) (A + B + C)

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2010

Electronic Portfolios in the Classroom

Reading: Managing Files in Windows XP

Hardware Description and Verification Lava Exam

Unit 2: Data Storage CS 101, Fall 2018

GOOGLE DRIVE & DOCS. USERNAME: [for example,

PowerPoint 2016: Part 1

Computer Organization and Levels of Abstraction

Learning Worksheet Fundamentals

Experiment 8 Introduction to VHDL

Use of in-built functions and writing expressions

Beginner s Guide to Microsoft Excel 2002

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013

University of Florida EEL 3701 Dr. Eric M. Schwartz Department of Electrical & Computer Engineering Revision 0 12-Jun-16

User pages for RM Portico

What is OneNote? The first time you start OneNote, it asks you to sign in. Sign in with your personal Microsoft account.

UC Berkeley College of Engineering, EECS Department CS61C: Combinational Logic Blocks

UC Berkeley College of Engineering, EECS Department CS61C: Combinational Logic Blocks

Session 2. >_ {Code4Loop}; Roochir Purani

Content Collection. How to Access Content Collection. From the homepage: From a course:

QUICK EXCEL TUTORIAL. The Very Basics

Working with Attribute Data and Clipping Spatial Data. Determining Land Use and Ownership Patterns associated with Streams.

FSA Algebra 1 EOC Practice Test Guide

Grade 8 FSA Mathematics Practice Test Guide

Homework #1: SSH. Step 1: From the start button (lower left hand corner) type Secure. Then click on the Secure Shell File Transfer Client.

Florida Standards Assessments

How To Upload Your Newsletter

Part 1. Creating an Array of Controls or Indicators

EXPERIMENT NUMBER 7 HIERARCHICAL DESIGN OF A FOUR BIT ADDER (EDA-2)

Electronic Engineering Part 1 Laboratory Experiment. Digital Circuit Design 1 Combinational Logic. (3 hours)

Skills Exam Objective Objective Number

PlicElements Quick Start Guide

Accommodations Upload Quick Guide Oklahoma School Testing Program & College and Career Readiness Assessments Spring 2018

University of Pennsylvania. Department of Electrical and Systems Engineering. ESE Undergraduate Laboratory. Introduction to LabView

Lab 11-1 Lab User Profiles and Tracking

Using Windows 7 Explorer By Len Nasman, Bristol Village Computer Club

FireFox. CIS 231 Windows 2012 R2 Server Install Lab #1

Lacon Childe School. Accessing Parental Online Reports Parent Guidelines

Lesson 4 Page Styles

ENCM 339 Fall 2017: Editing and Running Programs in the Lab

Start Active-HDL. Create a new workspace TUTORIAL #1 CREATING AND SIMULATING SIMPLE SCHEMATICS

Internet Basics Session 2: Using a Web Browser. Maureen Southorn Oswego Public Library PCC Fall 2010

CSE P567 - Winter 2010 Lab 1 Introduction to FGPA CAD Tools

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

SINE AND COSINE SUBROUTINES

Brianna Nelson Updated 6/30/15 HOW TO: Docs, Sheets, Slides, Calendar, & Drive. English

Practicing on word processor, spreadsheet, search engines, citation and referencing, and creating zipped files.

Chapter 3 Arithmetic for Computers

Part II: Creating Visio Drawings

Transcription:

COS 116 The Computational Universe Laboratory 8: Digital Logic II In this lab you ll learn that, using only AND, OR, and NOT gates, you can build a circuit that can add two numbers. If you get stuck at any point, feel free to discuss the problem with another student or a TA. However, you are not allowed to copy another student s answers. Hand in your lab report at the beginning of lecture on Tuesday, April 10. Include responses to questions printed in bold. (Number them by Part and Step.) This lab will be done entirely in Logisim. You can install Logisim by clicking this link: http://www.cs.princeton.edu/courses/archive/spring07/cos116/lab7_files/logisim.exe When prompted, save the file to the Desktop. After the download completes, double-click logisim.exe. (If you are warned that this program may be unsafe, click Run and Ok as needed.) Part 1: Odd-Parity Circuit The first step in creating an adder is building a three-input odd-parity circuit. The output of an odd-parity circuit is TRUE if and only if an odd number of its inputs are TRUE. The truth table for a three-input odd-parity circuit is: A B C Output 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 COS 116 Lab 8 1

To be able to build a circuit from a truth table, you must first convert the truth table to a Boolean formula using a technique called sum-of-products. Sum-of-products is best explained by example. Suppose you had the following truth table: A B Output 0 0 0 0 1 1 1 0 1 1 1 0 The steps of the sum-of-products technique are: i. Identify the combinations of input values (rows of the truth table) that make the output TRUE. A B Output 0 0 0 0 1 1 1 0 1 1 1 0 ii. For each combination of input values, create a Boolean formula that is TRUE if and only if the inputs have those particular values. In this case, there are two combinations of input values that make the output TRUE yielding two formulas: A B and A B iii. Take the formulas that you created in step 2 and OR them together to form a single formula representing the truth table: A B + A B In English, this formula means that the output of the function is TRUE if either A is FALSE and B is TRUE or if A is TRUE and B is FALSE. 1. Now that you know how to convert truth tables to Boolean formulas, derive a Boolean formula for the three-input odd-parity circuit. 2. Construct the three-input odd-parity circuit in Logisim. There should be three inputs and one output. For this lab, you may use AND and OR gates with more than two inputs. 3. Label the inputs A, B, and C and the output Out. To label an input or output, switch to the arrow tool and then click on the input or output. A list COS 116 Lab 8 2

of attributes for the object will appear in the lower left corner of the window. Edit the Label attribute and press return when done. 4. Name the circuit. Since you ll be using it later, you need to give the circuit a name. In the list on the left, right-click on the item labeled main and select Rename Circuit Give the circuit the name odd-parity. 5. Verify that the circuit you built matches the truth table for a three-input odd-parity circuit. 6. Save the file by going to File > Save. Name the file odd-parity.circ. 7. Save a picture of your circuit to hand in with your lab report. There are a few ways to do this. Here is a simple method: a. Click anywhere in the window of the Logisim program, and press Alt+PrintScreen. This takes a snapshot of the active window. b. Open a new Word document, and press Ctrl+V. This copies your snapshot into the document. COS 116 Lab 8 3

Part 2: 1-bit Adder Computers perform addition using the same method that you learned in grade school adding the two input numbers one column at a time starting on the right and carrying a one as needed. For example, to compute 7+6=13, a computer does: Consider one column of this addition: 1 1 0 0 Carries 0 1 1 1 Input A (7) + 0 1 1 0 Input B (6) 1 1 0 1 Sum (13) 1 1 0 0 Carries 0 1 1 1 Input A (7) + 0 1 1 0 Input B (6) 1 1 0 1 Sum (13) You can view it as a circuit with three inputs A one bit from the first input number B one bit from the second input number CarryIn a bit which is 1 if the we are carrying a one over from the previous column and two outputs Sum one bit of the sum CarryOut a bit which is 1 if we are carrying a one over to the next column A B CarryIn Sum CarryOut COS 116 Lab 8 4

A circuit to compute a single column of an addition is called a 1-bit adder. 1. Fill in the truth table for a 1-bit adder and include it in your lab report: A B CarryIn Sum CarryOut 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 It turns out that the circuits that you ve built so far in this lab and the previous one majority and odd-parity are enough to implement a 1-bit adder. Examine the truth table for a 1-bit adder. 2. Which of the circuits that you ve already built (majority or odd-parity) can be used to compute the Sum output of the adder and which can be used to compute the CarryOut output? For reference, the truth table of the three-input majority circuit is: A B C Output 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1 3. Now you ll build a 1-bit adder. Download our pre-built majority circuit by clicking this link: http://www.cs.princeton.edu/courses/archive/spring07/cos116/lab8_files/majority.circ When prompted, save the file to a location that you can remember. If you are not prompted to save the file and instead see text in the Web browser window, select File > Save As in the Web browser. COS 116 Lab 8 5

4. Create a new circuit file in Logisim by going to File > New. 5. Import our majority subcircuit and your odd-parity subcircuit into the new circuit file. To import a circuit into the file, go to Project > Load Library > Logisim Library and then navigate to file containing the subcircuit that you want to import. The files that you ll need to import should be named majority.circ and odd-parity.circ. 6. Once the two subcircuits have been imported, you should see two new folders named majority and odd-parity in the column on the left. Click on the + signs next to them to see the circuits themselves. You can click on these subcircuits to select them and then click anywhere in the dotted field to place them in your new circuit. Unfortunately, when you place one of the subcircuits in the dotted field, it just shows up as an unlabeled box. However, there are little blue dots on the box indicating the locations of the subcircuit s input and output connectors. The input connectors are on the side that has the gray semicircle. Also, if you hold the mouse pointer over a subcircuit, a label with the name of the subcircuit appears, and if you hold the pointer over one of the subcircuit s inputs or outputs, a label with the name of the input or output appears. 7. Build a 1-bit adder circuit and label the inputs and outputs. There should be three inputs labeled A, B, and CarryIn, and two outputs labeled Sum and CarryOut. You should only need one majority subcircuit and one oddparity subcircuit and no other gates. 8. Verify that the circuit you built matches the truth table that you completed in Part 2 Step 1. COS 116 Lab 8 6

9. Place some text next to each of the subcircuits (majority and odd-parity) that identifies the subcircuit so that we can tell which subcircuit is which. To place text, select the A tool and then click on the location in the dotted field where you want the text to appear. 10. Name the circuit 1bit-adder using the procedure described in Part 1 Step 4. 11. Save the circuit file with the name 1bit-adder.circ. 12. Save a picture of your circuit to hand in with your lab report. Part 3: 4-bit Adder Now that you ve built a circuit that can process one column of an addition a 1-bit adder you can now combine several 1-bit adders to make an adder that can add two 4-bit numbers. 1. Create a new circuit file in Logisim by going to File > New. 2. Import your 1-bit adder subcircuit using the procedure described in Part 2 Steps 5 and 6. 3. Build a 4-bit adder. There should be 8 inputs (4 bits for each input number) and 4 outputs (the bits of the sum). You should only need four 1-bit adder subcircuits. COS 116 Lab 8 7

4. To build the 4-bit adder, you will need one other gate that will allow you to force a wire to always carry a particular value (0 or 1). To use this gate, click on the + next to the Gates folder in the column on the left to view the list of available gates, then select Constant, and then click in the dotted field to place the gate. To change the value of a Constant gate, switch to the pointer tool, click on the gate, and change the gate s Value attribute. 5. Label the inputs A0-A3 and B0-B3 and the outputs S0-S3 where A0, B0, and S0 are the least significant bits of the input and output numbers. 6. Try your adder out and verify that it can add 7+6 correctly. Also, try out some other input values and verify that your circuit adds them correctly as well. 7. Try adding 8+8. What is the result? Is that result correct? If it s not correct, why isn t it? 8. Name the circuit 4bit-adder using the procedure described in Part 1 Step 4. 9. Save the circuit file with the name 4bit-adder.circ. 10. Save a picture of your circuit to hand in with your lab report. COS 116 Lab 8 8

Clearly, the procedure that you used to build a 4bit adder could be used to build an adder of any size. Modern computers have adders that are 32, 64, or 128 bits wide. Further Questions to Answer in Your Report 1. In your 4-bit adder, the CarryOut wire of the last 1-bit adder (the one connected to A3 and B3) doesn t affect any of the bits of the sum. When is the value of that wire 1? What does a value of 1 on that wire mean? 2. For any path through a circuit from a particular input to a particular output, you can measure its depth by counting the number of AND, OR, and NOT gates standing between the input and the output. The depth of an entire circuit is equal to the depth of the deepest path through that circuit. It is useful to measure the depth of a circuit because the deeper a circuit is; the longer it takes for a signal to travel through the circuit. What is the depth of your 4-bit adder circuit? Justify your answer. (You may need to open up majority.circ in Logisim in order to determine its depth.) 3. You saw how it s possible to derive a Boolean formula corresponding to a truth table using the sum-of-products technique. Does the sum-of-products procedure always produce the shortest possible Boolean formula corresponding to a given truth table? If you think it does, explain why. If you think it does not, give an example of a truth table for which the sum-ofproducts technique does not produce the shortest possible formula. COS 116 Lab 8 9