convert a two s complement number back into a recognizable magnitude.

Size: px
Start display at page:

Download "convert a two s complement number back into a recognizable magnitude."

Transcription

1 1 INTRODUCTION The previous lesson introduced binary and hexadecimal numbers. In this lesson we look at simple arithmetic operations using these number systems. In particular, we examine the problem of representing negative numbers. YOUR AIMS On completing this lesson you should be able to: add and subtract binary numbers describe two ways in which negative numbers can be represented by a binary code perform arithmetic operations using two s complement notation convert a two s complement number back into a recognizable magnitude. STUDY ADVICE Again, this is a short unit in terms of text but it will require considerable time to complete all the examples and Self-Assessment Questions. Have to hand a pencil and scrap paper!

2 2 ADDITION OF BINARY NUMBERS In principle, binary numbers are added in exactly the same way as in denary addition but remember we are working to a base of two! This means that (1 + 1) will generate a carry. The rules of binary addition are summarised below: carry 1 You may find it worthwile to write these rules down several times so that you remember them. Then study the following examples. Example 1 Add the binary numbers 1010 and carry The bits in each column are added together and any carry bit generated is added into the column on the left.

3 3 Example 2 Add the binary numbers 1011 and * carry In this example the column marked with an asterisk represents the addition ( ) = 11. This means that 1 is entered into this column and one is carried over to the next most significant column. Example 3 Perform carry A harder example, this, with lots of carries. Note that the most significant column also generates a carry. Microprocessors have a carry flag that can be set when an overflow carry is generated more on this in a later lesson.

4 4 BINARY SUBTRACTION There is no theoretical reason why binary numbers cannot be subtracted using the same rules as for denary subtraction, i.e. starting with the least significant column we subtract one bit from another. The rules for binary subtraction will then be: (borrow 1 from left hand column) In the fourth rule, 1 from 0 won t go and we have to borrow a bit from the adjacent column. This now forms the equivalent of (2 1) = 1. Example 4 Subtract 0111 from Note that the answer can be checked by adding the result to the number subtracted

5 5 Example 5 Subtract 0011 from (In column 2 we have to borrow from column 3.) borrow This is as far as we shall go in binary subtraction. The reason for this is that computers do not perform subtraction in this way. There are two reasons why they do not: (a) Binary addition is carried out in the arithmetic logic unit (ALU) built into the CPU. The addition is done by special adder hardware. If subtraction were to be done in the conventional way then subtractor hardware would also be required. (b) Subtraction can give rise to negative results. Thus we need a means of representing positive and negative numbers. Conventionally we do this by using the symbols + and. We must remember, however, that a binary machine will only recognise two symbols (namely 0 and 1 ). We cannot therefore use extra symbols to denote a number s sign.

6 6 REPRESENTATION OF NEGATIVE NUMBERS Two methods will be considered. THE SIGN-MAGNITUDE METHOD This method is widely used in data communications systems. The magnitude of a number is its value, ignoring its sign. Thus the magnitude of +3 is 3 and -8 is 8. The magnitude of minus one hundred is equal to the magnitude of plus one hundred. In the sign magnitude method, the sign of a binary number is given by the MSB. The remaining bits give the magnitude of the number. If positive numbers are represented by the MSB being set to 0, then negative numbers are represented by the MSB being set to 1. To illustrate the idea, the binary equivalents of -5 to +5 are listed below (using 1 byte numbers): SIGN BIT MAGNITUDE

7 As a matter of curiosity, note that this method gives two zeros, (minus zero) and (plus zero)! This, however, does not cause any problems. Also, there is, as a matter of fact, no hard and fast rule as to whether a 1 or a 0 is used to represent a positive number. Which convention is adopted will depend upon the particular system. The advantage of the method is the simplicity with which it allows the magnitude of the number to be quickly established. A serious disadvantage though, is that the method cannot easily be used for binary arithmetic. Consider the following examples.

8 8 Example 6 Add (+3) to ( 3) using binary signed numbers +3 = and 3 = Clearly the result should have been zero ((+3) + ( 3) = 0) but the addition has come up with 6. Example 7 Add ( 5) to (+2). 5 = and +2 = This time the answer is 7 and not 3 as it should be. You may care to try a few examples yourself and I am sure you will soon be convinced that this method is quite hopeless for arithmetic. Nevertheless it does have the value of simplicity and is used in systems where the data does not have to be processed arithmetically. The sign-magnitude method is used, for example, in the PCM (plus code modulation) system of digital audio applications.

9 9 THE TWO S COMPLEMENT METHOD The one s complement of a binary number is obtained by changing all the 1 s to 0 s and vice versa. (This process is known as INVERTING the number.) A few examples of binary numbers and their one s complements are given below. NUMBER ONE S COMPLEMENT Note that in each of the above examples adding the binary number to its complement always yields Moreover we note that in performing the operation of adding a binary number to its complement +1 will always yield 0000 or zero. The two s complement of a binary number is formed by taking the one s complement and adding 1 to it. Example 8 Find the two s complement of 14. Express the answer as an 8 bit number = One s complement = Two s complement = ( one s complement + 1)

10 10 = ( ) = Example 9 Find the two s complement of = Two s complement = ( ) = We have shown above that adding a binary number to its one s complement +1 will always yield 0000 or zero. As the one s complement +1 is in fact the two s complement of the binary number then we can write: N + N = 0 where N is the binary number and N is its two s complement. Thus N = N Thus two s complement form can be used to represent the negative of a binary number that can be used in arithmetic operations. It may be a bit tricky for us to use and recognise the two s complement form, but relatively simple arithmetic circuits in the CPU are quite at home with them. To convince yourself that the two s complement representation of binary numbers works, study the following examples.

