Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs

Similar documents
Number representations

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

To design a 4-bit ALU To experimentally check the operation of the ALU

EE 109 Unit 6 Binary Arithmetic

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Number System. Introduction. Decimal Numbers

Basic Arithmetic (adding and subtracting)

CHW 261: Logic Design

Signed Binary Numbers

Digital Fundamentals. Lab 6 2 s Complement / Digital Calculator

Microcomputers. Outline. Number Systems and Digital Logic Review

THE LOGIC OF COMPOUND STATEMENTS

Chapter 3: Arithmetic for Computers

Binary Adders: Half Adders and Full Adders

Chapter 3: part 3 Binary Subtraction

CMPE223/CMSE222 Digital Logic Design. Positional representation

Lecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture

T02 Tutorial Slides for Week 2

Lab 3: Standard Combinational Components

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

Chapter 4 Arithmetic Functions

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Chapter 2 Data Representations

Experiment 7 Arithmetic Circuits Design and Implementation

Signed umbers. Sign/Magnitude otation

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

BINARY SYSTEM. Binary system is used in digital systems because it is:

Chapter 4. Combinational Logic

CO Computer Architecture and Programming Languages CAPL. Lecture 9

Computer Architecture and Organization: L04: Micro-operations

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

EE292: Fundamentals of ECE

Slide Set 1. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Data Representations & Arithmetic Operations

Department of Electrical and Computer Engineering University of Wisconsin - Madison. ECE/CS 352 Digital System Fundamentals.

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Chapter 4. Operations on Data

Chapter 2: Number Systems

Advanced Computer Architecture-CS501

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Inf2C - Computer Systems Lecture 2 Data Representation

COMP Overview of Tutorial #2

Number Systems. Both numbers are positive

Binary Representations and Arithmetic

Representation of Non Negative Integers

Computer Architecture and Organization

COMP 303 Computer Architecture Lecture 6

CSE140 L. Instructor: Thomas Y. P. Lee January 18,2006. CSE140L Course Info

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

CS/EE1012 INTRODUCTION TO COMPUTER ENGINEERING SPRING 2013 HOMEWORK I. Solve all homework and exam problems as shown in class and sample solutions

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Chapter 2 Bits, Data Types, and Operations

UNIT 7A Data Representation: Numbers and Text. Digital Data

CS & IT Conversions. Magnitude 10,000 1,

Principles of Computer Architecture. Chapter 3: Arithmetic

The Design of C: A Rational Reconstruction

Chapter 3 Part 2 Combinational Logic Design

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC


The Design of C: A Rational Reconstruction"

UNIT IV: DATA PATH DESIGN

Injntu.com Injntu.com Injntu.com R16

ECE 30 Introduction to Computer Engineering

Chapter 10 Binary Arithmetics

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

CS/COE0447: Computer Organization

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

CS/COE0447: Computer Organization

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

COMP2611: Computer Organization. Data Representation

Number Systems CHAPTER Positional Number Systems

Chapter 2 Bits, Data Types, and Operations

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

MC1601 Computer Organization

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System

World Inside a Computer is Binary

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

Digital Fundamentals

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations

INF2270 Spring Philipp Häfliger. Lecture 4: Signed Binaries and Arithmetic

Numerical Representations On The Computer: Negative And Rational Numbers

Chapter 1. Digital Systems and Binary Numbers

Transcription:

Number Systems Readings: 3-3.3.3, 3.3.5 Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches Missing: Way to implement numbers in binary Approach: From decimal to binary numbers (and back) 8

Decimal (Base ) Numbers Positional system - each digit position has a value 2534 = 2*, + 5* + 3* + 4* Alternate view: Digit position I from the right = Digit * I (rightmost is position ) 2534 = 2* 3 + 5* 2 + 3* + 4* 9

Base R Numbers Each digit in range..(r-),,2,3,4,5,6,7,8,9,a,b,c,d,e,f... A = B = C = 2 D = 3 E = 4 F = 5 Digit position I = Digit * R I D 3 D 2 D D (base R) = D 3 *R 3 +D 2 *R 2 +D *R +D *R 2

Number System (Conversion to Decimal) Binary: () 2 = Hexadecimal: (E32) 6 = 2

Conversion from Base R to Decimal Binary: () 2 Hexadecimal: (A6) 6 22

Conversion of Decimal to Binary (Method ) For positive, unsigned numbers Successively subtract the greatest power of two less than the number from the value. Put a in the corresponding digit position 2 = 2 4 =6 2 8 =256 2 2 =496 (4K) 2 =2 2 5 =32 2 9 =52 2 3 =892 (8K) 2 2 =4 2 6 =64 2 =24 (K) 2 3 =8 2 7 =28 2 =248 (2K) 23

Decimal to Binary Method Convert (2578) to binary Convert (289) to binary 24

Conversion of Decimal to Binary (Method 2) For positive, unsigned numbers Repeatedly divide number by 2. Remainder becomes the binary digits (right to left) Explanation: 25

