EGR 270Fundamentals of Computer
Engineering
• Syllabus• Office Hours• Web page
Reading Assignment: Chapter 1 in Logic and Computer Design Fundamentals, 5th Edition by Mano
1Chapter 1 EGR 270 – Fundamentals of Computer Engineering
2Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Sequence of Electrical/Computer Engineering Courses at TCC
Notes:1. Classes available at the Virginia Beach Campus, the Chesapeake Campus, and the Tri-Cities
Center2. EGR 271-272 transfers to Virginia Tech as ECE 20043. EGR 270 transfers to Virginia Tech as ECE 25044. EGR 262 does not transfer to Virginia Tech
EGR 271 (3 cr)Circuit Theory I
ODU equiv: ECE 201Offered: F, Sp, Su
EGR 272 (3 cr)Circuit Theory II
ODU equiv: ECE 202Offered: F, Sp
EGR 262 (2 cr)Fund. Circuits Lab
ODU equiv: ECE 287Offered: F, Sp, Su
EGR 270 (4 cr)Fund. Of Computer EGR
ODU equiv: ECE 241Offered: F, Sp, Su
EGR 125 (4 cr)Into to Engineering
Methods (C++)
MTH 279 (4 cr)DifferentialEquations
Digital System – a system that works with discrete elements of information (a set of symbols) rather than with continuous signals as in an analog system. This discrete information is represented in binary form. Data processing is carried out by means of binary logic elements using binary signals. Quantities are stored in binary storage elements (memory).
Illustration (analog system and binary system):
Chapter 1 – Binary Systems
3Chapter 1 EGR 270 – Fundamentals of Computer Engineering
1. Decimal NumbersBase = 10, ten unique digits: (0,1,2,3,4,5,6,7,8,9), place values, counting sequence, examples, LSD and MSD
Number Systems
2. Binary NumbersBase = 2, two unique digits: (0 and 1), binary digit = “bit”, place values, counting sequence, examples, LSB and MSB
4Chapter 1 EGR 270 – Fundamentals of Computer Engineering
3. Octal NumbersBase = 8, eight unique digits: (0,1,2,3,4,5,6,7), place values, counting sequence, examples, LSD and MSD
Number Systems
4. Hexadecimal NumbersBase = 16, sixteen unique digits: (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F), place values, counting sequence, examples, LSD and MSD
5Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Arithmetic operations in other bases are very similar to the familiar operations that we have always used in base 10.
Arithmetic Operations
Examples – Addition (in several bases)
6Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Examples – Subtraction (in several bases)
7Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Examples – Multiplication (in several bases)
8Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Converting Between Bases
Examples:
1. Converting to decimal: expand by place value as previously seen 2. Converting from decimal: A. For the integer portion: Use repeated division by the base (LSD is found first) B. For the fractional portion: Use repeated multiplication by the base (MSD is found first).
9Chapter 1 EGR 270 – Fundamentals of Computer Engineering
3. Converting between binary, octal, and hexadecimal – simple replacement A) Binary to octal
Examples:
10Chapter 1 EGR 270 – Fundamentals of Computer Engineering
3. Converting between binary, octal, and hexadecimal – simple replacement B) Binary to hexadecimal
Examples:
11Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Complements• Complements are commonly used to represent negative numbers and to
perform subtraction.• There are two types of complements which can be applied to any base:
General Base 2 Base 10(r-1)’s complement 1’s complement 9’s complementr’s complement 2’s complement 10’s complement
where r = baseAnd a general number X might consist of the digits X = aaaaaaa.bbbn = number of digits before the decimal pointm = number of digits after the decimal point
Formal definitions:(r-1)’s complement of X = rn – r-m – X ( = rn –1-X if m = 0) r’s complement of X = rn – X = (r-1)’s complement + r-m (= (r-1)’s complement + 1 if m = 0)
12Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Shortcut approach to finding complements:9’s comp: subtract each digit from 910’s comp: 9’s comp + 1 if m = 01’s comp: replace each 0 with 1 and replace each 1 with 02’s comp: 1’s comp + 1 if m = 02’s comp (alternate method): Move from the right until the first 1 is encountered.
Complement each bit after (but not including) this 1.
Examples:
13Chapter 1 EGR 270 – Fundamentals of Computer EngineeringExamples (using the formal definition):
Representing negative numbers in 2’s complement form:Negative numbers are typically represented in 2’s complement form in computers orother digital systems.
Example: int variables in C++ are represented using two bytes, where the MSB is a sign bit.
If the MSB = 1, the number is negative and in 2’s complement form.1) What are the max and min values that can be stored?2) What happens when an overflow occurs? (Show a sample program)
14Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Example: 1) Show how to represent +34 as an 8-bit signed binary number.2) Show how to represent -34 as an 8-bit signed binary number.3) If 10101010 is an-8-bit signed binary number, when decimal value does it represent?4) If 01100110 is an-8-bit signed binary number, when decimal value does it represent?
Binary CodesDigital systems use 2-state devices that understand only 2 binary values (0 and 1). But we communicate using various symbols and methods. Codes are needed to allow us to communicate. Codes translate our language into the computers language and vice versa.
Input/Output Information (letters, numbers, symbols,
colors, sounds, control characters, etc.)
Digital system (binary representation
of all information)
encoded
decoded
How many bits are needed to encode a set of elements? In general,
N bits are needed to encode up to 2N elements
N = log2(number of elements)
15Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Examples: Determine the number of bits required and develop a code to encodeeach of the following:A) 8 symbols
B) 10000 symbols
C) the 366 days of the year in order
D) the 366 days of the year using the month and day
16Chapter 1 EGR 270 – Fundamentals of Computer Engineering
byte: group of 8 bitsword: an n-bit code forms n-bit words. In a computer system, a certain number of bytes may form a word. For example, a 16-bit system might refer to words as consisting of 2 bytes.
kilobyte (kB): 210 = 1024 bytesmegabyte (MB): 220 = 1024 kB = (1024)(1024) = 1,048,576 bytesgigabyte (GB): 230 = 1024 MB = 1,073,741,824 bytesterabyte (TB): 240 = 1024 GBpetabyte (PB): 250 = 1024 TBetc
Multiplier Prefix name Symbol10+3 kilo k10+6 mega M10+9 giga G10+12 tera T10+15 peta P10+18 exa E
Recall the system of SI prefixes:
Example: How many address lines (bits) are required in a computer that has 64 MB of RAM (random access memory)?
Example: How many address lines (bits) are required in a computer that has 512 GB of RAM (random access memory)?
17Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Decimal Codes – codes used to encode the digits 0 – 9Several examples are shown below (Table 1-5 from the text)The BCD code is the most common.Know the BCD code for tests. Other codes will be given if needed.
18Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Gray Code The Gray code is a 4-bit binary code (different from a BCD code in that it encodes all 16 4-bit combinations, not just 10 combinations).
This code is interesting in that successive code words only change by one bit.
This code is sometimes used with stepper motors. Each time the code increases, only one bit changes, and the stepper motor turns a specified amount (angle).
19Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Example: Show how a digital voltmeter would convert binary information into BCD format, including the use of binary-to-BCD converters and BCD-to-7-segment decoders.
Application: BCD codes are routinely used on equipment to display numerical values. Digital circuits work in binary, but people prefer to read numbers in base 10, so BCD codes are used to convert the data to base 10.
20Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Error Detection and Correction CodesExtra bits are often added to code words (using sometimes complex schemes) so that when the word is transmitted, the received can detect if errors occurred in the transmission and possibly correct some of the errors.
Parity – perhaps the simplest error detection code involves the addition of a parity bitDiscuss even parity vs odd parityExample: Show a BCD code with a trailing odd parity bit.
21Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Error Correction Codes – Error correction codes are designed such that the desired information can still be received even if some bits are incorrect. Error correction codes can be as simple as adding redundant bits or very complicated. Graduate courses are available on error detection and correction codes. Example: Shown below is a crude 2-bit code with extra bits added for error correction.
22Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Information to be encoded Code Distance to 010111
00 000000
01 000111
10 111000
11 111111
If the code was transmitted and 010111 was received, what is the most likely code that was sent?The “distance” between codes is the number of bits that differ.What is the distance between 010111 and each of the possible codes? (Fill out the 3rd column above.)This is a (6,2,1) code. It encodes 2 bits using 6 bits and can correct 1 error. Much better error correction codes are available!
Alphanumeric codesUsed to encode keyboard symbols and control characters.ASCII, EBCDIC, and Unicode are common alphanumeric codes.The ASCII code is shown below in Table 1-5 from the text.Since the ASCII code is a 7-bit code, a leading 0 bit or a parity bit can be added to form an 8-bit code (byte).Example: The ASCII code for letter Q is 1010001 (B7B6B5B4B3B2B1B0)The ASCII code can be shown as 10100012 = 8110 = 5116.
23Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Example: Write the word “Byte” (in binary and in hexadecimal) using an ASCII code with an even leading parity bit. Binary ASCII Code for Byte: _________ _________ _________ _________Hexadecimal ASCII Code for Byte: _________ _________ _________ _________
24Chapter 1 EGR 270 – Fundamentals of Computer Engineering
Alphanumeric codesASCII• 7 bits, 27 = 128 characters• With a leading 0, can be represented by 1 byte (two hexadecimal digits)• Example: 010000012 = 4116 = “A”EBCDIC• 8 bits, 28 = 256 charactersUnicode• An modern, industry-standard code that is used to encode most of the world’s
writing systems. It is used to encode symbols of various types, including over 120,000 characters from many languages and over 1 million code points.
• Each character has a unique number called a code point, which begins with U+ (for example, U+0054 represents the letter T using UTF-8)
• Can be implemented using different character encodings, including:• UTF-8: 1-4 bytes used for each code point• UTF-16: 2 or 4 bytes used for each code point• UTF-32: 4 bytes for each code point
25Chapter 1 EGR 270 – Fundamentals of Computer Engineering
UTF-8• UTF-8 is a character encoding for the Unicode that uses 1-4 bytes, depending on
code point range as shown in Table 1-6 from the text.• For bytes 2-4, the number of leading 1’s in the first byte corresponds to the total
number of bytes.
26Chapter 1 EGR 270 – Fundamentals of Computer Engineering
(2 leading 1’s then a 0 – 2 bytes)
(4 leading 1’s then a 0 – 4 bytes)(3 leading 1’s then a 0 – 3 bytes)
(leading 0 with 1 byte)
(always 10)
UTF-8• The total number of bits is represented by the x’s in the table below.
27Chapter 1 EGR 270 – Fundamentals of Computer Engineering
(7 bits)
(11 bits)
(16 bits)
(21 bits)
UTF-8• We can use the ASCII table (Table 1-5) for Unicodes in the range 00 – 7F, but
what about the other codes?• The website www.unicode.org/charts has extensive tables showing code points
for various languages and symbols. A small portion is shown below.• Go to the website and try it! Explore some of the tables.
28Chapter 1 EGR 270 – Fundamentals of Computer Engineering
29Chapter 1 EGR 270 – Fundamentals of Computer Engineering• Using the website www.unicode.org/charts , find the table for ASCII
Digits. Note that it is the same as Table 1-5 except that the values are in hexadecimal. What is the code point for the symbol $?
Symbol: $ASCII: 01001002 = 2416
Code Point: U+0024 (uses 1 byte since in the range 0000 0000 to 0000 007F)UTF binary: 00100100 (use 7 bits with a leading 0)UTF hexadecimal: 24
30Chapter 1 EGR 270 – Fundamentals of Computer Engineering• Using the website www.unicode.org/charts , find the table for Greek.
Part of the table is shown below. What is the code point for the Greek letter ?
Symbol: Code from Greek table: 03B116 or 0000 0011 1011 00012 Code Point: U+03B1 (uses 2 bytes and 11 bits since in the range 0000 0080 to 0000 07FF)Binary with 11 bits: 011 1011 0001UTF binary: 11001110 10110001 (note the leading 110 and 10)UTF hexadecimal: CE B1
31Chapter 1 EGR 270 – Fundamentals of Computer Engineering
• Using the website www.unicode.org/charts, you can also search the chart by hex code. Enter the hexadecimal code and select Go.
Example: What symbol corresponds to U+00B1 ?
U+00B1 corresponds to the symbol
32Chapter 1 EGR 270 – Fundamentals of Computer Engineering
U+00B1 corresponds to the symbol
By the way, what happens when you use Insert – Symbol in Word and you select the symbol?
The table above shows that the Character code is 177.Note that 17710 = B116, so it uses the Unicode!
33Chapter 1 EGR 270 – Fundamentals of Computer Engineering
https://en.wikipedia.org/wiki/UTF-8
Shown below is a nicely illustrate table from Wikipedia with additional UTF-8 examples:
34Chapter 1 EGR 270 – Fundamentals of Computer Engineering
What characters correspond to the following symbols?(Have students look them up using the website www.unicode.org/charts )Try to write one of them in UTF-8 (binary and hexadecimal form)
U+2B30
U+1F60A
U+1F050
U+1F0A3
U+1F35F