11 11 Example 10 Using the two s complement method perform the operation (25 14). (25 14) may be rewritten as (25 + ( 14)). The procedure is to represent ( 14) in two s complement form and then add this to = add ( ) = [1] carry As we are working in 8 bit numbers, the carry one is ignored. The result is, therefore, = Example 11 Using the two s complement representation show that = = add ( 25) = [1] carry Again, the carry bit is ignored and a zero result is obtained.

12 12 Example 12 Using the two s complement representation evaluate (14 25). 14 = add ( 25) = This answer highlights one of the difficulties of the two s complement form. In the complement system all negative numbers have a MSB of 1, so we know our result is negative, but the magnitude of the number is by no means obvious! Before attempting to evaluate, in denary, the solution to example 12, let's investigate our new systems a little more closely. Initially, for simplicity, we will use 4 bit signed numbers. This gives a numbering range of ( 8) to (+7) as indicated on the number line shown below. DENARY ( 8+0) ( 8+1) ( 8+2) ( 8+3) ( 8+4) ( 8+5) ( 8+6) ( 8+7) BINARY The clue to evaluating the magnitude of a negative number represented in two s complement form is to note that, for example, ( 3) = ( 8 + 5). Looking at the number here we see that ( 3) = Thus the two s complement form can be regarded as consisting of a mixture of two numbers: (a) a negative number represented by the MSB and equal to ( 2 n 1 ) where n is the bit length of the number

13 13 (b) a positive number evaluated from the remaining bits. NEGATIVE NUMBER POSITIVE NUMBER ( 2n 1 ) = ( 2 3 ) = 8 ( ) = 5 The result is, of course, obtained by adding the two numbers together. We are now in a position to return to Example 12. The result is an 8-bit signed number and thus the number range will be from ( 128) to (+127). This range was evaluated using the formulae: (a) lower limit = ( 2 n 1 ) giving 128 for n = 8 (b) upper limit = (2 n 1 1) giving +127 for n = 8 Splitting ( ) into two parts yields: ( ) = 128 ( ) = 117 The answer, in denary is, therefore, ( ) = 11 The system works!

14 14 A SIMPLE TRICK! Before concluding this lesson we introduce you to a simple rule for converting binary numbers into a two s complement form, which can save a lot of work. The rule is: (a) Write down the binary number, starting with the LSB, up to and including the first 1. (b) Invert the remaining bits. Consider example 13. Example 13 Write down the two s complement of invert these bits to give 'up to and including the first '1" gives ' ' '1 0' Thus two s complement of is Example 14 Perform the arithmetic operation (17 97) in binary. Express your answer in two s complement form and then convert it to denary. Work in 8 bit numbers.

15 15 17 = = ( 97) = (in two s complement) Adding ( 97) to (+17): Thus in two s complement the result is (which is clearly negative as the MSB is set to 1 ). Converting this to denary: = ( ) + ( ) = ( ) = 80 The trick can also be used in reverse to convert a negative number expressed in two complement form back into a magnitude. Consider the result to example 14, namely In reversing the trick we: (a) write down the number up to and including the first 1 (yielding 10000) (b) invert all the other bits (giving ). The magnitude is thus = 80 As we know we are dealing with a negative number the answer is 80.

16 16 Which method you use (the more formal [ 2 n -1 + (positive number)] or the trick ) is entirely up to you there is little to choose between them in terms of speed of conversion. This completes our work on computer arithmetic, but to further develop and consolidate your understanding try the following Self-Assessment Questions.

17 17 SELF-ASSESSMENT QUESTIONS 1. Add the following binary numbers. In each case express the answer as an 8 bit number. In each case state if a carry is generated beyond the MSB. (a) (b) (c) (d) Add the following HEX numbers by converting to binary. Express the answer in HEX. (a) (b) 0F + 02 (c) 0ABC + DA0E 3. Convert the following numbers to two s complement form: (a) (b) (c) (d)

18 18 4. In the table below, negative numbers are represented by the two s complement form. Identify the odd negative numbers: (a) (b) (c) (d) (e) (f) (g) (h) (i) (j) F8 (k) 8A (l) CB 5. A sixteen bit microprocessor is to be used to perform arithmetic operations using signed numbers in two s complement form. Calculate the numbering range that can be represented using 16 bits. 6. Convert the denary numbers in (a) (d) to 8 bit binary numbers and evaluate using the two s complement method. Leave your answers in binary form. (a) 17 8 (b) (c) 4 48 (d) When performing an arithmetic operation using signed numbers a microprocessor gives the result F6. Express this in denary. 8. Subtract C006 from A0F7 using two s complement arithmetic. Express the answer in Hex.

19 19 9. Perform the operations: (a) 7A + 85 (b) 7A 7B Comment upon the result. 10. State the effect upon the magnitude of an 8 bit binary number by: (a) shifting each bit one position to the left (b) shifting each bit one position to the right. The answers are on page 20.

20 20 ANSWERS TO SELF-ASSESSMENT QUESTIONS 1. (a) (no carry) (b) (carry generated) (c) (carry generated) (d) (carry generated) 2. (a) B (b) 0 F

21 21 (c) 0ABC DA0E E4CA (a) Using the trick the complements may be written straight down: (a) (b) (c) (d) Negative odd numbers will have MSB and LSB at 1. Therefore (c), (g) and (l) are odd negative numbers. 5. The numbering range will extend from ( 2 n 1 ) to (2 n 1 1) where n = 16. Thus the range is ( 2 15 ) to (2 15 1) = to (a) 17 = = ( 8) = (17) ( 8) The carry one is ignored and thus the answer is

22 22 (b) 126 = = ( 33) = (126) ( 33) Again, the carry is ignored, leaving the result (c) 4 = = ( 48) = (4) ( 48) (d) 97 = = ( 125) = (97) = ( 125) =

