Example: Find the value of 1101 v(b) = = = 13 10

Similar documents
The string of digits in the binary number system represents the quantity

Systems I: Computer Organization and Architecture

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

CSI 333 Lecture 1 Number Systems

Sistemas Digitais I LESI - 2º ano

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

Useful Number Systems

2011, The McGraw-Hill Companies, Inc. Chapter 3

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Computer Science 281 Binary and Hexadecimal Review

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

Binary Adders: Half Adders and Full Adders

HOMEWORK # 2 SOLUTIO

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Chapter 1: Digital Systems and Binary Numbers

CSE140 Homework #7 - Solution

United States Naval Academy Electrical and Computer Engineering Department. EC262 Exam 1

Lecture 11: Number Systems

Number and codes in digital systems

Binary Numbers. Binary Octal Hexadecimal

Solution for Homework 2

DEPARTMENT OF INFORMATION TECHNLOGY

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

exclusive-or and Binary Adder R eouven Elbaz reouven@uwaterloo.ca Office room: DC3576

Understanding Logic Design

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Numbering Systems. InThisAppendix...

CPEN Digital Logic Design Binary Systems

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

Lecture 2. Binary and Hexadecimal Numbers

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Lecture 8: Binary Multiplication & Division

5 Combinatorial Components. 5.0 Full adder. Full subtractor

Digital Logic Design. Basics Combinational Circuits Sequential Circuits. Pu-Jen Cheng

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Chapter 4: Computer Codes

Adder.PPT(10/1/2009) 5.1. Lecture 13. Adder Circuits

COMBINATIONAL CIRCUITS

NUMBER SYSTEMS. 1.1 Introduction

FORDHAM UNIVERSITY CISC Dept. of Computer and Info. Science Spring, Lab 2. The Full-Adder

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

BINARY CODED DECIMAL: B.C.D.

Base Conversion written by Cathy Saxton

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

ECE 3401 Lecture 7. Concurrent Statements & Sequential Statements (Process)

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

ASYNCHRONOUS COUNTERS

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

Let s put together a Manual Processor

CHAPTER 3 Boolean Algebra and Digital Logic

Design and Development of Virtual Instrument (VI) Modules for an Introductory Digital Logic Course

Z80 Instruction Set. Z80 Assembly Language

Logic Reference Guide

COMPSCI 210. Binary Fractions. Agenda & Reading

CS201: Architecture and Assembly Language

A New Reversible TSG Gate and Its Application For Designing Efficient Adder Circuits

Step : Create Dependency Graph for Data Path Step b: 8-way Addition? So, the data operations are: 8 multiplications one 8-way addition Balanced binary

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

Number Representation

Binary Representation

Digital Design with Synthesizable VHDL

List of Experiment. 8. To study and verify the BCD to Seven Segments DECODER.(IC-7447).

Two's Complement Adder/Subtractor Lab L03

EXPERIMENT 4. Parallel Adders, Subtractors, and Complementors

NEW adder cells are useful for designing larger circuits despite increase in transistor count by four per cell.

Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

Section 1.4 Place Value Systems of Numeration in Other Bases

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Digital Design with VHDL

12. A B C A B C A B C 1 A B C A B C A B C JK-FF NETr

Designing Digital Circuits a modern approach. Jonathan Turner

Digital Electronics Detailed Outline

Decimal to Binary Conversion

CS321. Introduction to Numerical Methods

Digital Logic Design. Introduction

CSE140: Components and Design Techniques for Digital Systems

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

Binary Numbering Systems

Gates, Plexers, Decoders, Registers, Addition and Comparison

Digital Electronics Part I Combinational and Sequential Logic. Dr. I. J. Wassell

Number Systems and Radix Conversion

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

Implementation of Modified Booth Algorithm (Radix 4) and its Comparison with Booth Algorithm (Radix-2)

Combinational Logic Design

3. Convert a number from one number system to another

Q-Format number representation. Lecture 5 Fixed Point vs Floating Point. How to store Q30 number to 16-bit memory? Q-format notation.

The programming language C. sws1 1

Digital Logic Design

VHDL Test Bench Tutorial

Transcription:

Number Representation and Arithmetic Circuits The base of Decimal numbers = 10 any numberv(d) = n 1 i=0 d i 10 i Example : find the value of 895 v(d) = 5 10 0 + 9 10 1 + 8 10 2 = 5 + 90 + 800 Binary Numbers: The base = 2, each digit = 0 or 1 v(b) = n 1 i=0 b i 2 i Example: Find the value of 1101 v(b) = 1 2 0 + 0 2 1 + 1 2 2 + 1 2 3 = 1 + 4 + 8 = 13 10

