COA Module 1 BEC306C
COA Module 1 BEC306C
MODULE 1
Basic Structure of Computers: Computer Types, Functional Units, Basic Operational Concepts, Bus
Structures, Software, Performance -Processor Clock, Basic Performance
Equation(upto1.6.2ofChap1ofText).
Machine Instructions and Programs: Numbers, Arithmetic Operations and Characters, IEEE standard
for Floating point Numbers, Memory Location and Addresses, Memory Operations, Instructions and
Instruction Sequencing (up to 2.4.6 of Chap 2 and 6.7.1 of Chap 6 of Text).
BASIC CONCEPTS
• Computer Architecture (CA) is concerned with the structure and behaviour of the computer.
• CA includes the information formats, the instruction set and techniques for addressing memory.
• In general covers, CA covers 3 aspects of computer-design namely: 1) Computer Hardware, 2)
Instruction set Architecture and 3) Computer Organization.
1. Computer Hardware
It consists of electronic circuits, displays, magnetic and optical storage media and
communication facilities.
2. Instruction Set Architecture
It is programmer visible machine interface such as instruction set, registers, memory
organization and exception handling.
Two main approaches are 1) CISC and 2) RISC.
(CISCComplex Instruction Set Computer, RISCReduced Instruction Set Computer)
3. Computer Organization
It includes the high level aspects of a design, such as
→ memory-system
→ bus-structure &
→ design of the internal CPU.
It refers to the operational units and their interconnections that realize the architectural
specifications.
It describes the function of and design of the various units of digital computer that store and
process information.
FUNCTIONAL UNITS
• A computer consists of 5 functionally independent main parts:
1) Input
2) Memory
3) ALU
4) Output &
5) Control Units
Input Unit
Computers accept coded information through input units. The most common input device is the
keyboard. Whenever a key is pressed, the corresponding letter or digit is automatically translated into its
corresponding binary code and transmitted to the processor.
Many other kinds of input devices for human-computer interaction are available, including the touchpad,
mouse, joystick, and trackball. These are often used as graphic input devices in conjunction with
displays.
Microphones can be used to capture audio input which is then sampled and converted into digital codes
for storage and processing.
Similarly, cameras can be used to capture video input.
Digital communication facilities, such as the Internet, can also provide input to a computer from other
computers and database servers.
Memory Unit
The function of the memory unit is to store programs and data. There are two classes of storage, called
primary and secondary.
Primary Memory
Primary memory, also called main memory, is a fast memory that operates at electronic speeds.
Programs must be stored in this memory while they are being executed. The memory consists of a large
number of semiconductor storage cells, each capable of storing one bit of information. These cells are
rarely read or written individually.
Instead, they are handled in groups of fixed size called words. The memory is organized so that one
word can be stored or retrieved in one basic operation. The number of bits in each word is referred to as
the word length of the computer, typically 16, 32, or 64 bits.
To provide easy access to any word in the memory, a distinct address is associated with each word
location. Addresses are consecutive numbers, starting from 0, that identify successive locations.
Instructions and data can be written into or read from the memory under the control of the processor. A
memory in which any location can be accessed in a short and fixed amount of time after specifying its
address is called a random-access memory (RAM). The time required to access one word is called the
memory access time. This time is independent of the location of the word being accessed. It typically
ranges from a few nanoseconds (ns) to about 100 ns for current RAM units
Cache Memory
As an adjunct to the main memory, a smaller, faster RAM unit, called a cache, is used to hold sections of
a program that are currently being executed, along with any associated data. The cache is tightly coupled
with the processor and is usually contained on the same integrated-circuit chip. The purpose of the cache
is to facilitate high instruction execution rates.
At the start of program execution, the cache is empty. As execution proceeds, instructions are fetched
into the processor chip, and a copy of each is placed in the cache. When the execution of an instruction
requires data, located in the main memory, the data are fetched and copies are also placed in the cache.
If these instructions are available in the cache, they can be fetched quickly during the period of repeated
use.
Secondary Storage
Although primary memory is essential, it tends to be expensive and does not retain information when
power is turned off. Thus additional, less expensive, permanent secondary storage is used when large
amounts of data and many programs have to be stored, particularly for information that is accessed
infrequently. Access times for secondary storage are longer than for primary memory. The devices
available are including magnetic disks, optical disks (DVD and CD), and flash memory devices.
Output Unit
Output unit function is to send processed results to the outside world. A familiar example of such a
device is a printer. Most printers employ either photocopying techniques, as in laser printers, or ink jet
streams. Such printers may generate output at speeds of 20 or more pages per minute. However, printers
are mechanical devices, and as such are quite slow compared to the electronic speed of a processor.
Some units, such as graphic displays, provide both an output function, showing text and graphics, and an
input function, through touch screen capability. The dual role of such units is the reason for using the
single name input/output (I/O) unit in many cases.
Control Unit
The memory, arithmetic and logic, and I/O units store and process information and perform input and
output operations. The operation of these units must be coordinated in some way. This is the
responsibility of the control unit. The control unit is effectively the nerve center that sends control
signals to other units and senses their states.
I/O transfers, consisting of input and output operations, are controlled by program instructions that
identify the devices involved and the information to be transferred.
Control circuits are responsible for generating the timing signals that govern the transfers. They
determine when a given action is to take place. Data transfers between the processor and the memory are
also managed by the control unit through timing signals. A large set of control lines (wires) carries the
signals used for timing and synchronization of events in all units.
BUS STRUCTURE
• A bus is a group of lines that serves as a connecting path for several devices.
• A bus may be lines or wires.
• The lines carry data or address or control signal.
• There are 2 types of Bus structures: 1) Single Bus Structure and 2) Multiple Bus Structure.
1) Single Bus Structure
Because the bus can be used for only one transfer at a time, only 2 units can actively use the
bus at any given time.
Bus control lines are used to arbitrate multiple requests for use of the bus.
Advantages:
1) Low cost &
2) Flexibility for attaching peripheral devices.
2) Multiple Bus Structure
Systems that contain multiple buses achieve more concurrency in operations.
Two or more transfers can be carried out at the same time.
Advantage: Better performance.
Disadvantage: Increased cost.
Note:
Explanation similar to functional unit
Software
System software is a collection of programs that are executed as needed to perform functions:
Receiving and interpreting user commands
Entering and editing application programs and storing them as files in secondary storage devices
Managing the storage and retrieval of files in secondary storage devices
Running standard application programs such as word processors, spreadsheets, or games, with data supplied
by the user
Controlling I/O units to receive input information and produce output results
Translating programs from source form prepared by the user into object form consisting of machine
instructions
Linking and running user-written application programs with existing standard library routines, such as
numerical computation packages.
System software is responsible for the coordination of all activities in a computing system.
Application programs are usually written in a high-level programming language, such as C, C++, Java, or
Fortran
Independent of the particular computer used to execute the program.
A programmer using a high-level language need not know the details of machine program instructions.
Compiler translates the high-level language program into a suitable machine language program.
Text editor - used for entering and editing application programs.
File - a sequence of alphanumeric characters or binary data that is stored in memory or in secondary storage.
Operating system - a large program, or actually a collection of routines, that is used to control the sharing of
and interaction among various computer units as they execute application programs.
Consider a system with one processor, one disk, and one printer.
Assume that the application program has been compiled from a high-level language form into a machine language
form and stored on the disk.
PERFORMANCE
• The most important measure of performance of a computer is how quickly it can execute programs.
• The speed of a computer is affected by the design of
1) Instruction-set.
2) Hardware & the technology in which the hardware is implemented.
3) Software including the operating system.
• Because programs are usually written in a HLL, performance is also affected by the compiler that
translates programs into machine language. (HLL High Level Language).
• For best performance, it is necessary to design the compiler, machine instruction set and hardware ina co-
ordinate way.
examine the flow of program instructions and data between the memory & the processor.
• At the start of execution, all program instructions are stored in the main-memory.
• As execution proceeds, instructions are fetched into the processor, and a copy is placed in the cache.
• Later, if the same instruction is needed a second time, it is read directly from the cache.
• A program will be executed faster
if movement of instruction/data between the main-memory and the processor is minimized
which is achieved by using the cache.
PROCESSOR CLOCK
• Processor circuits are controlled by a timing signal called a Clock.
• The clock defines regular time intervals called Clock Cycles.
• To execute a machine instruction, the processor divides the action to be performed into a sequence
of basic steps such that each step can be completed in one clock cycle.
• Let P = Length of one clock cycle
R = Clock rate.
• Relation between P and R is given by
------(1)
• Equ1 is referred to as the basic performance equation.
• To achieve high performance, the computer designer must reduce the value of T, which means
reducing N and S, and increasing R.
The value of N is reduced if source program is compiled into fewer machine instructions.
The value of S is reduced if instructions have a smaller number of basic steps to perform.
The value of R can be increased by using a higher frequency clock.
• Care has to be taken while modifying values since changes in one parameter may affect the other.
CLOCK RATE
• There are 2 possibilities for increasing the clock rate R:
1) Improving the IC technology makes logic-circuits faster.
This reduces the time needed to compute a basic step. (IC integrated circuits).
This allows the clock period P to be reduced and the clock rate R to be increased.
2) Reducing the amount of processing done in one basic step also reduces the clock period P.
• In presence of a cache, the percentage of accesses to the main-memory is small.
Hence, much of performance-gain expected from the use of faster technology can be realized.
The value of T will be reduced by same factor as R is increased „.‟ S & N are not affected.
Problem 1:
List the steps needed to execute the machine instruction:
Load R2, LOC
in terms of transfers between the components of processor and some simple control commands.
Assume that the address of the memory-location containing this instruction is initially in register PC.
Solution:
1. Transfer the contents of register PC to register MAR.
2. Issue a Read command to memory.
And, then wait until it has transferred the requested word into register MDR.
3. Transfer the instruction from MDR into IR and decode it.
4. Transfer the address LOCA from IR to MAR.
5. Issue a Read command and wait until MDR is loaded.
6. Transfer contents of MDR to the ALU.
7. Transfer contents of R0 to the ALU.
8. Perform addition of the two operands in the ALU and transfer result into R0.
9. Transfer contents of PC to ALU.
10. Add 1 to operand in ALU and transfer incremented address to PC.
Problem 2:
List the steps needed to execute the machine instruction:
Add R4, R2, R3
in terms of transfers between the components of processor and some simple control commands.
Assume that the address of the memory-location containing this instruction is initially in register PC.
Solution:
1. Transfer the contents of register PC to register MAR.
2. Issue a Read command to memory.
And, then wait until it has transferred the requested word into register MDR.
3. Transfer the instruction from MDR into IR and decode it.
4. Transfer contents of R1 and R2 to the ALU.
5. Perform addition of two operands in the ALU and transfer answer into R3.
6. Transfer contents of PC to ALU.
7. Add 1 to operand in ALU and transfer incremented address to PC.
Problem 3:
(a) Give a short sequence of machine instructions for the task “Add the contents of memory-location A
to those of location B, and place the answer in location C”. Instructions:
Load Ri, LOC
and
Store Ri, LOC
are the only instructions available to transfer data between memory and the general purpose registers.
Add instructions are described in Section 1.3. Do not change contents of either location A or B.
(b) Suppose that Move and Add instructions are available with the formats:
Move Location1, Location2
and
Add Location1, Location2
These instructions move or add a copy of the operand at the second location to the first location,
overwriting the original operand at the first location. Either or both of the operands can be in the
memory or the general-purpose registers. Is it possible to use fewer instructions of these types to
accomplish the task in part (a)? If yes, give the sequence.
Solution:
(a)
Load A, R0
Load B, R1
Add R0, R1
Store R1, C
(b) Yes;
Move B, C
Add A, C
We need to represent both positive and negative numbers. Three systems are used for
representing such numbers:
• Sign-and-magnitude
• 1‟s-complement
• 2‟s-complement
In all three systems, the leftmost bit is 0 for positive numbers and 1 for negative numbers.
Assumptions:
4-bit machine word
16 different values can be represented
Roughly half are positive, half are negative
BYTE-ADDRESSABILITY
• In byte-addressable memory, successive addresses refer to successive byte locations in the memory.
• Byte locations have addresses 0, 1, 2. . . . .
• If the word-length is 32 bits, successive words are located at addresses 0, 4, 8. . with each word
having 4 bytes.
Consider a 32-bit integer (in hex): 0x12345678 which consists of 4 bytes: 12, 34, 56, and 78.
Hence this integer will occupy 4 bytes in memory.
Assume, we store it at memory address starting 1000.
On little-endian, memory will look like
Address Value
1000 78
1001 56
1002 34
1003 12
WORD ALIGNMENT
• Words are said to be Aligned in memory if they begin at a byte-address that is a multiple of the
number of bytes in a word.
• For example,
If the word length is 16(2 bytes), aligned words begin at byte-addresses 0, 2, 4 . . . . .
If the word length is 64(2 bytes), aligned words begin at byte-addresses 0, 8, 16 . . . . .
• Words are said to have Unaligned Addresses, if they begin at an arbitrary byte-address.
To retrieve information from memory, either for one word or one byte (8-bit), addresses for each location are
needed.
A k-bit address memory has 2k memory locations, namely 0 – 2 k -1, called memory space.
24-bit memory: 224 = 16,777,216 = 16M (1M=220)
32-bit memory: 232 = 4G (1G=230)
1K(kilo)=210
1T(tera)=240
MEMORY OPERATIONS
• Two memory operations are:
1) Load (Read/Fetch) &
2) Store (Write).
• The Load operation transfers a copy of the contents of a specific memory-location to the processor.
The memory contents remain unchanged.
• Steps for Load operation:
1) Processor sends the address of the desired location to the memory.
2) Processor issues „read‟ signal to memory to fetch the data.
3) Memory reads the data stored at that address.
4) Memory sends the read data to the processor.
• The Store operation transfers the information from the register to the specified memory-location.
This will destroy the original contents of that memory-location.
• Steps for Store operation are:
1) Processor sends the address of the memory-location where it wants to store data.
2) Processor issues „write‟ signal to memory to store the data.
3) Content of register(MDR) is written into the specified memory-location.
Program Explanation
• Consider the program for adding a list of n numbers (Figure 2.9).
• The Address of the memory-locations containing the n numbers are symbolically given as NUM1,
NUM2…..NUMn.
• Separate Add instruction is used to add each number to the contents of register R0.
• After all the numbers have been added, the result is placed in memory-location SUM.
BRANCHING
• Consider the task of adding a list of „n‟ numbers (Figure 2.10).
• Number of entries in the list „n‟ is stored in memory-location N.
• Register R1 is used as a counter to determine the number of times the loop is executed.
• Content-location N is loaded into register R1 at the beginning of the program.
• The Loop is a straight line sequence of instructions executed as many times as needed.
The loop starts at location LOOP and ends at the instruction Branch>0.
• During each pass,
→ address of the next list entry is determined and
→ that entry is fetched and added to R0.
• The instruction Decrement R1 reduces the contents of R1 by 1 each time through the loop.
• Then Branch Instruction loads a new value into the program counter. As a result, the processor
fetches and executes the instruction at this new address called the Branch Target.
• A Conditional Branch Instruction causes a branch only if a specified condition is satisfied. If the
condition is not satisfied, the PC is incremented in the normal way, and the next instruction in
sequential address order is fetched and executed.
CONDITION CODES (To understand better refer class notes we solved problems)
• The processor keeps track of information about the results of various operations. This is accomplished
by recording the required information in individual bits, called Condition Code Flags.
• These flags are grouped together in a special processor-register called the condition code register (orstatue
register).
• Four commonly used flags are:
1) N (negative) set to 1 if the result is negative, otherwise cleared to 0.
2) Z (zero) set to 1 if the result is 0; otherwise, cleared to 0.
3) V (overflow) set to 1 if arithmetic overflow occurs; otherwise, cleared to 0.
4) C (carry) set to 1 if a carry-out results from the operation; otherwise cleared to 0.
IEEE Standard for Floating-point Numbers (For problem refer class notes)
Second, as computations proceed, a number that does not fall in the represent able range of normal numbers
might be generated.
Overflow
Special value
The end values 0 and 255 of the excess-127 exponent 𝐸′ are used to represent special values. When 𝐸′ = 0
and 𝑀 = 0, the value 0 is represented.
When 𝐸′ = 255 and 𝑀 = 0, the value ∞ is represented.
When 𝐸′ = 0 and 𝑀 ≠ 0, denormal numbers are represented.
When 𝐸′ = 255 and 𝑀 ≠ 0, the value represented is called Not a Number (NaN).
1. (88.125) =?
2. (32.134)=?
3. (0.065)=?