23 23 7. F6 = which is obviously negative. Thus = ( 2 7 ) + ( ) = = 10 (N.B. You will see in later work that this kind of conversion needs to be applied when using certain types of computer instructions.) 8. A0F7 = C006 = ( C006) = A0F ( C006) E0F (a) 7A = = (b) 7B = ( 7B) = (7A) = ( 7B) =

24 24 Comment The answers are identical. Note, however, that in (a) we are using unsigned, eight bit numbers, whilst in (b) signed numbers are being used. Hence in converting (a) back to denary we would read it as +255 whereas (b) represents The table below shows the effect of shifting an 8 bit binary number to the left. The effect is to double the number. A right shift will halve the number. This is an obvious consequence of positional notation (1) (2) (4) (8) (16) (32) (64) (128) A microprocessor will have instructions that permit us to shift left or shift right which are useful in, for example, binary multiplication. Note, however, that if we were using signed numbers then we would have to be careful. For instance, the last result of the above table would then be negative!

25 25 SUMMARY (a) The rules of binary addition are: carry 1 to left hand column (b) The rules of binary subtraction are: borrow 1 from left hand column (c) Two common ways of representing negative numbers are: (i) Sign-magnitude method when the MSB gives the sign of the number and the remaining bits the magnitude. (ii) Two s complement method obtained by inverting the number and adding 1 to the result. In the next lesson we consider some simple hardware which can be used to perform simple operations on binary data.

ENGIN 112 Intro to Electrical and Computer Engineering

ENGIN 112 Intro to Electrical and Computer Engineering ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems Overview Hexadecimal numbers Related to binary and octal numbers Conversion between hexadecimal, octal and binary Value

More information

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary. Numbering Systems Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary. Addition & Subtraction using Octal & Hexadecimal 2 s Complement, Subtraction Using 2 s Complement.

More information

Chapter 1 CSCI

Chapter 1 CSCI Chapter 1 CSCI-1510-003 What is a Number? An expression of a numerical quantity A mathematical quantity Many types: Natural Numbers Real Numbers Rational Numbers Irrational Numbers Complex Numbers Etc.

More information

CHAPTER 2 NUMBER SYSTEMS

CHAPTER 2 NUMBER SYSTEMS CHAPTER 2 NUMBER SYSTEMS The Decimal Number System : We begin our study of the number systems with the familiar decimal number system. The decimal system contains ten unique symbol 0, 1, 2, 3, 4, 5, 6,

More information

CprE 281: Digital Logic

CprE 281: Digital Logic CprE 281: Digital Logic Instructor: Alexander Stoytchev http://www.ece.iastate.edu/~alexs/classes/ Signed Numbers CprE 281: Digital Logic Iowa State University, Ames, IA Copyright Alexander Stoytchev Administrative

More information

EE260: Digital Design, Spring n Digital Computers. n Number Systems. n Representations. n Conversions. n Arithmetic Operations.

EE260: Digital Design, Spring n Digital Computers. n Number Systems. n Representations. n Conversions. n Arithmetic Operations. EE 260: Introduction to Digital Design Number Systems Yao Zheng Department of Electrical Engineering University of Hawaiʻi at Mānoa Overview n Digital Computers n Number Systems n Representations n Conversions

More information

hexadecimal-to-decimal conversion

