Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO

Slides:



Advertisements
Similar presentations
A digital system is a system that manipulates discrete elements of information represented internally in binary form. Digital computers –general purposes.
Advertisements

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition.
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Digital Circuits. Analog and Digital Signals Noise margins in Logic Circuits VMVM.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 1 Overflow Signed binary is in fixed range -2 n-1  2 n-1 If the answer for addition/subtraction more than the.
Number System and Codes
Information Representation and Number Systems BIL- 223 Logic Circuit Design Ege University Department of Computer Engineering.
Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.
Mantıksal Tasarım – BBM231 M. Önder Efe
Operations on data CHAPTER 4.
3. Representing Integer Data
1.6 Signed Binary Numbers.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Digital Systems and Binary Numbers
Computers Organization & Assembly Language
Digital Systems and Logic Design
Representing Integer Data Book : Chapter ( Subject has no point !! ) A99ACF.
Logic and Digital System Design - CS 303
Binary Arithmetic & Data representation
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,
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 2 Number.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
Yuh-Jzer JoungDigital Systems1 Number Systems decimal number : 7397=7× × × ×10 0 a 4 a 3 a 2 a 1 a 0. a -1 a -2 = a 4 ×10 4 +a 3 ×10.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Number systems & Binary codes MODULE 1 Digital Logic Design Ch1-2 Outline of Chapter 1  1.1 Digital Systems  1.2 Binary Numbers  1.3 Number-base Conversions.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
CE1111 :Digital Logic Design lecture 01 Introduction Dr. Atef Ali Ibrahim.
Number Systems and Codes. CS2100 Number Systems and Codes 2 NUMBER SYSTEMS & CODES Information Representations Number Systems Base Conversion Negative.
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
1 Lecture 3 ENGRE 254 1/14/09. 2 Lecture 1 review Digital signals assume two values represented by “0” and “1”. Typically a “0” represents a voltage near.
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
Digital Circuits Text Book –M. M. Mano, "Digital Design," 3rd Ed., Prentice Hall Inc., Reference –class notes Grade –quizzes:15% –mid-term:27.5%
Chapter 1 Digital Systems and Binary Numbers
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Chapter 1: Binary Systems
IT1004: Data Representation and Organization Negative number representation.
Lecture 2 Number Representation, Overflow and Logic Topics Adders Math Behind Excess-3 Overflow Unsigned, signed-magnitude Two’s Complement Gray Code Boolean.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
ECE DIGITAL LOGIC LECTURE 4: BINARY CODES Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/26/2016.
Digital Logic Design Lab 1,2 By Nora Alaqeel.
Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy
BINARY SYSTEMS ENGR. KASHIF SHAHZAD 1. BINARY NUMBERS 1/2 Internally, information in digital systems is of binary form groups of bits (i.e. binary numbers)
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Digital Logic Design Ch1-1 Chapter 1 Digital Systems and Binary Numbers Mustafa Kemal Uyguroğlu Digital Logic Design I.
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.
N 3-1 Data Types  Binary information is stored in memory or processor registers  Registers contain either data or control information l Data are numbers.
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Chapter 1 Digital Systems and Binary Numbers
Digital Systems and Binary Numbers
Chapter 1 Digital Systems and Binary Numbers
University of Gujrat Department of Computer Science
Data Representation Data Types Complements Fixed Point Representation
ECE 331 – Digital System Design
Chapter 1 (Part c) Digital Systems and Binary Numbers
Presentation transcript:

Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO Email: dahmed@site.uottawa.ca

Binary Numbers Base (or radix) Number base conversion Complements 2 example: 0110 Number base conversion example: 41 = 101001 Complements 1's complements ( 2n- 1 ) - N 2's complements 2n - N Subtraction = addition with the 2's complement Signed binary numbers signed-magnitude, 10001001 signed 1's complement, 11110110 signed 2's complement. 11110111

Binary Number System Base = 2 2 Digits: 0, 1 Examples: = 8 + 1 = 9  1010 1101b = 1 * 27 + 1 * 25 + 1 * 23 + 1 * 22 + 1 = 128 + 32 + 8 + 4 + 1 = 173 Note: it is common to put binary digits in groups of 4 to make it easier to read them.

Ranges for Data Formats No. of bits Binary BCD 1 0 – 1 2 0 – 3 3 0 – 7 4 0 – 15 0 – 9 7 0 – 127 8 0 – 255 0 – 99 16 0 - 65,535 0 – 9999 24 0 – 16,777,215 0 – 999999

In General (binary) No. of bits Binary Min Max n 2n – 1

Signed Integers “unsigned integers” = positive values only Must also have a mechanism to represent “signed integers” (positive and negative values!) -1010 = ?2 Two common schemes: sign-magnitude and twos complement

Sign-Magnitude Extra bit on left to represent sign 0 = positive value 1 = negative value 6-bit sign-magnitude representation of +5 and –5: +5: 0 0 0 1 0 1 +ve 5 -5: 1 0 0 1 0 1 -ve 5

Ranges (revisited) No. of bits Binary Unsigned Sign-magnitude Min Max 1 2 3 -1 7 -3 4 15 -7 5 31 -15 6 63 -31

In General … No. of bits Binary Unsigned Sign-magnitude Min Max n 2n - 1 -(2n-1 - 1) 2n-1 - 1

Difficulties with Sign-Magnitude Two representations of zero Using 6-bit sign-magnitude… 0: 000000 0: 100000 Arithmetic is awkward!

Complementary Representations 1’s complement 2’s complement 9’s complement 10’s complement