nversion from decimal to binary Example: find the binary of 19 10 17 2 = 9 and remainder 1 9 2 = 4 and remainder 1 4 2 = 2 and remainder 0 2 2 = 1 and remainder 0 1 2 = 0 and remainder 1 Binary number is 10011 Octal numbers base =8 and digits 0-7 v(o) = n 1 i=0 o i 8 i Example: Find the value of 273 8 v(o) = 3 8 0 + 7 8 1 + 2 8 2 3 1 + 7 8 + 2 8 2 = 187 10 nversion from decimal to octal Divide the number by 8 Example 187 8 = 23, remainder 3 23 8 = 2, remainder 7 2 8 = 0, remainder 2

nversion between octal and binary convert each octal digit to its binary number Example : 537 8 = (101011111) 2 Example: 10101 = 010101 = (25) 8 Hexadecimal numbers base =16 and digits 0-9, A,B,C,D,E,F v(h) = n 1 i=0 h i 16 i Example: Find the value of A2E 16 v(o) = 14 16 0 + 2 16 1 + 10 16 2 14 1 + 2 16 + 10 16 2 = 2606 10 nversion from decimal to hex Divide the number by 16, and consider the remainders nversion between hex and binary convert each octal digit to its binary number Example : A2E 16 = (101000101110) 2 Example: 11100101 = 11100101 = (E5) 16

Addition of Unsigned Binary Numbers Each binary digit is added to the other as: 0 + 0 = 0 and carry 0 0 + 1 or 1 + 0 = 1 and carry 0 1 + 1 = 0 and carry 1 Example add Y=15 to X= 10 Y= 1111 X= 1010 = 1001 C= 1110 X+Y= 16+9=25

Two bit Adder Circuit Design (Full Adder) Add X plus Y with Ci, Results =, and Ci X Y 0 0 0 0 0 0 0 1 1 0 =!Ci.(!X.Y + X.!Y) + Ci.(!X.!Y + X.Y) 0 1 0 1 0 = X.Y + Ci.X + Ci.Y 0 1 1 0 1 1 1 1 0 0 0 1 1 0 1 0 0 1 0 1 X Y X Y Ci 1 1 1 1 1 X Ci Y Ci X Y Ci F.A.

Ripple Carry Adder for N bit Addition Y3 X3 Y2 X2 Y1 X1 Y0 X0 C0 Y X Ci F.A. Y X Ci F.A. Y X Ci F.A. Y X Ci F.A. C4 3 2 1 0 Problem: Propagation Delay of ripple carry pwdpwd

The igned Numbers The Most ignificant bit is used for sign. One less bit to represent the number. largest number is = 2 n 1 1 ign Magnitude: If sign bit (MB) = 0, the number is positive If sign bit =1, the number is negative Example: Find the sign magnitude representation of +5 and -5 +5 the sign bit is 0, +5 = 0101-5 the sign bit =1, -5=1101 1 s mplement: For any number, 1 s complement = (2 n 1) k Or invert each bit of the number Example: Find 1 s complement of +5 +5= 0101 and -5 in 1 s complement is 1010

The 2 s mplement For any number, 2 s complement = (2 n k) 1-Invert each bit of the number (1 s mplement) then add 1 2- keep digits same until first 1, then invert each following bit Example: Find 2 s complement representation of +5 and -5 +5= 0101-5 =1010 then add 1 =1011 Example: Find the decimal value of 2 s complement number = 1100 2 s C for 1100 = 0011 + 1= 0100 = 4 then the number is -4

Addition and ubtraction of signed numbers It is difficult to add / sub numbers in sign magnitude or 1 s complement Use 2 s complement ADD: use binary addition of the numbers ubtract: nvert to 2 s complement then ADD Example: Find +5+2, +5-2, -5+2, -5-2 +5 = 0101, -5= 1011 +2 = 0010, -2= 1110 +5+2=0111,-5-2=1001-5 = 1011 +2 = 0010-5+2=1101

Adder/ubtractor If add/sub=0, operation is X+ Y (add) If addsub=1, XOR will complement Y and Ci will add 1 and operation is X-Y (sub) Y3 X3 Y2 X2 Y1 X1 Y0 X0 C0 Y X Ci F.A. Y X Ci F.A. Y X Ci F.A. Y X Ci F.A. C4 3 2 1 0 4 Bit Ripple Carry Adder X3 X2 X1 X0 Y3 Y2 Y1 Y0 Add/ub 4 Bit Adder Ci C4 3 2 1 0 Adder/ubtractor