hexadecimal-to-decimal conversion OTHER NUMBER SYSTEMS: octal (digits 0 to 7) group three binary numbers together and represent as base 8 3564 10 = 110 111 101 100 2 = (6X8 3 ) + (7X8 2 ) + (5X8 1 ) + (4X8 0 ) = 6754 8 hexadecimal (digits

More information

Hakim Weatherspoon CS 3410 Computer Science Cornell University

Hakim Weatherspoon CS 3410 Computer Science Cornell University Hakim Weatherspoon CS 3410 Computer Science Cornell University The slides are the product of many rounds of teaching CS 3410 by Professors Weatherspoon, Bala, Bracy, and Sirer. memory inst 32 register

More information

14:332:231 DIGITAL LOGIC DESIGN. Why Binary Number System?

14:332:231 DIGITAL LOGIC DESIGN. Why Binary Number System? :33:3 DIGITAL LOGIC DESIGN Ivan Marsic, Rutgers University Electrical & Computer Engineering Fall 3 Lecture #: Binary Number System Complement Number Representation X Y Why Binary Number System? Because

More information

Introduction to Digital Logic Missouri S&T University CPE 2210 Subtractors

Introduction to Digital Logic Missouri S&T University CPE 2210 Subtractors Introduction to Digital Logic Missouri S&T University CPE 2210 Egemen K. Çetinkaya Egemen K. Çetinkaya Department of Electrical & Computer Engineering Missouri University of Science and Technology cetinkayae@mst.edu

More information

Binary addition example worked out

Binary addition example worked out Binary addition example worked out Some terms are given here Exercise: what are these numbers equivalent to in decimal? The initial carry in is implicitly 0 1 1 1 0 (Carries) 1 0 1 1 (Augend) + 1 1 1 0

More information

Conversions between Decimal and Binary

Conversions between Decimal and Binary Conversions between Decimal and Binary Binary to Decimal Technique - use the definition of a number in a positional number system with base 2 - evaluate the definition formula ( the formula ) using decimal

More information

COMBINATIONAL LOGIC FUNCTIONS

COMBINATIONAL LOGIC FUNCTIONS COMBINATIONAL LOGIC FUNCTIONS Digital logic circuits can be classified as either combinational or sequential circuits. A combinational circuit is one where the output at any time depends only on the present

More information

Chapter 5 Arithmetic Circuits

Chapter 5 Arithmetic Circuits Chapter 5 Arithmetic Circuits SKEE2263 Digital Systems Mun im/ismahani/izam {munim@utm.my,e-izam@utm.my,ismahani@fke.utm.my} February 11, 2016 Table of Contents 1 Iterative Designs 2 Adders 3 High-Speed

More information

Combinational Logic Design Arithmetic Functions and Circuits

Combinational Logic Design Arithmetic Functions and Circuits Combinational Logic Design Arithmetic Functions and Circuits Overview Binary Addition Half Adder Full Adder Ripple Carry Adder Carry Look-ahead Adder Binary Subtraction Binary Subtractor Binary Adder-Subtractor

More information

Digital Systems Roberto Muscedere Images 2013 Pearson Education Inc. 1

Digital Systems Roberto Muscedere Images 2013 Pearson Education Inc. 1 Digital Systems Digital systems have such a prominent role in everyday life The digital age The technology around us is ubiquitous, that is we don t even notice it anymore Digital systems are used in:

More information

UNSIGNED BINARY NUMBERS DIGITAL ELECTRONICS SYSTEM DESIGN WHAT ABOUT NEGATIVE NUMBERS? BINARY ADDITION 11/9/2018

UNSIGNED BINARY NUMBERS DIGITAL ELECTRONICS SYSTEM DESIGN WHAT ABOUT NEGATIVE NUMBERS? BINARY ADDITION 11/9/2018 DIGITAL ELECTRONICS SYSTEM DESIGN LL 2018 PROFS. IRIS BAHAR & ROD BERESFORD NOVEMBER 9, 2018 LECTURE 19: BINARY ADDITION, UNSIGNED BINARY NUMBERS For the binary number b n-1 b n-2 b 1 b 0. b -1 b -2 b

More information

Combinational Logic. By : Ali Mustafa

Combinational Logic. By : Ali Mustafa Combinational Logic By : Ali Mustafa Contents Adder Subtractor Multiplier Comparator Decoder Encoder Multiplexer How to Analyze any combinational circuit like this? Analysis Procedure To obtain the output

More information

Design of Digital Circuits Reading: Binary Numbers. Required Reading for Week February 2017 Spring 2017

Design of Digital Circuits Reading: Binary Numbers. Required Reading for Week February 2017 Spring 2017 Design of Digital Circuits Reading: Binary Numbers Required Reading for Week 1 23-24 February 2017 Spring 2017 Binary Numbers Design of Digital Circuits 2016 Srdjan Capkun Frank K. Gürkaynak http://www.syssec.ethz.ch/education/digitaltechnik_16

More information

THE LOGIC OF COMPOUND STATEMENTS

THE LOGIC OF COMPOUND STATEMENTS CHAPTER 2 THE LOGIC OF COMPOUND STATEMENTS Copyright Cengage Learning. All rights reserved. SECTION 2.4 Application: Digital Logic Circuits Copyright Cengage Learning. All rights reserved. Application:

More information

ECE380 Digital Logic. Positional representation

ECE380 Digital Logic. Positional representation ECE380 Digital Logic Number Representation and Arithmetic Circuits: Number Representation and Unsigned Addition Dr. D. J. Jackson Lecture 16-1 Positional representation First consider integers Begin with

More information

Binary addition (1-bit) P Q Y = P + Q Comments Carry = Carry = Carry = Carry = 1 P Q

Binary addition (1-bit) P Q Y = P + Q Comments Carry = Carry = Carry = Carry = 1 P Q Digital Arithmetic In Chapter 2, we have discussed number systems such as binary, hexadecimal, decimal, and octal. We have also discussed sign representation techniques, for example, sign-bit representation

More information

Chapter 2 Combinational Logic Circuits

Chapter 2 Combinational Logic Circuits Logic and Computer Design Fundamentals Chapter 2 Combinational Logic Circuits Part 2 Circuit Optimization Goal: To obtain the simplest implementation for a given function Optimization is a more formal

More information

ECE 250 / CPS 250 Computer Architecture. Basics of Logic Design Boolean Algebra, Logic Gates

ECE 250 / CPS 250 Computer Architecture. Basics of Logic Design Boolean Algebra, Logic Gates ECE 250 / CPS 250 Computer Architecture Basics of Logic Design Boolean Algebra, Logic Gates Benjamin Lee Slides based on those from Andrew Hilton (Duke), Alvy Lebeck (Duke) Benjamin Lee (Duke), and Amir

More information

Numbers and Arithmetic

Numbers and Arithmetic Numbers and Arithmetic See: P&H Chapter 2.4 2.6, 3.2, C.5 C.6 Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University Big Picture: Building a Processor memory inst register file alu

More information

Carry Look Ahead Adders

Carry Look Ahead Adders Carry Look Ahead Adders Lesson Objectives: The objectives of this lesson are to learn about: 1. Carry Look Ahead Adder circuit. 2. Binary Parallel Adder/Subtractor circuit. 3. BCD adder circuit. 4. Binary

More information

Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Lecture 02 Groups: Subgroups and homomorphism (Refer Slide Time: 00:13) We looked

More information

Logic. Combinational. inputs. outputs. the result. system can

Logic. Combinational. inputs. outputs. the result. system can Digital Electronics Combinational Logic Functions Digital logic circuits can be classified as either combinational or sequential circuits. A combinational circuit is one where the output at any time depends

More information

Logic and Computer Design Fundamentals. Chapter 5 Arithmetic Functions and Circuits

Logic and Computer Design Fundamentals. Chapter 5 Arithmetic Functions and Circuits Logic and Computer Design Fundamentals Chapter 5 Arithmetic Functions and Circuits Arithmetic functions Operate on binary vectors Use the same subfunction in each bit position Can design functional block

More information

of Digital Electronics

of Digital Electronics 26 Digital Electronics 729 Digital Electronics 26.1 Analog and Digital Signals 26.3 Binary Number System 26.5 Decimal to Binary Conversion 26.7 Octal Number System 26.9 Binary-Coded Decimal Code (BCD Code)

More information

Fundamentals of Digital Design

Fundamentals of Digital Design Fundamentals of Digital Design Digital Radiation Measurement and Spectroscopy NE/RHP 537 1 Binary Number System The binary numeral system, or base-2 number system, is a numeral system that represents numeric

More information

Binary Multipliers. Reading: Study Chapter 3. The key trick of multiplication is memorizing a digit-to-digit table Everything else was just adding

Binary Multipliers. Reading: Study Chapter 3. The key trick of multiplication is memorizing a digit-to-digit table Everything else was just adding Binary Multipliers The key trick of multiplication is memorizing a digit-to-digit table Everything else was just adding 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 2 2 4 6 8 2 4 6 8 3 3 6 9 2 5 8 2 24 27 4 4 8 2 6

More information

CPE100: Digital Logic Design I

CPE100: Digital Logic Design I Chapter 1 Professor Brendan Morris, SEB 3216, brendan.morris@unlv.edu http://www.ee.unlv.edu/~b1morris/cpe100/ CPE100: Digital Logic Design I Section 1004: Dr. Morris From Zero to One Chapter 1 Background:

More information

Digital Techniques. Figure 1: Block diagram of digital computer. Processor or Arithmetic logic unit ALU. Control Unit. Storage or memory unit

Digital Techniques. Figure 1: Block diagram of digital computer. Processor or Arithmetic logic unit ALU. Control Unit. Storage or memory unit Digital Techniques 1. Binary System The digital computer is the best example of a digital system. A main characteristic of digital system is its ability to manipulate discrete elements of information.

More information

ECE/CS 250 Computer Architecture

ECE/CS 250 Computer Architecture ECE/CS 250 Computer Architecture Basics of Logic Design: Boolean Algebra, Logic Gates (Combinational Logic) Tyler Bletsch Duke University Slides are derived from work by Daniel J. Sorin (Duke), Alvy Lebeck

More information

Numbers & Arithmetic. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. See: P&H Chapter , 3.2, C.5 C.

Numbers & Arithmetic. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. See: P&H Chapter , 3.2, C.5 C. Numbers & Arithmetic Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See: P&H Chapter 2.4-2.6, 3.2, C.5 C.6 Example: Big Picture Computer System Organization and Programming

More information

Chapter 03: Computer Arithmetic. Lesson 03: Arithmetic Operations Adder and Subtractor circuits Design

Chapter 03: Computer Arithmetic. Lesson 03: Arithmetic Operations Adder and Subtractor circuits Design Chapter 03: Computer Arithmetic Lesson 03: Arithmetic Operations Adder and Subtractor circuits Design Objective To understand adder circuit Subtractor circuit Fast adder circuit 2 Adder Circuit 3 Full

More information

Digital Systems Overview. Unit 1 Numbering Systems. Why Digital Systems? Levels of Design Abstraction. Dissecting Decimal Numbers

Digital Systems Overview. Unit 1 Numbering Systems. Why Digital Systems? Levels of Design Abstraction. Dissecting Decimal Numbers Unit Numbering Systems Fundamentals of Logic Design EE2369 Prof. Eric MacDonald Fall Semester 2003 Digital Systems Overview Digital Systems are Home PC XBOX or Playstation2 Cell phone Network router Data

More information

Numbers and Arithmetic

Numbers and Arithmetic Numbers and Arithmetic See: P&H Chapter 2.4 2.6, 3.2, C.5 C.6 Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University Big Picture: Building a Processor memory inst register file alu

More information

Design of Sequential Circuits

Design of Sequential Circuits Design of Sequential Circuits Seven Steps: Construct a state diagram (showing contents of flip flop and inputs with next state) Assign letter variables to each flip flop and each input and output variable

More information

E40M. Binary Numbers. M. Horowitz, J. Plummer, R. Howe 1

E40M. Binary Numbers. M. Horowitz, J. Plummer, R. Howe 1 E40M Binary Numbers M. Horowitz, J. Plummer, R. Howe 1 Reading Chapter 5 in the reader A&L 5.6 M. Horowitz, J. Plummer, R. Howe 2 Useless Box Lab Project #2 Adding a computer to the Useless Box alows us

More information

Four Important Number Systems

Four Important Number Systems Four Important Number Systems System Why? Remarks Decimal Base 10: (10 fingers) Most used system Binary Base 2: On/Off systems 3-4 times more digits than decimal Octal Base 8: Shorthand notation for working

More information

UNIT II COMBINATIONAL CIRCUITS:

UNIT II COMBINATIONAL CIRCUITS: UNIT II COMBINATIONAL CIRCUITS: INTRODUCTION: The digital system consists of two types of circuits, namely (i) (ii) Combinational circuits Sequential circuits Combinational circuit consists of logic gates

More information

Menu. Review of Number Systems EEL3701 EEL3701. Math. Review of number systems >Binary math >Signed number systems

Menu. Review of Number Systems EEL3701 EEL3701. Math. Review of number systems >Binary math >Signed number systems Menu Review of number systems >Binary math >Signed number systems Look into my... 1 Our decimal (base 10 or radix 10) number system is positional. Ex: 9437 10 = 9x10 3 + 4x10 2 + 3x10 1 + 7x10 0 We have

More information

Unit II Chapter 4:- Digital Logic Contents 4.1 Introduction... 4

Unit II Chapter 4:- Digital Logic Contents 4.1 Introduction... 4 Unit II Chapter 4:- Digital Logic Contents 4.1 Introduction... 4 4.1.1 Signal... 4 4.1.2 Comparison of Analog and Digital Signal... 7 4.2 Number Systems... 7 4.2.1 Decimal Number System... 7 4.2.2 Binary

More information

CMP 334: Seventh Class

CMP 334: Seventh Class CMP 334: Seventh Class Performance HW 5 solution Averages and weighted averages (review) Amdahl's law Ripple-carry adder circuits Binary addition Half-adder circuits Full-adder circuits Subtraction, negative

More information

Systems I: Computer Organization and Architecture

Systems I: Computer Organization and Architecture Systems I: Computer Organization and Architecture Lecture 6 - Combinational Logic Introduction A combinational circuit consists of input variables, logic gates, and output variables. The logic gates accept

More information

Week No. 06: Numbering Systems

Week No. 06: Numbering Systems Week No. 06: Numbering Systems Numbering System: A numbering system defined as A set of values used to represent quantity. OR A number system is a term used for a set of different symbols or digits, which

More information

CSE 241 Digital Systems Spring 2013

CSE 241 Digital Systems Spring 2013 CSE 241 Digital Systems Spring 2013 Instructor: Prof. Kui Ren Department of Computer Science and Engineering Lecture slides modified from many online resources and used solely for the educational purpose.

More information

Why digital? Overview. Number Systems. Binary to Decimal conversion

Why digital? Overview. Number Systems. Binary to Decimal conversion Why digital? Overview It has the following advantages over analog. It can be processed and transmitted efficiently and reliably. It can be stored and retrieved with greater accuracy. Noise level does not

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering Data Representation & 2 s Complement James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy Data

More information

Module 2. Basic Digital Building Blocks. Binary Arithmetic & Arithmetic Circuits Comparators, Decoders, Encoders, Multiplexors Flip-Flops

Module 2. Basic Digital Building Blocks. Binary Arithmetic & Arithmetic Circuits Comparators, Decoders, Encoders, Multiplexors Flip-Flops Module 2 asic Digital uilding locks Lecturer: Dr. Yongsheng Gao Office: Tech 3.25 Email: Web: Structure: Textbook: yongsheng.gao@griffith.edu.au maxwell.me.gu.edu.au 6 lecturers 1 tutorial 1 laboratory

More information

Building a Computer Adder

Building a Computer Adder Logic Gates are used to translate Boolean logic into circuits. In the abstract it is clear that we can build AND gates that perform the AND function and OR gates that perform the OR function and so on.

More information

CHAPTER 12 Boolean Algebra

CHAPTER 12 Boolean Algebra 318 Chapter 12 Boolean Algebra CHAPTER 12 Boolean Algebra SECTION 12.1 Boolean Functions 2. a) Since x 1 = x, the only solution is x = 0. b) Since 0 + 0 = 0 and 1 + 1 = 1, the only solution is x = 0. c)

