CSC 214 Digital Design
CSC 214 Digital Design
S. O. ADEFAMOYE
Faculty of Sciences,
Computer Science Department
+234 – 809 – 073 – 1442
+229 – 6856 – 1587
Digital Designs Fundamentals 2
CHAPTER 1
INTRODUCTION TO NUMBERS AND CODES
1.0 Number representation: Computers can only process binary data – i.e. 1’s and 0’s. If
numeric data is to be processed then it cannot be processed in its usual base10 form, it must be
converted into its base2 form – known as binary.
There are two ways that can be used to represent numbers in binary:
‘pure’ binary;
Binary-coded decimal (BCD).
There are also two ‘half-way’ stages that are sometimes used by programmers because they are
easier to understand than a string of 1s and 0s:
Octal;
Hexadecimal.
2
Digital Designs Fundamentals 3
2. Then, starting from the left, ‘take out’ the values in the column headings, if possible:
128 cannot be taken out of 107 so that column contains a ‘0’:
64 can be taken out of 107 so that column contains a ‘1’; this leaves 107 – 64 = 43:
32 can be taken out of 43 so that column contains a ‘1’; this leaves 43 – 32 = 11:
3. keep repeating the above process until the whole number has been converted to pure
binary:
3
Digital Designs Fundamentals 4
Note that the higher codes are not used in BCD because they do not represent a denary digit.
These are:
4
Digital Designs Fundamentals 5
Converting between octal and binary. The octal number 652 (426 in denary) is represented in
binary as:
If we combine the bits in groups of three and label with the appropriate column headings…
… we can see that converting from octal to binary converts each digit into its 3-bit binary
equivalent (very similar as converting between denary and BCD).
2. Noting that A 10 and C 12, convert in the same way as conversion from binary to
denary:
= (4096 x 2) + (256 x 12) + (16 x 5) + (1 x 10)
= 11 354
= 1CE
1.5.1 Expression
Expressing the denary number 195 as eight-bit binary, BCD, octal and hexadecimal:
Binary
BCD
Octal
6
Digital Designs Fundamentals 7
Or:
Pure Binary:
Group in threes:
Octal:
Hexadecimal
Or:
Pure Binary:
Group in fours:
Hexadecimal:
If, for example, one byte is used to represent a ‘signed’ integer using the two’s compliment
method, the column headings would become:
Notes:
Negative numbers will always start with a ‘1’ and positives will start will a ‘0’;
The range of integers that can be represented using one byte is from – 128 up to + 127.
7
Digital Designs Fundamentals 8
Stage two
Starting at the right hand side, copy each bit, up to and including the first ‘1’:
Stage three
Reverse all the other bits:
= – 128 + 64 + 16 + 4 + 1
= – 43
= – (64 + 8 + 4)
= – 76
Notes:
The range of integers that can be represented using one byte is from – 127 up to + 127.
Although the sign and magnitude method is easier for humans it is much harder to use for
computers performing arithmetic.
SPOT CHECK
1. Assuming a single byte is used, convert the following numbers into two’s compliment binary:
(a) – 5 (b) – 10 (c) – 20
2. What is the denary value of 1010 1011 if the binary codes represent:
(a) a two’s compliment number (b) a sign and magnitude number
8
Digital Designs Fundamentals 9
Note that when you add a ‘carry’ to the next column, it is possible for:
1 + 1 + 1 (the carry) = 3 (‘11’ in binary – this is 1 ‘down’ and ‘carry’ 1)
This is better shown if we add 1010 1110 1100 and 0011 1010 1010:
1.8.2 Subtraction
To perform subtraction, the number to be subtracted is converted into its two’s compliment
negative and then added.
12
-12
9
Digital Designs Fundamentals 10
CHAPTER 2
TEXT (CHARACTER) REPRESENTATION
ASCII
American Standard Code for Information Interchange (ASCII) is used for character encoding by
most Windows™ PCs. ASCII can be used to translate alphanumeric characters into a 7-bit binary
code that represents all the characters available from the keyboard including punctuation and
some special symbols such as ‘@’, # and $:
A development of ASCII, known as Extended ASCII, uses an 8-bit code that also defines codes for
additional characters, including some graphical ones. Note that using an 8-bit code means the
maximum number of characters that can be represented is 256.
10
Digital Designs Fundamentals 11
The message is typed at the keyboard. Electronics in the keyboard convert the typed characters
into ASCII binary codes that are sent from the keyboard along a cable to the computer. The
computer stores these codes in its internal memory. The computer also provides a visual
display of the characters as they are typed. To be able to do this, electronics inside the
computer convert the stored binary codes back into their character equivalents.
EBCDIC
Extended Binary Coded Decimal Interchange Code (EBCDIC) was developed by IBM for use in
their mainframe systems. It has the same limitation as ASCII in that its 8-bit code can only
define 256 different characters.
11
Digital Designs Fundamentals 12
Notice how the EBCDIC codes are completely different to ASCII – if a message was sent that had
been encoded using ASCII, but received by a system that used EBCDIC, then the resulting
message would not make sense.
Unicode.
Unicode is an international system of representing characters using 16 bits. Using 16 bits means
that 216 = 65 536 different characters can be represented (thus overcoming the limitation of
ASCII and EBCDIC).
Unicode allows every character from most alphabets to have a code of its own – Chinese,
Russian, Greek, Urdu etc, including Egyptian Hieroglyphics. Note that there are plenty of spare
codes that are used for mathematical symbols, common graphics and even the Braille symbols.
12
Digital Designs Fundamentals 13
CHAPTER 3
13
Digital Designs Fundamentals 14
14
Digital Designs Fundamentals 15
15
Digital Designs Fundamentals 16
16
Digital Designs Fundamentals 17
17
Digital Designs Fundamentals 18
18
Digital Designs Fundamentals 19
19
Digital Designs Fundamentals 20
20
Digital Designs Fundamentals 21
21
Digital Designs Fundamentals 22
22