The Logic of Compound Statements

Slides:



Advertisements
Similar presentations
Adders Used to perform addition, subtraction, multiplication, and division (sometimes) Half-adder adds rightmost (least significant) bit Full-adder.
Advertisements

DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Binary Numbers.
Binary Numbers.
8 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
1 Floating Point Representation and Arithmetic (see Patterson Chapter 4)
A Simple ALU Binary Logic.
B261 Systems Architecture
CSC 2510 Test 3 1. Give the names of the formula or rule that provides the answer for each of the following problems. Do not try to solve the problems!
Monika Gope Lecturer IICT, KUET
Logic Circuits Basic Building Blocks Dr John Cowell
Digital Systems Introduction Binary Quantities and Variables
Logic Gates. Transistors as Switches ¡V BB voltage controls whether the transistor conducts in a common base configuration. ¡Logic circuits can be built.
Logic Gates Flip-Flops Registers Adders
Fixed-point and floating-point numbers CS370 Fall 2003.
Lecture no 6. Two's Complement Given a negative number (N), represented using the Two's Complement representation (N*), the magnitude of the number (P)
Binary Number Systems.
25 seconds left…...
Datorteknik IntegerAddSub bild 1 Integer arithmetic Depends what you mean by "integer" Assume at 3-bit string. –Then we define zero = 000 one = 001 Use.
Data Storage and manipulation. Data Storage Computers store and manipulate data in the form of electronic pulses (high and Low voltages). This digitised.
NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.
Binary, Hexadecimal, and Base 10.
Year 3 Objectives: Number NUMBER AND PLACE VALUE Objective 1: Read and write numbers up to 1000 in numerals and words Read and write all numbers to 100.
EET 1131 Unit 7 Arithmetic Operations and Circuits
Representing Numbers: Integers
HEXADECIMAL NUMBERS Code
Assembly Language and Computer Architecture Using C++ and Java
Introduction to Programming with Java, for Beginners
Assembly Language and Computer Architecture Using C++ and Java
Digital Arithmetic Wen-Hung Liao, Ph.D.. Objectives Perform binary addition, subtraction, multiplication, and division on two binary numbers. Add and.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
1 CSE-221 Digital Logic Design (DLD) Lecture-1: Digital Systems & Number Systems.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Chapter 2 Bits, Data Types, and Operations. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-2 How do we.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Numbering systems.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Dale & Lewis Chapter 3 Data Representation. Data and computers Everything inside a computer is stored as patterns of 0s and 1s Numbers, text, audio, video,
Bits, Data Types, and Operations. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-2 How do we represent.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
Number Representation. 10/12/2015CDA31002 Conversion between Representations Now we can represent a quantity in different number representations How can.
PART 2 Data Types 1. Integers 2. 2’s Complement 3. Conversion
Bits, Data Types, and Operations Slides based on set prepared by Gregory T. Byrd, North Carolina State University.
Number systems, Operations, and Codes
Chapter 2 Bits, Data Types, and Operations. 2-2 How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works.
Number Systems & Operations
Instructor:Po-Yu Kuo 教師:郭柏佑
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Outline Binary Addition 2’s complement Binary Subtraction Half Adder
Introduction To Number Systems Binary System M. AL-Towaileb1.
©2010 Cengage Learning SLIDES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION Click the mouse to move to the next page. Use the ESC key to exit.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
Digital Systems and Number Systems
COMPUTING FUNDAMENTALS
Digital Logic & Design Lecture 02.
Two’s Complement Shortcut
Introduction to Computer Engineering
Chapter 2 Bits, Data Types, and Operations
Presentation transcript:

The Logic of Compound Statements Chapter 1 The Logic of Compound Statements

Number Systems and Circuits for Addition Karnaugh Maps Section 1.5 Number Systems and Circuits for Addition Karnaugh Maps

Decimal Representation Recall decimal numbers (base 10) can be described as a number sentence. Decimal: 6,145 == 6x1000 + 1x100 + 4x10 + 5 6x103 + 1x102 + 4x101 + 5x100 Decimal: 7,000 == 7x1000 + 0x100 + 0x10 + 0 7x103 + 0x102 + 0x101 + 0x100

Binary Representation Binary numbers (base 2) are sequence of {0,1}digits. The value of the number depends on it’s location in the sequence. Binary: 1101 => 1x8 + 1x4 + 0x2 + 1 1x23 + 1x22 + 1x21 + 1x20 = (decimal) 8+4+0+1 = 1310 Binary: 10101 => 1x16 + 0x8 + 1x4 + 0x2 + 1 1x24 + 0x23 + 1x22 + 1x21 + 1x20 = (decimal) 16+0+4+0+1 = 2110

Converting Binary to Decimal Converting from binary to decimal is performed by expanding the binary to a number sentence and summing over the number sentence. Example: 1101012 = 1x25 + 1x24 + 0x23 + 1x22 + 0x21 + 1x20 = 5310

Converting Decimal to Binary Convert decimal to binary using the repeated division method as follows. The divisor (bottom number) is the base that the decimal is being converted to. Example: Convert 5010 to binary 5010 = 1100102

Example Convert 20910 to binary Answer: 11010001