More information

CS 140 Lecture 14 Standard Combinational Modules

CS 140 Lecture 14 Standard Combinational Modules CS 14 Lecture 14 Standard Combinational Modules Professor CK Cheng CSE Dept. UC San Diego Some slides from Harris and Harris 1 Part III. Standard Modules A. Interconnect B. Operators. Adders Multiplier

More information

The goal differs from prime factorization. Prime factorization would initialize all divisors to be prime numbers instead of integers*

The goal differs from prime factorization. Prime factorization would initialize all divisors to be prime numbers instead of integers* Quantum Algorithm Processor For Finding Exact Divisors Professor J R Burger Summary Wiring diagrams are given for a quantum algorithm processor in CMOS to compute, in parallel, all divisors of an n-bit

More information

Chapter 1: Logic systems

Chapter 1: Logic systems Chapter 1: Logic systems 1: Logic gates Learning Objectives: At the end of this topic you should be able to: identify the symbols and truth tables for the following logic gates: NOT AND NAND OR NOR XOR

More information

Computer organization

Computer organization Computer organization Levels of abstraction Assembler Simulator Applications C C++ Java High-level language SOFTWARE add lw ori Assembly language Goal 0000 0001 0000 1001 0101 Machine instructions/data

More information

ALU (3) - Division Algorithms

