Академический Документы
Профессиональный Документы
Культура Документы
Digital Electronics
Number Systems and Logic Electronic Gates Combinational Logic Sequential Circuits ADC DAC circuits Memory and Microprocessors Hardware Description Languages
Weekly Structure
Lectures Monday, Tuesday, Wednesday Slides in ppt and pdf format on support website:
Digital vs Analog data Binary inputs and outputs Binary, octal, decimal and hexadecimal number systems Other uses of binary coding.
Analog/Analogue Systems
Analogue Systems
V(t) can have any value between its minimum and maximum value
V(t)
Digital Systems
Digital Systems V(t) must take a value selected from a set of values called an alphabet
V(t)
Binary digital systems form the basis of almost all hardware systems currently
Slide example
levels
Advantages of Digital Systems Analogue systems: slight error in input yields large error in output Digital systems more accurate and reliable Computers use digital circuits internally Interface circuits (for instance, sensors and actuators) are often analogue
Exercise
A photograph or painting A scanned image Sound from a computers loud speaker Sound file stored on disc
Coding: A single binary input can only have two values: True or False (Yes or No) (1 or 0)
Binary
00
01
10
1 1
Each additional input doubles the number of combinations we can represent i.e. with n inputs it is possible to represent 2n combinations
Combinations
Example 1:
Example 2:
What is the minimum number of bits needed to represent the digits 0 to 9 as a binary code?
Decimal systems
Number Representation
Difficult to represent Decimal numbers directly in a digital system Easier to convert them to binary There is a weighting system:
eg 403 = 4 x 100 + 0 x 10 + 3 x 1 or in, powers of 10: 40310= 4x102 + 0x101 + 3x100 = 400 + 0 + 3
Both Decimal and Binary numbers use a positional weighting system, eg:
10102 = 1x23+0x22+1x21+0x20 = 1x8 + 0x4 + 1x2 + 0x1 = 1010 decimal 100 (102) 4 binary 8 (23) 1 4 (22) 0 10 (101) 0 2 (21) 0 1 (100) 3 1 (20) 1 8+0+0+1 400 + 0 + 3
Binary to decimal
Multiply each 1 bit by the appropriate power of 2 and add them together.
? ? 128 1 1 0 64 0 1 32 0 0 16 0 0 8 0 1 4 0 1 2 1 0 1 1 0
Number Representation - Binary to decimal A decimal number can be converted to binary by repeated division by 2
number 155 77 38 19 9 4 2 1 /2 77 38 19 9 4 2 1 0 remainder 1 1 0 1 1 0 0 1 Most Significant bit Least Significant Bit
15510 = 100110112
Decimal to Binary
An alternative way is to use the placement method 128 64 32 16 8 4 2
128 goes into 155 once leaving 27 to be placed 1 So 64 and 32 are too big (make them zero) 16 goes in once leaving 11
1 0 0 1
and so on
Representations
There are different ways of representing decimal numbers in a binary coding BCD or Binary Coded Decimal is one example. Each decimal digit is replaced by 4 binary digits
Note that BCD code is longer than a direct representation in natural binary code:
453 = 111000101
Decimal 0 1 2 3 4 5 6 7 8 9
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Hexadecimal and Octal Writing binary numbers as strings of 1s and 0s can be very tedious Octal (base 8) and Hexadecimal (base 16) notations can be used to reduce a long string of binary digits.
octal 512 (83) 1 64 (82) 2 8 (81) 0 1 (80) 7 512 + 128 + 7
hexadecimal
256 (162)
1
16 (161)
A
1 (160)
F 256 + 160 + 15
Notice that hexadecimal requires 15 symbols (each number system needs 0 base-1 symbols) and therefore A F are used after 9.
binary 000
octal 0
001
010 011 100 101 110 111
1
2 3 4 5 6 7
hex 0 1 2
1000
1001 1010 1011 1100 1101 1110 1111
8
9 A B C D E F
0011
0100 0101 0110 0111
3
4 5 6 7
Thus 100111010100112 = 16 ?
Colour codes You often see hex used in graphic design programs for the red, blue and green components of a colour: FF0000 represents red, for example. How many bits are used to represent each colour? How many different colours can be represented?
Characters
Three main coding schemes used: ASCII (widespread use), EBCDIC (not used often) and UNICODE (new) ASCII table (in hex) :
00 nul 10 dle 20 sp 30 0 40 @ 50 P 60 ` 70 p 01 soh 11 dc1 21 ! 31 1 41 A 51 Q 61 a 71 q 02 sot 12 dc2 22 " 32 2 42 B 52 R 62 b 72 r 03 etx 13 dc3 23 # 33 3 43 C 53 S 63 c 73 s 04 05 eot enq 14 15 dc4 nak 24 25 $ % 34 35 4 5 44 45 D E 54 55 T U 64 65 d e 74 75 t u 06 ack 16 syn 26 & 36 6 46 F 56 V 66 f 76 v 07 bel 17 etb 27 ' 37 7 47 G 57 W 67 g 77 w 08 bs 18 can 28 ( 38 8 48 H 58 X 68 h 78 x 09 ht 19 em 29 ) 39 9 49 I 59 Y 69 i 79 y 0a nl 1a sub 2a * 3a : 4a J 5a Z 6a j 7a z 0b vt 1b esc 2b + 3b ; 4b K 5b [ 6b k 7b { 0c np 1c fs 2c , 3c < 4c L 5c \ 6c l 7c 0d cr 1d gs 2d 3d = 4d M 5d ] 6d m 7d } 0e so 1e rs 2e . 3e > 4e N 5e ^ 6e n 7e ~ 0f si 1f us 2f / 3f ? 4f O 5f _ 6f o 7f del
Gray Codes
Other codes exist for specific purposes Gray codes provide a sequence where only one bit changes for each increment Allows increments without ambiguity due to bits changing at different times.
Dec 0 1 2 3 E.g. changing from 3 to 4, normal binary has 4 all three bits changing 011 -> 100. 5 Depending on the order in which the bits change any intermediate value may be 6 created. 7
Summary
Support website Analogue and Digital Binary Number Systems Coding schemes considered were:
Exercises
You should practice conversions between binary, octal, decimal and hexadecimal. You should be able to code decimal to BCD (and BCD to decimal). You should be able to explain and give examples of digital and analogue data.