Radix mplement Can use 10 s complemet to decimal numbers: Example: 74-36 10 s complement of 36 = (99-36)+1= 64 74-36=74+64=38 Arithmetic Overflow when the digits are not enough for the result. Example: using 4 bits to perform +7+6 and -7-6 and -7+6 +7=0111, +6=0110-7=1001, -6=1010 +7+6=0111+ 0110=1101 a negative result overflow -7-6=1001 + 1010=0011 a positive result overflow -7+6=1001 + 0110=1111 a correct result negative

Overflow Detection Overflow must be detected in two condidtions: 1- C3=1 and C4=0 2-if C3=0 and C4=1 v=c3.!c4 +!C3.C4= C3 XOR C4

CARRY LOOKAHEAD ADDER (no ripple) define generate signal gi=xi.yi define popagate signal pi=xi + Yi ci+1=gi+ci-1.pi c1=g0+c0.p0 c2=g1+g0.p1+c0.p0.p1 c3=g2+g1.p2 + g0.p1.p2 +c0.p0.p1.p2 c4=g3+g2.p3+g1.p2.p3 + g0.p1.p2.p3 + c0.p0.p1.p2.p3 i=xi XOR Yi XOR Ci Group generate G0=g7+g6.p7+g5.p6.p7+... c0.p0.p1...p7 Group propagate P0=p0.p1.p2.p3.p4.p5.p6.p7 c8=g0 + c0.p0, c16= G1 + G0.P1 + c0.p0.p1

Design of Arithmetic Circuits Using VHDL VHDL code for full-adder LIBRARY ieee; UE ieee_std_logic_1164.all; ENTITY fulladd I PORT(Cin,x,y :IN TD_LOGIC; s,ut :OUT TD_LOGIC); END fulladd; ARCHITECTURE LogicFunc OF fulladd I BEGIN s<= x XOR y XOR Cin; ut<=(x AND y) OR (Cin AND x) OR (Cin AND y); END LogicFunc;

VHDL for 4 bit adder LIBRARY ieee; UE ieee_std_logic_1164.all; ENTITY adder4 I PORT(Cin :IN TD_LOGIC; X,Y :IN TD_LOGIC_VECTOR(3 DOWNTO 0); :OUT TD_LOGIC_VECTOR(3 DOWNTO 0); ut, OVF :OUT TD_LOGIC); END adder4; ARCHITECTURE Behavior OF adder4 I IGNAL um: TD_LOGIC_VECTOR(4 DOWNTO 0); BEGIN um<= ("0" & X) +Y + Cin; <= um(3 DOWNTO 0); ut <=um(4); OVF<=um(4) XOR X(3) XOR Y(3) XOR um(3); END Behavior;

Other Number Representations Floating Point V alue = + M.2 E 127 M is mantesa which is L 23 Bits E is exponent and is 8 M bits ign bit is MB BCD Binary ded Decimal It is a code for decimal numbers. convert each decimal digit to 4 bit binary Example: Find the BCD to 58 BCD = 0101 1000 BCD addition Add each digit in binary, if the result is > 9, then add 6 Example: 46 + 36 46= 0100 0110 36= 0011 0110 = 0111 1100 add 6 0110 = 1000 0010 = 82

BCD Adder Y X cout 4 bit Adder Cin Z 6 0 Detect sum>9 MUX adjust cout 4 bit Adder 0 BCD Adder

ACII de Uses 7 bits for 128 characters number 1 = 0110001 =49 Parity It uses the 8th bit for parity check. Even parity: number of 1 s = even Odd parity: number of 1 s = odd Parity Generator and Check For 4 bit generator use XOR (XOR generates a 1 if number of 1 s is odd): P=X3 XOR X2 XOR X1 XOR X0 At Receiving end C = p XOR X3 XOR X2 XOR X1 XOR X0 If C = 0 no errr, if C=1 then an error occured

Problems from Ch5 5-1-a 0111011110 = 478 b- (3751) 8 = 1 + 5 8 + 7 64 + 3 8 3 = 2025 c-(a25f) 16 = 15 1+5 16+2 16 2 +10 16 3 = 41567 5-3-a 0111011110 = +478 b- 1011100111 = -(0100011001) = -281 5-5 b- +117-34 = 83 no overflow c- -33-72 = -105 no overflow f- -45 + 20 = +25 no overflow 11010011 + 000010100 = 11100111 e-+117 + 42= +159 01110101 + 00101010 = 10011111 over flow 5-19- BCD ubtraction if X= 057, Y =038 Find X-Y 10 mplement of Y = 999-38 +1 = 962 057 + 962 = 019