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 BCD coded number
Convert the BCD coded number into decimal. Solve Decimal Number BCD Coded Number
Convert the decimal number 350 to its BCD equivalent. Decimal Number BCD Coded Number 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 If a carry results when 6 is added, simply add the carry to the next 4-bit group.
BCD BCD addition
BCD What happen if more than 9 ? Because 4 bits up to 15 which is = 6 0110 add 6 and create the second bit significant The solution is 12 which means :
Ahmad Almulhem, KFUPM 2010 BCD Addition
BCD Example : add 8+9 The solution is :
BCD Example : ( )+( )
BCD Solve: 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 Decimal Sample Problem: Excess
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
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 DecimalBinary
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 to Gray code binary 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 to binary Gray 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)
Most significant bit Least significant bit
e.g., ‘a’ =
95 Graphic codes
33 Control codes
“Hello, world” Example ======================== Binary Hexadecimal C 6F 2C C 64 Decimal 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:
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 OR / Summation XYX+Y NOT XX’
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)