Complementary Notations What is the 3-digit 10’s complement of 207? Answer: What is the 4-digit 10’s complement of 15? 111 is a 10’s complement representation of what decimal value?

Exercises – Complementary Notations What is the 3-digit 10’s complement of 207? Answer: 793 What is the 4-digit 10’s complement of 15? Answer: 9985 111 is a 10’s complement representation of what decimal value? Answer: 889

2’s Complement Most common scheme of representing negative numbers natural arithmetic - no special rules! Rule to represent a negative number in 2’s C Decide upon the number of bits (n) Find the binary representation of the +ve value in n-bits Flip all the bits Add 1

2’s Complement Example Represent -5 in binary using 2’s complement notation Decide on the number of bits Find the binary representation of the +ve value in 6 bits Flip all the bits Add 1 6 (for example) 000101 +5 111010 111010 + 1 111011 -5

Sign Bit In 2’s complement notation, the MSB is the sign bit (as with sign-magnitude notation) 0 = positive value 1 = negative value +5: 0 0 0 1 0 1 +ve 5 -5: 1 1 1 0 1 1 -ve 2’s complement

“Complementary” Notation Conversions between positive and negative numbers are easy For binary (base 2)…

Example +5 2’s C -5 0 0 0 1 0 1 1 1 1 0 1 0 + 1 1 1 1 0 1 1 0 0 0 1 0 0 + 1 2’s C +ve -ve 2’s C

Range for 2’s Complement For example, 6-bit 2’s complement notation 100000 100001 111111 000000 000001 011111 -32 -31 ... -1 0 1 ... 31 Negative, sign bit = 1 Zero or positive, sign bit = 0

Ranges No. of bits Binary Unsigned Sign-magnitude 2’s complement Min Max 1 2 3 -1 -2 7 -3 -4 4 15 -7 -8 5 31 -15 -16 6 63 -31 -32

In General (revisited) No. of bits Binary Unsigned Sign-magnitude 2’s complement Min Max n 2n - 1 -(2n-1 - 1) 2n-1-1 -2n-1 2n-1 - 1

What is -6 plus +6? Zero, but let’s see -6: 10000110 +6: +00000110 10001100 Sign-magnitude -6: 11111010 +6: +00000110 00000000 2’s complement

2’s Complement Subtraction Easy, no special rules Subtract?? Actually … addition! A – B = A + (-B) add 2’s complement of B

What is 10 subtract 3? 7, but… Let’s do it (we’ll use 6-bit values) 10 – 3 = 10 + (-3) = 7 001010 +111101 000111 +3: 000011 -3: 111101

What is 10 subtract -3? 13, but… Let’s do it (we’ll use 6-bit values) 10 – (-3) = 10 + (-(-3)) = 13 001010 +000011 001101 -3: 111101 +3: 000011

M - N M + 2’s complement of N If M  N If M < N M + (2n - N) = M - N + 2n If M  N Produce an carry, which is discarded If M < N results in 2n - (N - M), which is the 2’s complement of (N-M)

Overflow Carry out of the leading digit If we add two positive numbers and we get a carry into the sign bit we have a problem If we add two negative numbers and we get a carry into the sign bit we have a problem If we add a positive and a negative number we won't have a problem Assume 4 bit numbers (+7 : -8)

N = 4 Number Represented Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Unsigned 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Signed Mag 1 2 3 4 5 6 7 -0 -1 -2 -3 -4 -5 -6 -7 1's Comp 1 2 3 4 5 6 7 -7 -6 -5 -4 -3 -2 -1 -0 2's Comp 1 2 3 4 5 6 7 -8 -7 -6 -5 -4 -3 -2 -1

Overflow If we add two positive numbers and we get a carry into the sign bit we have a problem 3 0011 4 0100 6 0110 8 1000

Overflow -5 1011 -4 1100 -3 1101 -5 1011 -8 11000 -9 10111 If we add two negative numbers and we get a carry into the sign bit we have a problem

Overflow If we add a positive and a negative number we won't have a problem 5 0101 -4 1100 -3 1101 5 0101 2 10010 1 10001

Overflow If we add two positive numbers and we get a carry into the sign bit we have a problem 3 0011 4 0100 6 0110 8 1000 carry in 0 carry out 0 carry in 1 carry out 0

Overflow If we add two negative numbers and we get a carry into the sign bit we have a problem -5 1011 -4 1100 -3 1101 -5 1011 -8 11000 -9 10111 carry in 1 carry out 1 carry in 0 carry out 1

Overflow If we add a positive and a negative number we won't have a problem 5 0101 -4 1100 -3 1101 5 0101 2 10010 1 10001 carry in 1 carry out 1 carry in 1 carry out 1

Binary Codes n-bit binary code BCD – Binary Coded Decimal (4-bits) 2n distinct combinations BCD – Binary Coded Decimal (4-bits) 0 0000 1 0001 … … 9 1001 BCD addition Get the binary sum If the sum > 9, add 6 to the sum Obtain the correct BCD digit sum and a carry

Binary Codes ASCII code Error-detection code American Standard Code for Information Interchange alphanumeric characters, printable characters (symbol), control characters Error-detection code one parity bit - an even numbered error is undetected “A” 41:100|0001 - - > 0100|0001 (even), 1100|0001 (odd)

Binary Logic Boolean algebra Binary variables: X, Y Logical operations two discrete values (true or false) Logical operations AND, OR, NOT Truth tables

Logic Gates Logic circuits Computations and controls Logic Gates circuits = logical manipulation paths Computations and controls combinations of logic circuits Logic Gates

Timing diagram

Thank You!