Binary Addition Binary addition is performed in the same manner as decimal addition. When and how do you perform a carry? Carry is dependent on the base. Sum greater than the (base – 1) results in a carry. Example: 12 + 02 = 1 (no carry) 02 + 12 = 1 (no carry) 12 + 12 = 102 (carry)

Examples

Binary Subtraction Binary subtraction is performed in the same manner as decimal subtraction. When and how do you perform a borrow? Borrow is dependent on the base. In decimal you borrow a 10’s value from the adjoining digit, however, in binary you borrow a 102 (210). Example: 12 - 02 = 1 (no borrow) 12 - 12 = 0 (no borrow) 102 - 12 = 012 (borrow from 2’s position) 210 – 110 = 110 (check)

Examples

Circuits for Addition Addition requires two inputs (P, Q) and two outputs (Carry, Sum). Input/output table can be constructed to show the relationship of P,Q to Carry and P,Q to Sum.

Addition Circuits Half-Adder

Addition Circuits Full-Adder A full adder requires three inputs, (P, Q) and a carry in (R). Use canonical form to create circuit

Addition Circuits Full-Adder Full-adder can be constructed from multiple half-adders. Use canonical form to create circuit

Addition Circuits Full-Adder Full-adder can be constructed from two half-adders. Use canonical form to create circuit

Unsigned Integers 329 101 Non-positional notation could represent a number (“5”) with a string of ones (“11111”) problems? Weighted positional notation like decimal numbers: “329” “3” is worth 300, because of its position, while “9” is only worth 9 most significant least significant 329 102 101 100 101 22 21 20 3x100 + 2x10 + 9x1 = 329 1x4 + 0x2 + 1x1 = 5

Unsigned Integers (cont.) An n-bit unsigned integer represents 2n values: from 0 to 2n-1. 22 21 20 1 2 3 4 5 6 7

Signed Integers With n bits, we have 2n distinct values. assign about half to positive integers (1 through 2n-1) and about half to negative (- 2n-1 through -1) that leaves two values: one for 0, and one extra Positive integers just like unsigned – zero in most significant (MS) bit 00101 = 5 Negative integers sign-magnitude – set MS bit to show negative, other bits are the same as unsigned 10101 = -5 one’s complement – flip every bit to represent negative 11010 = -5 in either case, MS bit indicates sign: 0=positive, 1=negative

Two’s Complement + 11011 (-5) + (-9) 00000 (0) 00000 (0) Problems with sign-magnitude and 1’s complement two representations of zero (+0 and –0) arithmetic circuits are complex How to add two sign-magnitude numbers? e.g., try 2 + (-3) How to add to one’s complement numbers? e.g., try 4 + (-3) Two’s complement representation developed to make circuits easy for arithmetic. for each positive number (X), assign value to its negative (-X), such that X + (-X) = 0 with “normal” addition, ignoring carry out 00101 (5) 01001 (9) + 11011 (-5) + (-9) 00000 (0) 00000 (0)

Two’s Complement Representation If number is positive or zero, normal binary representation, zeroes in upper bits if required. If number is negative, start with positive number flip every bit (i.e., take the one’s complement) then add one 00101 (5) 01001 (9) 11010 (1’s comp) (1’s comp) + 1 + 1 11011 (-5) (-9)

Two’s Complement Shortcut To take the two’s complement of a number: copy bits from right to left until (and including) the first “1” flip remaining bits to the left 011010000 011010000 100101111 (1’s comp) + 1 100110000 100110000 (flip) (copy)

Two’s Complement Signed Integers MS bit is sign bit – it has weight –2n-1. Range of an n-bit number: -2n-1 through 2n-1 – 1. The most negative number (-2n-1) has no positive counterpart. -23 22 21 20 1 2 3 4 5 6 7 -23 22 21 20 1 -8 -7 -6 -5 -4 -3 -2 -1

Converting Binary (2’s C) to Decimal If leading bit is one, take two’s complement to get a positive number. Add powers of 2 that have “1” in the corresponding bit positions. If original number was negative, add a minus sign. n 2n 1 2 4 3 8 16 5 32 6 64 7 128 256 9 512 10 1024 X = 011010002 = 26+25+23 = 64+32+8 = 10410 Assuming 8-bit 2’s complement numbers.

More Examples X = 001001112 = 25+22+21+20 = 32+4+2+1 = 3910 = 25+22+21+20 = 32+4+2+1 = 3910 n 2n 1 2 4 3 8 16 5 32 6 64 7 128 256 9 512 10 1024 X = 111001102 -X = 00011010 = 24+23+21 = 16+8+2 = 2610 X = -2610 Assuming 8-bit 2’s complement numbers.

Converting Decimal to Binary (2’s C) First Method: Division Find magnitude of decimal number. (Always positive.) Divide by two – remainder is least significant bit. Keep dividing by two until answer is zero, writing remainders from right to left. Append a zero as the MS bit; if original number was negative, take two’s complement. X = 104ten 104/2 = 52 r0 bit 0 52/2 = 26 r0 bit 1 26/2 = 13 r0 bit 2 13/2 = 6 r1 bit 3 6/2 = 3 r0 bit 4 3/2 = 1 r1 bit 5 X = 01101000two 1/2 = 0 r1 bit 6