ALU (3) - Division Algorithms HUMBOLDT-UNIVERSITÄT ZU BERLIN INSTITUT FÜR INFORMATIK Lecture 12 ALU (3) - Division Algorithms Sommersemester 2002 Leitung: Prof. Dr. Miroslaw Malek www.informatik.hu-berlin.de/rok/ca CA - XII - ALU(3)

More information

Adders - Subtractors

Adders - Subtractors Adders - Subtractors Lesson Objectives: The objectives of this lesson are to learn about: 1. Half adder circuit. 2. Full adder circuit. 3. Binary parallel adder circuit. 4. Half subtractor circuit. 5.

More information

14:332:231 DIGITAL LOGIC DESIGN. 2 s-complement Representation

14:332:231 DIGITAL LOGIC DESIGN. 2 s-complement Representation 4:332:23 DIGITAL LOGIC DESIGN Ivan Marsic, Rutgers University Electrical & Computer Engineering Fall 203 Lecture #3: Addition, Subtraction, Multiplication, and Division 2 s-complement Representation RECALL

More information

Chapter 5. Digital systems. 5.1 Boolean algebra Negation, conjunction and disjunction

Chapter 5. Digital systems. 5.1 Boolean algebra Negation, conjunction and disjunction Chapter 5 igital systems digital system is any machine that processes information encoded in the form of digits. Modern digital systems use binary digits, encoded as voltage levels. Two voltage levels,

More information

STEP Support Programme. Hints and Partial Solutions for Assignment 17

STEP Support Programme. Hints and Partial Solutions for Assignment 17 STEP Support Programme Hints and Partial Solutions for Assignment 7 Warm-up You need to be quite careful with these proofs to ensure that you are not assuming something that should not be assumed. For

More information

We say that the base of the decimal number system is ten, represented by the symbol

We say that the base of the decimal number system is ten, represented by the symbol Introduction to counting and positional notation. In the decimal number system, a typical number, N, looks like... d 3 d 2 d 1 d 0.d -1 d -2 d -3... [N1] where the ellipsis at each end indicates that there

More information

What s the Deal? MULTIPLICATION. Time to multiply

What s the Deal? MULTIPLICATION. Time to multiply What s the Deal? MULTIPLICATION Time to multiply Multiplying two numbers requires a multiply Luckily, in binary that s just an AND gate! 0*0=0, 0*1=0, 1*0=0, 1*1=1 Generate a bunch of partial products

