# Dr. Nermin Hamza. Agenda Signed Numbers Properties of Switching Algebra.

## Presentation on theme: "Dr. Nermin Hamza. Agenda Signed Numbers Properties of Switching Algebra."— Presentation transcript:

Dr. Nermin Hamza

Agenda Signed Numbers Properties of Switching Algebra

Signed Numbers + 9 or -9 In binary system : the left most bit in the most significant bit of the number 0 for – 1 for + Example : let 9 = 1001 So +9 01001 and -9 11001

Code Systems Binary codes Binary coded decimal (BCD) Gray Code ASCII Code Error Detecting Code

BCD BCD: Binary Coded Decimal The one digits takes from 0 to 9 in decimal In BCD, a digit is usually represented by four bits which, in general, represent the decimal digits 0 through 9. Other bit combinations are sometimes used for a sign or for other indications (e.g., error or overflow).

The 8421 BCD Code BCD stands for Binary-Coded Decimal. A BCD number is a four-bit binary group that represents one of the ten decimal digits 0 through 9. Example: Decimal number 4926 4 9 2 6 8421 BCD coded number 0100 1001 0010 0110

BCD Decimal  BCD 0123456789 0000000100100011010001010110011110001001 127 127 000100100111

Example : (185) 10  (??) BCD Solution : (0001 1000 0101) BCD BCD

Convert the BCD coded number 1000 0111 0001 into decimal. Solve Decimal Number 8 7 1 BCD Coded Number 1000 0111 0001

Convert the decimal number 350 to its BCD equivalent. Decimal Number 3 5 0 BCD Coded Number 0011 0101 0000 Solve

BCD Addition BCD is a numerical code and can be used in arithmetic operations. Here is how to add two BCD numbers: Add the two BCD numbers, using the rules for basic binary addition. If a 4-bit sum is equal to or less than 9, it is a valid BCD number. If a 4-bit sum > 9, or if a carry out of the 4-bit group is generated it is an invalid result. Add 6 (0110) to a 4-bit sum in order to skip the six the invalid states and return the code to 8421. If a carry results when 6 is added, simply add the carry to the next 4-bit group.

BCD BCD addition 40100 + 50101 ---------------- 9 1001

BCD What happen if more than 9 ? Because 4 bits up to 15 which is 1111 15-9 = 6  0110 add 6 and create the second bit significant 40100 + 81000 --------------------------- +121100 + 0110 --------- 10010 The solution is 12 which means : 0001 0010

BCD Example : add 8+9 The solution is : 81000 + 91001 --------------------------------- + 17 10111

BCD Example : 184 + 576 (0001 1000 0100)+(0101 0111 0110) 1 1 0001 10000100184 + 0101 0111 0110576 ------------------------------------------------------------------------------------------- 0111100001010 01100110 -------------------------------------------------------------------------------------------- 0111 01100000760

BCD Solve: 145+679 The solution :

The Excess-3 Code Add 3 to each digit of decimal and convert to 4-bit binary form A BCD code (not 8421 BCD) Decimal Binary +3 Excess-3 0 0000 0011 0011 1 0001 0011 0100 2 0010 0011 0101 3 0011 0011 0110 4 0100 0011 0111 5 0101 0011 1000 6 0110 0011 1001 7 0111 0011 1010 8 1000 0011 1011 9 1001 0011 1100 Decimal 3 5 9 Sample Problem: Excess-3 0110 1000 1100

The Gray Code The Gray code’s most important characteristic is that only one digit changes as you increment or decrement the count. The Gray code is commonly associated with input/output devices such as an optical encoder of a shaft’s angular position. The Gray code is NOT a BCD code. Decimal Gray code 0 00000 1 00001 2 00011 3 00010 4 00110 5 00111 6 00101 7 00100 8 01100 9 01101 10 01111 11 01110 12 01010 13 01011 14 01001 15 01000 16 11000

The Gray Code The Gray code is unweighted and is not an arithmetic code. There are no specific weights assigned to the bit positions. Important: the Gray code exhibits only a single bit change from one code word to the next in sequence. This property is important in many applications, such as shaft position encoders.

The Gray Code DecimalBinary Gray Code 000000000 100010001 200100011 300110010 401000110 501010111 601100101 701110100DecimalBinary 810001100 910011101 1010101111 1110111110 1211001010 1311011011 1411101001 1511111000

The Gray Code Binary-to-Gray code conversion The MSB in the Gray code is the same as corresponding MSB in the binary number. Going from left to right, add each adjacent pair of binary code bits to get the next Gray code bit. Discard carries. ex: convert 10110 2 to Gray code 1 + 0 + 1 + 1 + 0 binary 1 1 1 0 1 Gray

