01-02 - Number Syst

Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

1

LOGIC DESIGN

NUMBER SYSTEMS

Doç. Dr. Birim BALCI CBÜ 2022-23 Spring


Introduction
2

 Why digital circuits?


 They are everywhere
 digital computers, smart phones, digital recording, digital TV …..

 Simpler to design than analog circuits


• can build more sophisticated systems

 Logic gates (AND, OR, NOT)


 Boolean algebra
What is a Digital System?
3

 One characteristic: Ability of manipulating discrete


elements of information
 A set that has a finite number of elements contains discrete
information

 Examples for discrete sets


 Decimal digits {0, 1, …, 9}
 Alphabet {A, B, …, Y, Z}
 Binary digits {0, 1}

 One important problem


 how to represent the elements of discrete sets in physical
systems?
How to represent the elements of discrete sets in
physical systems ?
4

 In electronics circuits, we have electrical signals:


Voltage, Current

 Different strengths of a physical signal can be used to


represent elements of the discrete set.
5

 Which discrete set?

 Binary set is the easiest

 two elements {0, 1}  1: TRUE, HIGH


0: FALSE, LOW
 Just two signal levels: 0 V and 5 V

 we use binary system to represent the info. in digital systems.


6

 Elements of any discrete set can be represented using


groups of bits.

 9  1001
 A  1010
Decimal/ Octal/ Hexadecimal Systems
7

 Decimal system
 coefficients are from {0,1, …, 9}
 and coefficients are multiplied by powers of 10
 Because the digits have 10 possible values and each digit is
weighted as a power of 10, we say that
decimal numbers are base-10 or radix-10 numbers

 Octal  Hexadecimal
 Base 8 = base 23  Base 16
 digits {0,1, …, 7}  digits {0, 1, …, 9, A, B, C, D, E, F}
 Example: (31.5)8  Example: (19.A)16
Numbers
in
different
systems
9

Powers of 2
 210 = 1,024 (K)
 220 = 1,048,576 (M) 1 byte = 8 bits
 230  (G)
 240  (T)
 250  (P)
 exa, zetta, yotta, …
(exbi, zebi, yobi, ...)
Similar !
But Base is 2 instead of 10
Base Conversions: From base-r to decimal
12

 expand the number in power series and add all the terms
 Reverse operation requires division
 Simple idea:
Divide the decimal number successively by r
&
Accumulate the remainders

 If fraction :
integer and fraction parts are handled separately.
Base Conversions: From base-r to binary

1- Decimal to binary conversion


LsD: Least Significant
Digit

(55)10 = ( )2

MsD: Most Significant


Digit

(55 )10 = (110111) 2


Base Conversions: From base-r to binary...

2- Hexadecimal to binary conversion


Base Conversions: From base-x to base-y

* Decimal to octal
* Decimal to Hexadecimal
* Hexadecimal to octal
* ...
Base Conversions…
18

Example 2 : Dealing with fractions


Convert decimal number 0.6875 to binary.

When dealing with fractions, instead of dividing by r multiply by r


until we get an integer
 0.68752 = 1.3750 = 1 + 0.375  a-1 = 1 MsD
 0.37502 = 0.7500 = 0 + 0.750  a-2 = 0
 0.75002 = 1.5000 = 1 + 0.500  a-3 = 1
 0.50002 = 1.0000 = 1 + 0.000  a-4 = 1 LsD

(0.6875) 10= (0.1011)2


Arithmetic with Binary Numbers

ADDITION

Decimal Binary

20
21
Arithmetic with Binary Numbers
22

Subtraction Multiplication

More Exp
Examples: Examples:
( 011)2 + (001) 2 = ( ?) 2 ( 011)2 + (001) 2 = ( ?) 2

(11)2 + (11)2 = (? ) 2 (11)2 + (11)2 = (? ) 2

23
Complement Arithmetic
26

Goal: To simplify subtraction operation


 turn the subtraction operation into an addition op.

 Two types
1. Radix complement when r = 2
(r’s complement) 1. 2’s complement
2. Diminished complement
((r-1)’s complement) 2. 1’s complement

Easier way to compute 1’s and 2’s complements:


1’s complement  negate
2’s complement  negate + increment
Radix complement (r’s complement) of a number:
Tt = Tt-1 + 1 (LsD)
Examples:

• Find the two’s compelement