More information

3. Complete the following table of equivalent values. Use binary numbers with a sign bit and 7 bits for the value

3. Complete the following table of equivalent values. Use binary numbers with a sign bit and 7 bits for the value EGC22 Digital Logic Fundamental Additional Practice Problems. Complete the following table of equivalent values. Binary. Octal 35.77 33.23.875 29.99 27 9 64 Hexadecimal B.3 D.FD B.4C 2. Calculate the following

More information

ENG2410 Digital Design Introduction to Digital Systems. Fall 2017 S. Areibi School of Engineering University of Guelph

ENG2410 Digital Design Introduction to Digital Systems. Fall 2017 S. Areibi School of Engineering University of Guelph ENG2410 Digital Design Introduction to Digital Systems Fall 2017 S. Areibi School of Engineering University of Guelph Resources Chapter #1, Mano Sections 1.1 Digital Computers 1.2 Number Systems 1.3 Arithmetic

More information

ECE 372 Microcontroller Design

ECE 372 Microcontroller Design Data Formats Humor There are 10 types of people in the world: Those who get binary and those who don t. 1 Information vs. Data Information An abstract description of facts, processes or perceptions How

More information

CprE 281: Digital Logic

CprE 281: Digital Logic CprE 281: Digital Logic Instructor: Alexander Stoytchev http://www.ece.iastate.edu/~alexs/classes/ Fast Adders CprE 281: Digital Logic Iowa State University, Ames, IA Copyright Alexander Stoytchev HW5

More information

Lecture 5: Arithmetic

Lecture 5: Arithmetic Lecture 5: Arithmetic COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David August 1 5 Binary Representation of Integers Two physical states: call these 1 and

More information

XOR - XNOR Gates. The graphic symbol and truth table of XOR gate is shown in the figure.

XOR - XNOR Gates. The graphic symbol and truth table of XOR gate is shown in the figure. XOR - XNOR Gates Lesson Objectives: In addition to AND, OR, NOT, NAND and NOR gates, exclusive-or (XOR) and exclusive-nor (XNOR) gates are also used in the design of digital circuits. These have special

More information

Ex code

Ex code Ex. 8.4 7-4-2-1 code Codeconverter 7-4-2-1-code to BCD-code. When encoding the digits 0... 9 sometimes in the past a code having weights 7-4-2-1 instead of the binary code weights 8-4-2-1 was used. In

More information

CprE 281: Digital Logic

CprE 281: Digital Logic CprE 28: Digital Logic Instructor: Alexander Stoytchev http://www.ece.iastate.edu/~alexs/classes/ Simple Processor CprE 28: Digital Logic Iowa State University, Ames, IA Copyright Alexander Stoytchev Digital

More information

Lecture 2 Review on Digital Logic (Part 1)

Lecture 2 Review on Digital Logic (Part 1) Lecture 2 Review on Digital Logic (Part 1) Xuan Silvia Zhang Washington University in St. Louis http://classes.engineering.wustl.edu/ese461/ Grading Engagement 5% Review Quiz 10% Homework 10% Labs 40%

More information

Lecture 8: Sequential Multipliers

Lecture 8: Sequential Multipliers Lecture 8: Sequential Multipliers ECE 645 Computer Arithmetic 3/25/08 ECE 645 Computer Arithmetic Lecture Roadmap Sequential Multipliers Unsigned Signed Radix-2 Booth Recoding High-Radix Multiplication

More information

Computer Architecture. ESE 345 Computer Architecture. Design Process. CA: Design process

Computer Architecture. ESE 345 Computer Architecture. Design Process. CA: Design process Computer Architecture ESE 345 Computer Architecture Design Process 1 The Design Process "To Design Is To Represent" Design activity yields description/representation of an object -- Traditional craftsman

More information

Physics 310 Lecture 10 Microprocessors

Physics 310 Lecture 10 Microprocessors Mon. 3/29 Wed. 3/31 Thurs. 4/1 Fri. 4/2 Mon. 4/5 Wed. 4/7 Thurs. 4/8 Fri. 4/9 Mon. 4/12 Wed. 4/14 Thurs. 4/15 Fri. 4/16 Project: Component Shopping Ch 13: Microprocessor Basics Intro to More Ch 13 Review

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Digital Logic

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Digital Logic Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Digital Logic Our goal for the next few weeks is to paint a a reasonably complete picture of how we can go from transistor

More information

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

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors CSC258 Week 3 1 Logistics If you cannot login to MarkUs, email me your UTORID and name. Check lab marks on MarkUs, if it s recorded wrong, contact Larry within a week after the lab. Quiz 1 average: 86%

More information

Chapter 1 :: From Zero to One

Chapter 1 :: From Zero to One Chapter 1 :: From Zero to One Digital Design and Computer Architecture David Money Harris and Sarah L. Harris Copyright 2007 Elsevier 1- Chapter 1 :: Topics Background The Game Plan The Art of Managing

More information

ELCT201: DIGITAL LOGIC DESIGN

ELCT201: DIGITAL LOGIC DESIGN ELCT2: DIGITAL LOGIC DESIGN Dr. Eng. Haitham Omran, haitham.omran@guc.edu.eg Dr. Eng. Wassim Alexan, wassim.joseph@guc.edu.eg Lecture 4 Following the slides of Dr. Ahmed H. Madian محرم 439 ه Winter 28

More information

Binary addition by hand. Adding two bits

Binary addition by hand. Adding two bits Chapter 3 Arithmetic is the most basic thing you can do with a computer We focus on addition, subtraction, multiplication and arithmetic-logic units, or ALUs, which are the heart of CPUs. ALU design Bit

More information

Introduction to Digital Logic

