Computer Hardware and Text Representation
Computer Hardware and Text Representation
CSE 101
By Dawit Zenebe
Mekelle Institute of Technology
2014/2015
By Dawit Zenebe
Chapter 3
Introduction to CPU
CPU
Central processing unit etched on silicon chip
called microprocessor.
A microprocessor incorporates the functions of
By Dawit Zenebe
a computer's central processing unit (CPU) on a
single integrated circuit (IC).
The microprocessor is
multipurpose, programmable device that
accepts digital data as input, processes it according
to instructions stored in its memory, and provides 2
results as output.
Microprocessors operate on numbers and symbols
represented in the binary numeral system.
It is an example of sequential digital logic, as it has
internal memory. Microprocessors operate on
numbers and symbols represented in the binary
numeral system.
By Dawit Zenebe
Before microprocessors, small computers had
been implemented using racks of circuit boards
with many medium- and small-scale integrated
circuits.
Microprocessors integrated this into one or a
few large-scale ICs. 3
Types of Processors
The most common type of processors are
common desktop processors, such as Intel's
Pentium or AMD's Athlon.
Less common are the extremely powerful
By Dawit Zenebe
processors used in high-end servers, such as
Sun's SPARC, IBM's Power, or Intel's Itanium.
microprocessors have come in "standard sizes"
of 8 bits, 16 bits, 32 bits, and 64 bits.
The number of bits represent how much
4
physical memory can be directly addressed by
the CPU.
Continued--
It also represents the amount of bits that can be
read by one read/write operation.
8 bit processors can read/write 1 byte at a time and
can directly address 256 bytes
16 bit processors can read/write 2 bytes at a time,
By Dawit Zenebe
and can address 65,536 bytes (64 Kilobytes)
32 bit processors can read/write 4 bytes at a time,
and can address 4,294,967,295 bytes (4 Gigabytes)
64 bit processors can read/write 8 bytes at a time,
and can address 18,446,744,073,709,551,616 bytes
5
(16 Exabytes)
Bits and Bytes
What is a "bit"?
A bit is the smallest possible piece of information.
If you have heard someone say that "everything in
the computer is all one's and zero's," they are
actually referring to bits.
By Dawit Zenebe
A bit can have only two possible states: 1 or 0.
As humans, we may find it useful to think of this in
terms of "yes or no," "true or false," "on or off,"
and so on.
They all mean the same thing. The key is that
6
there are only two possibilities, and nothing in
between.
What is a "byte"?
Although a single bit can have only one of two
possible values, by gathering groups of bits
together, we can make much more complicated
(and interesting) information.
A byte is simply a group of 8 bits. How many
different possible values can a byte have? There
By Dawit Zenebe
turns out to be a simple way of calculating this:
1 bit --> 2^1 = 2 different possible values
2 bits --> 2^2 (2x2) = 4 different possible values
3 bits --> 2^3 (2x2x2) = 8 different possible
values
8 bits (one byte) --> 2^8 (2x2x2x2x2x2x2x2) 7
= 256 possibilities
CPU Registers
A processor register is a very fast computer
memory used to speed the execution of computer
programs by providing quick access to commonly
used values-typically, the values being in the midst
By Dawit Zenebe
of a calculation at a given point in time.
These registers are the top of the memory
hierarchy, and are the fastest way for the system to
manipulate data.
8
By Dawit Zenebe
9
Types of registers:
(a) Accumulator: It is most frequently used register
used to store data taken from memory. Its number
varies from microprocessor to microprocessor.
(b) General Purpose registers: General purpose
registers are used to store data and intermediate
By Dawit Zenebe
results during program execution. Its contents can be
accessed through assembly programming.
(c) Special purpose Registers: Users do not access
these registers. These are used by computer system
at the time of program execution. :
10
Some types of special purpose registers
1. Memory Address Register (MAR): It stores address
of data or instructions to be fetched from memory.
2. Memory Buffer Register (MBR): It stores
instruction and data received from the memory and
By Dawit Zenebe
sent from the memory.
3. Instruction Register (IR): Instructions are stored in
instruction register. When one instruction is
completed, next instruction is fetched in memory for
processing.
4. Program Counter (PC): It counts instructions. 11
The instruction cycle is completed into two phases:
(a) Fetch Cycle and (b) Execute Cycle.
By Dawit Zenebe
Registers and Cache memory?
13
Answer
The registers are the places where the
values that the CPU is actually working on
are located.
The CPU design is such that it is only able to
actually modify or otherwise act on a value
By Dawit Zenebe
when it is in a register. So registers can work
logic, whereas Cache memory can only hold
values the CPU reads from and writes to.
14
Example: how register logic works.
Let's imagine we have four registers named R1..R4. If you
compile a statement that looks like this:
X = Y + Z * 3;
The compiler would output machine code that looks something
like this:
BDawit Zenebe
1. LOAD R1, ADDRESS_Z // move the value of z into register 1
2. MUL R1, 3 // multiply the value of register 1 by 3
3. LOAD R2, ADDRESS_Y // move the value of y into register 2
4. ADD R1, R2 // adds the value in R2 to the value in R1
5. STORE R1, ADDRESS_X // move the value of register 1 into
x
15
Microprocessor Speeds
Measure of system clock speed
• How many electronic pulses the clock produces per
second
• Usually expressed in gigahertz (GHz)
By Dawit Zenebe
• Billions of machine cycles per second
• Some old PCs measured in megahertz (MHz)
Comparison of clock speed only meaningful
between identical microprocessors
CPU cycle time – inverse of clock rate
16
Clock Rates
Microprocessors are typically discussed in terms of
their clock speed.
The clock speed is measured in hertz (or
megahertz, or gigahertz).
A hertz is a "cycle per second".
By Dawit Zenebe
Each cycle, a microprocessor will perform certain
tasks, although the amount of work performed in a
single cycle will be different for different types of
processors.
The amount of work that a processor can complete
17
in a single cycle is measured in "cycles per
instruction".
The clock rate is equated as such:
By Dawit Zenebe
A computer with a 1MHz clock rate will have a
clock time of 1 microsecond.
A modern desktop computer with a 3.2 GHz
processor will have a clock time of approximately
3× 10-10 seconds, or 300 picoseconds.
300 picoseconds is an incredibly small amount of 18
time, and there is a lot that needs to happen inside
the processor in each clock cycle.
Current Technology Capabilities
and Limitations
• Moore’s Law
• Rate of increase in transistor density on
microchips doubles every 18-24 months with
By Dawit Zenebe
no increase in unit cost
• Rock’s Law
• Cost of fabrication facilities for chip generation
doubles every four years
19
Introduction to Numbering Systems
– Binary Base 2
– Octal Base 8
– Hexadecimal Base 16
Significant Digits
Binary: 11101101
Hexadecimal: 1D63A7A
000 0 20 1
001 1 21 2
010 2 22 4
011 3 23 8
100 4 24 16
101 5 25 32
110 6 26 64
111 7 27 128
Binary Addition
4 Possible Binary Addition Combinations:
(1) 0 (2) 0
+0 +1 Note that leading
zeroes are frequently
Carry 00 Sum 01 dropped.
(3) 1 (4) 1
+0 +1
01 10
Decimal to Binary Conversion
• The easiest way to convert a decimal number to its
binary equivalent is to use the Division Algorithm
• This method repeatedly divides a decimal number
by 2 and records the quotient and remainder
– The remainder digits (a sequence of zeros and ones)
form the binary equivalent in least significant to most
significant digit sequence
Division Algorithm
Convert 67 to its binary equivalent:
6710 = x2
Step 1: 67 / 2 = 33 R 1 Divide 67 by 2. Record quotient in next row
1 0 0 0 0 1 12
Binary to Decimal Conversion
• The easiest method for converting a binary
number to its decimal equivalent is to use
the Multiplication Algorithm
• Multiply the binary digits by increasing
powers of two, starting from the right
• Then, to find the decimal number
equivalent, sum those products
Multiplication Algorithm
Convert (10101101)2 to its decimal equivalent:
Binary 1 0 1 0 1 1 0 1
x x x x x x x x
Positional Values 27 26 25 24 23 22 21 20
Products 128 + 32 + 8 + 4 + 1
17310
Octal Number System
• Also known as the Base 8 System
• Uses digits 0 - 7
• Readily converts to binary
• Groups of three (binary) digits can be used
to represent each octal digit
• Also uses multiplication and division
algorithms for conversion to and from base
10
Decimal to Octal Conversion
Convert 42710 to its octal equivalent:
6538
Octal to Decimal Conversion
Convert 6538 to its decimal equivalent:
Octal Digits 6 5 3
x x x
Positional Values
82 81 80
Products 384 + 40 + 3
42710
Octal to Binary Conversion
Each octal number converts to 3 binary digits
6 5 3
33E16
Hexadecimal to Decimal Conversion
Convert 3B4F16 to its decimal equivalent:
Hex Digits 3 B 4 F
x x x x
Positional Values
163 162 161 160
Products 12288 +2816 + 64 +15
15,18310
Binary to Hexadecimal Conversion
• The easiest method for converting binary to
hexadecimal is to use a substitution code
• Each hex number converts to 4 binary digits
Substitution Code
Convert 0101011010101110011010102 to hex using
the 4-bit substitution code :
5 6 A E 6 A
56AE6A16
Substitution Code
Substitution code can also be used to convert binary to
octal by using 3-bit groupings:
2 5 5 2 7 1 5 2
010 101 101 010 111 001 101 010
255271528
Complementary Arithmetic
• 1’s complement
– Switch all 0’s to 1’s and 1’s to 0’s
Binary # 10110011
1’s complement 01001100
Complementary Arithmetic
• 2’s complement
– Step 1: Find 1’s complement of the number
Binary # 11000110
1’s complement 00111001
– Step 2: Add 1 to the 1’s complement
00111001
+ 00000001
00111010
Signed Magnitude Numbers
110010.. …00101110010101
0 = positive
1 = negative This is your basic
Integer format
Floating Point Numbers
• Real numbers must be normalized using
scientific notation:
Digital
10110010…
camera
Examples of Standards
Type of Data Standards
Alphanumeric ASCII, EBCDIC, Unicode