Digital Logic Rcs

2,323 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,323
On SlideShare
0
From Embeds
0
Number of Embeds
15
Actions
Shares
0
Downloads
54
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Digital Logic Rcs

  1. 1. Digital Logic
  2. 2. Digital Systems <ul><li>* Digital systems operate on discrete elements of information </li></ul><ul><li># Numbers (e.g., pocket calculator) </li></ul><ul><li># Letters (e.g., word processor) </li></ul><ul><li># Pictures (e.g., digital cameras) </li></ul><ul><li>* For a digital systems to operate on a continuous data, it needs to quantize (digitize) that data first </li></ul><ul><li># Covert data into digital representation </li></ul><ul><li>* Digital systems </li></ul><ul><li># Cell phone # MP3 music player …. etc </li></ul><ul><li># digital camera </li></ul>Ramzi Sh. Alqrainy
  3. 3. Numbers <ul><li>Each number is represented by a string of digits , in which </li></ul><ul><li>the position of each digit has an associated weight . </li></ul><ul><li>Example: </li></ul><ul><li>* In general , any decimal number D of the form </li></ul><ul><li>Has the value </li></ul>Ramzi Sh. Alqrainy
  4. 6. <ul><li>* What is the range of values of an n -bit number in radix r ? </li></ul><ul><li># Minimum value: 0 </li></ul><ul><li># Maximum value: r n -1 </li></ul><ul><li># Number of different values: r n </li></ul><ul><li>What is the range of values of an 4 -bit binary number? </li></ul><ul><li># Minimum value: 0 </li></ul><ul><li># Maximum value: 2 4 -1=15 </li></ul><ul><li># Number of different values: 2 4 = 16 </li></ul><ul><li>------------------------------------------------------------------------------- </li></ul><ul><li>What is the range of values of an 2 -bit decimal number? </li></ul><ul><li># Minimum value: 0 </li></ul><ul><li># Maximum value: 10 2 -1=99 </li></ul><ul><li># Number of different values: 10 2 = 100 </li></ul>Ramzi Sh. Alqrainy
  5. 9. Number Base Conversions <ul><li>* Binary to octal conversion </li></ul><ul><li>Starting at the binary point and working left, separate the bits into groups of three and replace each group with the corresponding octal digit. </li></ul><ul><li>(1010011100) 2 =001 010 011 100=(1234) 8 </li></ul><ul><li>* Binary to hexadecimal </li></ul><ul><li>separate the bits into groups of four and replace each group with the corresponding hexadecimal digit. </li></ul><ul><li>(1010011100) 2 = 0010 0100 1100 = (29C) 16 </li></ul>Ramzi Sh. Alqrainy
  6. 10. <ul><li>* Conversion of fractions </li></ul><ul><li>Starting at the binary point , group the binary digits that lie to the right into groups of three or four. </li></ul><ul><li>(0.10111) 2 = 0.101 110 = (0.56) 8 </li></ul><ul><li>(0.10111) 2 = 0.1011 1000 = (0. B6) 16 </li></ul><ul><li>* Conversion to binary numbers </li></ul><ul><li>Replace each octal or hexadecimal digit with the corresponding 3 or 4 bit binary string </li></ul>(2414) 10 =(100101101110) 2 Ramzi Sh. Alqrainy ( 4 5 5 6 ) 8 ( 9 6 E ) 16
  7. 14. COMPLEMENT <ul><li>* Complement are used in digital computer for simplifying the subtraction operation. </li></ul><ul><li>* There are two types of complement for each base-r system: </li></ul><ul><li>1- Diminished Radix Complement (r-1)’s </li></ul><ul><li>2- Radix Complement r’s </li></ul><ul><li># the two types are referred to as the 2’s complement and 1’s complement for binary number. </li></ul><ul><li># 10’s complement and 9’s complement for decimal number. </li></ul>Ramzi Sh. Alqrainy
  8. 16. <ul><li>Observation: </li></ul><ul><ul><li>* Subtraction from ( r n –1) will never require a borrow </li></ul></ul><ul><ul><li>* Diminished radix complement can be computed digit-by-digit </li></ul></ul><ul><ul><li>* For binary: 1 – 0 = 1 and 1 – 1 = 0 </li></ul></ul><ul><ul><ul><li>Ex . The 1’s complement of 1011000 is 0100111 </li></ul></ul></ul><ul><ul><ul><li>The 1’s complement of 0101101 is 1010010 </li></ul></ul></ul>Ramzi Sh. Alqrainy The 1’s complement of a binary number is formed by changing 1’s to 0’s and 0’s to 1’s
  9. 22. Signed Numbers with Complements <ul><li>* 3-bit number </li></ul>Ramzi Sh. Alqrainy ---- ---- 100 -4 111 100 101 -3 110 101 110 -2 101 110 111 -1 100 111 ---- -0 000 000 000 0 001 001 001 +1 010 010 010 +2 011 011 011 +3 Signed Magnitude Signed 1's complement Signed 2's complement Decimal
  10. 23. Signed Numbers <ul><li>How are signed numbers handled in base 10? </li></ul><ul><ul><li>~ Plus or minus sign placed in front of number </li></ul></ul><ul><li>Can we do that for binary numbers? </li></ul><ul><ul><li>~ Sign needs to be represented in digital system </li></ul></ul><ul><ul><li>~ Only choice are ‘0’ and ‘1’ </li></ul></ul><ul><ul><ul><li># ‘0’ indicates ‘+’ </li></ul></ul></ul><ul><ul><ul><li># ‘1’ indicates ‘–’ </li></ul></ul></ul><ul><li>Examples on five-bit numbers: </li></ul><ul><ul><li>01101 11101 00000 10000 </li></ul></ul><ul><ul><li>+ 13 – 13 + 0 – 0 </li></ul></ul>Ramzi Sh. Alqrainy
  11. 26. BCD Addition <ul><li>Addition is done BCD digit by BCD digit </li></ul><ul><li>~ 4 bits at the time </li></ul><ul><li>Can we use normal binary addition? </li></ul><ul><li>* Problem : digits adding up to more than 9 </li></ul><ul><li>~ Binary addition will result in invalid BCD codes </li></ul><ul><li>~ 1010 … 1111 are not valid </li></ul><ul><li>* Solution: check if resulting value is greater than 9 </li></ul><ul><li>~ if so, add 6 </li></ul><ul><li>~ 6 will offset the invalid BCD codes and generate the carry </li></ul>Ramzi Sh. Alqrainy
  12. 27. BCD Addition <ul><li>Example: 184 + 576 </li></ul><ul><li>BCD carry 1 1 </li></ul><ul><li>0001 1000 0100 184 </li></ul><ul><li>+ 0101 0111 0110 +576 </li></ul><ul><li>Binary sum 0111 10000 1010 </li></ul><ul><li>Add 6 0110 0110 </li></ul><ul><li>BCD sum 0111 0110 0000 760 </li></ul>Ramzi Sh. Alqrainy
  13. 28. Decimal Arithmetic <ul><li>Everything needs to be 4-bit aligned </li></ul><ul><li>􀁹 ‘ +’ represented by 0 (=‘0000’) </li></ul><ul><li>􀁹 ‘–’ represented by 9 (=‘1001’) </li></ul><ul><li>􀂃 Signed magnitude representation or complements </li></ul><ul><li>􀁹 Signed magnitude hardly use </li></ul><ul><li>􀁹 10’s complement most common </li></ul><ul><li>􀂃 Example: 375 + (–240) </li></ul><ul><li>􀁹 Negative numbers represented by 10’s complement </li></ul><ul><li>􀁹 10’s complement of 240 is 104 – 240 = 9760 </li></ul><ul><li>􀁹 Addition of all digits and </li></ul><ul><li>discard of end carry: 0 375 </li></ul><ul><li>+ 9 760 </li></ul><ul><li>0 130 </li></ul><ul><li>􀁹 Sign of result automatically correct </li></ul>Ramzi Sh. Alqrainy
  14. 29. Other Decimal Codes <ul><li>Decimals can be encoded in many ways in 4 bits </li></ul><ul><li>􀂃 Weighted codes </li></ul><ul><li>* Each bit position is assigned a weighting factor </li></ul><ul><li>* Value of code is sum of weights where bits are ‘1’ </li></ul><ul><li>* Is BCD a weighted code? </li></ul><ul><li>» Yes! It’s a 8,4,2,1 code </li></ul><ul><li>􀁹 Other weighted code: </li></ul><ul><li>» 2,4,2,1 code (yields non-unique coding) </li></ul><ul><li>» 8,4,-2,-1 code </li></ul><ul><li>􀂃 Self-complementing codes </li></ul><ul><li>* 9’s complement by exchanging 1’s with 0’s and 0’s with 1’s </li></ul><ul><li>* Excess-3 and 2421 codes are self-complementing </li></ul>Ramzi Sh. Alqrainy
  15. 30. Other Decimal Codes Ramzi Sh. Alqrainy
  16. 31. Gray Code <ul><li>* Imaging you code a 2-bit number with two light </li></ul><ul><li>switches connected to light bulbs </li></ul><ul><li>~ Can you count binary without causing ambiguity? </li></ul><ul><li>* Probably not: </li></ul><ul><li>~ Switching from 01 to 10 cannot be done simultaneously on both bits </li></ul><ul><li># Either 01->00->10 or 01->11->10 </li></ul><ul><li>* This brief error or ambiguity can cause problems </li></ul><ul><li>* Gray code changes only one bit between consecutive </li></ul><ul><li>numbers </li></ul>Ramzi Sh. Alqrainy
  17. 32. Gray Code Ramzi Sh. Alqrainy
  18. 34. ASCII Table Ramzi Sh. Alqrainy
  19. 35. Error-Detecting Code <ul><li>*Communication between systems can be “noisy” </li></ul><ul><li>􀁹 Environmental conditions can cause bit flips </li></ul><ul><li>* Error-detecting code </li></ul><ul><li>􀁹 If one bit is flipped, the code becomes invalid </li></ul><ul><li>􀁹 Communication system can detect that and retransmit </li></ul><ul><li>“ Parity bit ” is an extra bit included with a message to make the total number of 1’s either even or odd . </li></ul><ul><li>􀁹 “ Even parity”: choose parity bit such that # of 1’s is even </li></ul><ul><li>􀁹 “ Odd parity”: choose parity bit such that # of 1’s is odd </li></ul><ul><li>* Example: </li></ul><ul><li>􀁹 Data=1000001, even parity=0, odd parity=1 </li></ul><ul><li>􀁹 Data=1010100, even parity=1, odd parity=0 </li></ul><ul><li>* Only one parity bit is used </li></ul>Ramzi Sh. Alqrainy
  20. 36. Binary Storage and Registers <ul><li>* How is information stored on a digital system? </li></ul><ul><li>􀁹 Bits are stored in “binary cells” </li></ul><ul><li>􀁹 Binary cell can have two stable states: ‘0’ and ‘1’ </li></ul><ul><li>* Binary cells are grouped into registers </li></ul><ul><li>􀁹 n cells make up n-bit register </li></ul><ul><li>* Size of registers is typically predefined </li></ul><ul><li>􀁹 Simple microcontroller: 8 bits = 1 byte </li></ul><ul><li>􀁹 Pentium: 32 bits = 4 bytes </li></ul><ul><li>􀁹 Mac G5: 64 bits = 8 bytes </li></ul><ul><li>* Digital system can usually process entire registers </li></ul><ul><li>􀁹 “ Register transfer” operation specify processing </li></ul>Ramzi Sh. Alqrainy
  21. 37. Register Example Ramzi Sh. Alqrainy
  22. 38. Register Transfer Operations Ramzi Sh. Alqrainy

×