Introduction to Digital Logic Introduction to Digital Logic Lecture 15: Comparators EXERCISES Mark Redekopp, All rights reserved Adding Many Bits You know that an FA adds X + Y + Ci Use FA and/or HA components to add 4 individual bits:

More information

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute DIGITAL TECHNICS Dr. Bálint Pődör Óbuda University, Microelectronics and Technology Institute 4. LECTURE: COMBINATIONAL LOGIC DESIGN: ARITHMETICS (THROUGH EXAMPLES) 2016/2017 COMBINATIONAL LOGIC DESIGN:

More information

CSCI 255. S i g n e d N u m s / S h i f t i n g / A r i t h m e t i c O p s.

CSCI 255. S i g n e d N u m s / S h i f t i n g / A r i t h m e t i c O p s. Ying.Yang 1.-1 CSCI 255 http://cs.furman.edu In mathematics, negative integers exists -> forced to do it binary In a binary string, the MSB is sacrificed as the signed bit 0 => Positive Value 1 => Negative

More information

SAU1A FUNDAMENTALS OF DIGITAL COMPUTERS

SAU1A FUNDAMENTALS OF DIGITAL COMPUTERS SAU1A FUNDAMENTALS OF DIGITAL COMPUTERS Unit : I - V Unit : I Overview Fundamentals of Computers Characteristics of Computers Computer Language Operating Systems Generation of Computers 2 Definition of

More information

Representing signed numbers in Two s Complement notation

Representing signed numbers in Two s Complement notation EE457 Representing signed numbers in Two s Complement notation A way to view the signed number representation in 2 s complement notation as a positional weighted coefficient system. example ( 2) = (6 4

More information

Chapter 2 Combinational Logic Circuits

Chapter 2 Combinational Logic Circuits Logic and Computer Design Fundamentals Chapter 2 Combinational Logic Circuits Part 2 Circuit Optimization Charles Kime & Thomas Kaminski 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active

More information

Total Time = 90 Minutes, Total Marks = 100. Total /10 /25 /20 /10 /15 /20

Total Time = 90 Minutes, Total Marks = 100. Total /10 /25 /20 /10 /15 /20 University of Waterloo Department of Electrical & Computer Engineering E&CE 223 Digital Circuits and Systems Midterm Examination Instructor: M. Sachdev October 30th, 2006 Total Time = 90 Minutes, Total

More information

Logic Theory in Designing of Digital Circuit & Microprocessor

Logic Theory in Designing of Digital Circuit & Microprocessor Logic Theory in Designing of Digital Circuit & Microprocessor Prof.Vikram Mahendra Kakade Assistant Professor, Electronics & Telecommunication Engineering Department, Prof Ram Meghe College of Engineering

More information

EECS150 - Digital Design Lecture 24 - Arithmetic Blocks, Part 2 + Shifters

EECS150 - Digital Design Lecture 24 - Arithmetic Blocks, Part 2 + Shifters EECS150 - Digital Design Lecture 24 - Arithmetic Blocks, Part 2 + Shifters April 15, 2010 John Wawrzynek 1 Multiplication a 3 a 2 a 1 a 0 Multiplicand b 3 b 2 b 1 b 0 Multiplier X a 3 b 0 a 2 b 0 a 1 b

More information

Save from: cs. Logic design 1 st Class أستاذ المادة: د. عماد

Save from:   cs. Logic design 1 st Class أستاذ المادة: د. عماد Save from: www.uotiq.org/dep cs Logic design 1 st Class أستاذ المادة: د. عماد استاذة المادة: م.م ميساء Contents Lectured One: Number system operation 1- Decimal numbers. 2- Binary numbers. 3- Octal numbers.

More information

CSC9R6 Computer Design. Practical Digital Logic

CSC9R6 Computer Design. Practical Digital Logic CSC9R6 Computer Design Practical Digital Logic 1 References (for this part of CSC9R6) Hamacher et al: Computer Organization App A. In library Floyd: Digital Fundamentals Ch 1, 3-6, 8-10 web page: www.prenhall.com/floyd/

More information

Number System conversions

Number System conversions Number System conversions Number Systems The system used to count discrete units is called number system. There are four systems of arithmetic which are often used in digital electronics. Decimal Number

More information

Part 1: Digital Logic and Gates. Analog vs. Digital waveforms. The digital advantage. In real life...

Part 1: Digital Logic and Gates. Analog vs. Digital waveforms. The digital advantage. In real life... Part 1: Digital Logic and Gates Analog vs Digital waveforms An analog signal assumes a continuous range of values: v(t) ANALOG A digital signal assumes discrete (isolated, separate) values Usually there

More information

Department of Electrical & Electronics EE-333 DIGITAL SYSTEMS

Department of Electrical & Electronics EE-333 DIGITAL SYSTEMS Department of Electrical & Electronics EE-333 DIGITAL SYSTEMS 1) Given the two binary numbers X = 1010100 and Y = 1000011, perform the subtraction (a) X -Y and (b) Y - X using 2's complements. a) X = 1010100

More information

Data Converter Fundamentals

Data Converter Fundamentals Data Converter Fundamentals David Johns and Ken Martin (johns@eecg.toronto.edu) (martin@eecg.toronto.edu) slide 1 of 33 Introduction Two main types of converters Nyquist-Rate Converters Generate output

More information

DSP Design Lecture 2. Fredrik Edman.

DSP Design Lecture 2. Fredrik Edman. DSP Design Lecture Number representation, scaling, quantization and round-off Noise Fredrik Edman fredrik.edman@eit.lth.se Representation of Numbers Numbers is a way to use symbols to describe and model

More information

Binary logic consists of binary variables and logical operations. The variables are

Binary logic consists of binary variables and logical operations. The variables are 1) Define binary logic? Binary logic consists of binary variables and logical operations. The variables are designated by the alphabets such as A, B, C, x, y, z, etc., with each variable having only two

More information