The Gray Code Gray-to-Binary Conversion The MSB in the binary code is the same as the corresponding bit in the Gray code. Add each binary code bit generated to the Gray code bit in the next adjacent position. Discard carries. ex: convert the Gray code word 11011 to binary 1 1 0 1 1 Gray + + + + 1 0 0 1 0 Binary

The ASCII Code ASCII is an acronym for American Standard Code for Information Interchange Represents numbers, letters, punctuation marks and control characters Standard ASCII is a 7-bit code (127 characters) Extended ASCII (IBM ASCII), an 8-bit code, is also very popular Extended ASCII adds graphics and math symbols to code (total of 256 symbols)

ASCII Features 7-bit code 8 th bit is unused (or used for a parity bit) 2 7 = 128 codes Two general types of codes: 95 are “Graphic” codes (displayable on a console) 33 are “Control” codes (control features of the console or communications channel)

ASCII Chart

Most significant bit Least significant bit

e.g., ‘a’ = 1100001

95 Graphic codes

33 Control codes

Alphabetic codes

Numeric codes

Punctuation, etc.

“Hello, world” Example ======================== Binary 01001000 01100101 01101100 01101111 00101100 00100000 01110111 01100111 01110010 01101100 01100100 Hexadecimal 48 65 6C 6F 2C 20 77 67 72 6C 64 Decimal 72 101 108 111 44 32 119 103 114 108 100 Hello, worldHello, world ======================== ========================

Error-detection To detect errors in data : an eight bit is sometimes added to the ASCII character to indicate its parity. ASCII A: 1000001 0100000111000001

Error Detecting Code In data communication, errors may happen One code change into another code How to detect errors? Add an extra bit called a parity bit such that Number of 1’s is even (even parity) or odd (odd parity)

Error Detecting Code ASCII A = ASCII T =

Properties of Switching Algebra Why do we need Algebra: To Describe the relationships between inputs and outputs To Simplify the expressions of complex network (of gates) To Minimize the logic (number of Gates) needed for implementation To enable us to satisfy the constraints of the problem.

Definition for Switching Algebra OR: a + b is 1 Iff either or both a, b are 1 AND: a.b is 1 Iff both a,b are 1 NOT: a’ is 1 Iff a is 0

Definition for Switching Algebra AND / Product XYX.Y 000 010 100 111 OR / Summation XYX+Y 000 011 101 111 NOT XX’ 01 01 10 10

Definition for Switching Algebra Commutative : a+ b = b+ a ab = ba (P1) Associative: a +(b+c) = (a+b) + c a(bc) = (ab)c (P2)

Basic Properties: Identity: a+1= 1a. 1 = a(P3) Null: a + 0 = aa.0 =0(P4) Complement: a + a’ =1 a.a’= 0(P5) Idempotency: a + a = aa.a=a (P6) Involution: (a’)’ = a (P7) Distributive: a(b+c)= ab + ac a + bc=(a+b)(a+c)(P8)

Basic Properties: Adjacency: ab + ab’ = a (a+b)(a+b’) = a (P9) Demorgan : (a+b )’= a’. b’ (ab)’= a’+ b’(P10)

Boolean Functions F= x+yz XYZY.ZX+Y.Z 00000 00100 01000 01111 10001 10101 11001 11111

Boolean Functions Solve : f= A+B’C ABCB’B’CA+B’C 000100 001111 010000 011000 100101 101111 110001 111001

Boolean Functions NOTAND OR

Boolean Functions F= X+Y’Z X Y Z F

Boolean Functions Solve : f= XY’+X’Z X Y Z F

Boolean Functions The function simplification: F= x’y’z+x’y’z+xy’ =x’z(y’+y)+xy’ =x’z + xy’

Boolean Functions Simplify the following function: (x+y)( x+y’) =x.x+x.y’+x.y+y.y’ =x + x.y’+x.y+ 0 =x(1+y’+y) =x

Boolean Functions Simplify the following function: ABCD+A’BD+ABC’D = ABD(C+C’)+A’BD =ABD+A’BD =BD(A+A’) =BD

Boolean Functions Solve: Simplify and represent to truth table and get the gate implementation: X(X’ +Y) The solution : = XX’+XY = 0+XY =XY XYXY 000 010 100 111 X Y F

Boolean Functions Solve (simplify, draw gates and write the truth table): For: 1- xy+x’z+yz 2- (x+y)(x’+z)(y+z) 3-(A+B+C)’

Boolean Functions (A+B+C)’ LET X’= B+C (A+X)’ = A’X’  demorgan’s law So A’(B+C)’ = A’B’C’

Download ppt "Dr. Nermin Hamza. Agenda Signed Numbers Properties of Switching Algebra."

Similar presentations