Decimal to Binary Method 2 Convert (289) to binary 26

Decimal to Binary Method 2 Convert (85) to binary 27

Converting Binary to Hexadecimal hex digit = 4 binary digits Convert () 2 to hex Convert (A3FF2A) 6 to binary 28

Converting Decimal to Hex Convert to binary, then to Hex Convert (98) to Hexadecimal 29

Arithmetic Operations Decimal: 5 7 8 9 2 + 7 8 9 5 6 Binary: + Decimal: 5 7 8 9 2-3 2 9 4 6 Binary: - 3

Arithmetic Operations (cont.) Decimal: 2 * 2 4 Binary: * 3

Half Adder Ai Bi Carry Sum Ai Bi Bi Ai Ai Bi Bi Ai Carry = Ai Bi Sum = Ai Bi + Ai Bi = Ai + Bi A i Sum B i Half-adder Schematic Carry 32

Full Adder A B CI CO S 33

Full Adder Implementation 34

Multi-Bit Addition A 3 B 3 A 2 B 2 A B A B A 3 A 2 A A + B 3 B 2 B B A B A B A B A B CO + CI CO + CI CO + CI CO + CI S S S S S 3 S 2 S S 35

Multi-Bit Addition in Verilog, Parameters module uadd #(parameter WIDTH=8) (out, a, b); output logic [WIDTH:] out; input logic [WIDTH-:] a, b; always_comb begin out = a + b; end endmodule module add4 #(parameter W=22) (out, a, b, c, d); output logic [W+:] out; input logic [W-:] a, b, c, d; endmodule 36

Negative Numbers Need an efficient way to represent negative numbers in binary Both positive & negative numbers will be strings of bits Use fixed-width formats (4-bit, 6-bit, etc.) Must provide efficient mathematical operations Addition & subtraction with potentially mixed signs Negation (multiply by -) 37

Sign/Magnitude Representation -4-3 -5-2 -6 - -7 - + +7 + +6 +2 +3 +4 +5 + = + 4 = - 4 - High order bit is sign: = positive (or zero), = negative Three low order bits is the magnitude: () thru 7 () n- Number range for n bits = +/-2 - Representations for : 38

Sign/Magnitude Addition (+2) + (+4) (-2) + (-4) (+2) + ( -4) ( -2) + (+4) Bottom line: Basic mathematics are too complex in Sign/Magnitude 39

Idea: Pick negatives so that addition works Let - = - (+): ( ) - (+) Does addition work? (+2) + ( -) Result: Two s Complement Numbers 4

Two s Complement Only one representation for One more negative number than positive number Fixed width format for both pos. & neg. numbers -4-5 -3-6 -2-7 - -8 + +7 + +6 +2 +3 +4 +5 + = + 3 = - 3-4

Negating in Two s Complement Flip bits & Add Negate () 2 (+2) Negate () 2 (-2) -4-5 -3-6 -2-7 - -8 + +7 + +6 +2 +3 +4 +5 42

Addition in Two s Complement (+2) + (+4) (-2) + (-4) (+2) + ( -4) ( -2) + (+4) 43

Subtraction in Two s Complement A - B = A + (-B) = A + B + - - - 44

Overflows in Two s Complement Add two positive numbers but get a negative number or two negative numbers but get a positive number -3-4 -5-6 -7 - -2-8 + +7 + +6 +2 +5 +3 +4-3 -4-5 -6-7 -2 - -8 + +7 + +6 +2 +5 +3 +4 5 + 3 = -8-7 - 2 = +7 45

Overflow Detection in Two s Complement 5-7 3-2 -8 7 Overflow Overflow 5-3 2-5 7-8 No overflow No overflow 46

Adder/Subtractor A 3 B 3 A 2 B 2 A B A B A B A B A B A B CO + CI CO + CI CO + CI CO + CI S S S S S 3 S 2 S S Overflow A - B = A + (-B) = A + B + 47

Converting Decimal to Two s Complement Convert absolute value to unsigned binary, then fixed width, then negate if necessary Convert (-9) to 6-bit Two s Complement Convert (9) to 6-bit Two s Complement 48

Converting Two s Complement to Decimal If Positive, convert as normal; If Negative, negate then convert. Convert () 2 to Decimal Convert () 2 to Decimal 49

Sign Extension To convert from N-bit to M-bit Two s Complement (N<M), simply duplicate sign bit: Convert () 2 to 8-bit Two s Complement Convert () 2 to 8-bit Two s Complement 5

Solving Complex Problems Many problems too complex to build as one system Replace with communicating sub-circuits Timer ST TS TL Traffic Light Controller Design process: Understand the problem Break problem into subsystems, identifying connections Design individual subsystems. 5

Complex Problem Example Design a digital clock, which can Display the seconds, minutes and hours Have three inputs Increment hour Increment minute Reset seconds 52

Complex Problem Example (cont.) 53

Complex Problem Example (cont.) 54

Complex Problem Example (cont.) 55