of binary number (1001)2

2’ye tümleyen biçiminde verilen


sayının negatifini gösterirken
tümleyenini alıyoruz.
1001  0111 +sayı
bunun da T2 1001 -sayı
Examples:

N=(1011)2  radix (r)compliment in base 2 : T2= ?


T1 = 0100 0100
+ 1
0101
6= (0110)
-6  1001
+ 1
1010

3= (0011)
2 = (0010)

-2  1101
+ 1
1110 ignore carry
Taking One’s Complement
31
Diminished complement ((r-1)’s complement) : Tt-1

Exp:
N=(1,27)8  diminished compliment in base 8 : T7= (6,50)

N=(1011)2  diminished compliment in base 2 : T1= (0100)

If you add the number and the compliment of it according to diminihed


notation (t-1), each digit will be (t-1).

Easier way to compute 1’s and 2’s complements:


1’s complement  negate
2’s complement  negate + increment
33

Exp:
10’s complement of Exp:
9’s complement
(9)10 = ?
of (9)10 = ?
0 +1 1 0

Exp:
10’s complement of Exp:
9’s complement
(009)10 = ? of (009)10 = ?
990
990 + 1  991
“signed-magnitude
method” rarely used in
digital systems.

 01011  (unsigned binary) Number is 11


 (signed binary) Number is +11

 11011  (unsigned binary) Number is 27


 (signed binary) Number is -11
Signed Binary Numbers
35

“signed-magnitude method” rarely used in digital systems.

In computers, a negative number is represented by


the complement of its absolute value.

Signed-complement system:

positive numbers have always “0” in the MSB position


negative numbers have always “1” in the MSB position
Signed-Complement System
36
binary
 Dec + 0 000
-0 100

 Dec +1 001
-1 101

 Dec +2 010
-2 110

 Dec +3 011
-3 111
Arithmetic Addition
sign+magnitude notation according to Radix notation ( Tt)
37

Case 1: A> 0, B > 0 Case 2: A< 0, B < 0


13 0000 1101 sign+mag t base
+ 11 + 0000 1011 -4 1 0100 1 1100
0001 1000 + -7 1 0111 + 1 1001
sign bit: 0  positive 1 1 0101
ignore
Take complement to see sign
+magnitute notation:
1 0101 1 1010
+ 1
result 1 1011 -11
Arithmetic Addition
sign+magnitude notation according to Radix notation ( Tt)
38

Case 3: A> 0, B < 0 Case 3: A<0, B >0


result will be + result will be –
(MutlakA<mutlak B)
(MutlakA>MutlakB) For the result, take 2’s
complement of the value
if carry  ignore
5 0101 0101
+ -2 + 1010 + 1110
10011
İgnore carry
sign bit: 0  positive
Arithmetic Addition
according to Diminished notation ( Tt-1)
By useing+magn. Precision
39

Case 1: A> 0, B > 0 Case 2: A< 0, B < 0


Same as previous one sign+mag t-1 base
13 0000 1101 -3 1 0011 1 1100
+ 11 + 0000 1011 + -11 1 1011 + 1 0100
0001 1000
1 10000
sign bit: 0  positive
add to LsD
10000
+ 1
10001 negative  takecompl
to see sign +magnitute notation:
1 0001 1 1110
result: 1 1110
Arithmetic Addition
according to Diminished notation ( Tt-1)
40

Case 3: A> 0, B< 0 Case 3: A>0, B <0


Result will be + Mutlak b> mutlakA
Sign bit 0 Result will be -
Add Carry bit to LsD of sum Sign bit will be 1
Take the complement of sum
Subtraction with compliments
41

 Traditionally: If the minuend digit is smaller than the subtrahend digit,


you borrow “1” from a digit in higher significant position

 With complements
Subtraction with compliments
42

 According to Tt compliment (Radix notation Tt = Tt-1 + 1 )

X = 11001 (25)
Y = 10011 (19) X-Y = ?

if sum has carry  result +  ignore carry


no carry  result -  take inverse and add 1

result: (00110)2
Subtraction with compliments
43

 According to Tt -1 compliment ( Diminished Radix notation)

X = 11001 (25)
Y = 10011 (19) X-Y = ?

if sum has carry  result +  add carry to LsD


no carry  result -  take inverse of the value

Result: 00101
+ 1
( 00110)2

You might also like