CO Module1
CO Module1
(S3CCSI02)
Module-1
Dr.Kallinatha H D
Assistant Professor
Dept. of CSE
SIT
• Computer: It is a fast electronic calculating machine that accepts digitized input information,
processes it according to the list of internally stored instructions & produces the resulting output
information. The list of internally stored instructions is called as a Computer program & internal
storage is called as Computer memory.
• Functional units: A computer consists of five functionally independent parts: Input, output,
ALU, memory & control units
Input Unit
• Computers reads the data through input unit.
• The most common Input devices are Keyboard, joystick, trackballs, microphone and mouse
• When a key is pressed (keyboard), corresponding letter/digit is translated into its corresponding
binary code and transmitted over a cable to either the memory or the processor.
Alphanumeric characters are also expressed in the form binary codes. Two commonly used
codes are:
• ASCII (American Standard code for Information Interchange)
• EBCDIC ( Extended Binary-Coded Decimal Interchange Code)
Memory Unit
• Function: is to store programs and data
• There are 2 classes of storage:
• Primary/Main memory (RAM, cache memory)
• Secondary (ROM, flash drives, hard disk drives, magnetic tapes)
• Primary Storage
• Fast memory that operates at electronic speeds
• The memory contains a large number of semiconductor storage cells, each capable of storing 1 bit
of information
• These cells are processed in groups of fixed size called word
• The number of bits in each word is known as word length
• Range from 16 to 64 bits
• Word size desribe the no. of bits of data processed by the microprocessor in one go (at a time)
(Modern Computers: 32/64 bits).
Memory Hierarchy
Memory Unit
• Any operation is initiated by bringing the required operands into the processor, where the
operation is performed by the ALU (Data transfer b/w memory & processor)
• Suppose two numbers located in the memory are to be added. They are brought into the
processor, and the actual addition is carried out by the ALU. The sum may then be stored in the
memory or retained in the processor for immediate use.
• When operands are brought into the processor, they are stored in high- speed storage elements
called registers. Each register can store one word of data
Control Unit
• The memory, arithmetic and logic, and input and output units store and process information and
perform input and output operations. The operation of these units is coordinated by control
unit.
• The control unit is effectively the nerve center that sends control signals to other units and senses
their states.
• It directs the operation of the other units by providing timing and control signals.
• Timing signals are signals that determine when a given action is to take place.
• Control signals supervise execution of the instructions
Output Unit
• Counterpart of Input unit
• Its function is to send processed results to outside world
• The familiar example of output device is printer (various types), monitor, speakers
Operation of a Computer - Summarized
• The computer accepts information in the form of pgms & data through an
input unit & stores it in the memory
• Information stored in the memory is fetched, under pgm control, into an ALU,
where it is processed
• All activities inside the machine are directed by the Control Unit
9
Basic Operational Concepts
The information handled by a computer may be either instruction or data.
Data are the numbers and encoded characters that are used as operands by the
instructions.
Basic Operational Concepts
Consider the instruction Add LOCA, R0
This instruction adds the operand at memory location LOCA to the operand in a register in
the processor, R0, and places the sum into register R0.
• Transfers between the memory and the processor are started by sending the address of
the memory location to be accessed to the memory unit and issuing the appropriate
control signals. The data are then transferred to or from the memory.
Connection between the processor and memory
Control
Unit
Arithmetic
Logic Unit
In addition to the ALU and the control circuitry, the processor contains a number of registers used for
several different purposes.
• PC (program counter)
• Keeps track of the execution of a program
• Contains the memory address of next instruction to be fetched & executed
• IR (instruction register)
• Holds the instruction that is currently being executed
• Its o/p is available to control circuits, which generate the timing signals that control the various
processing elements involved in executing the instruction
MOVE 1000
NUM1,R1 1001
1009
5 1010
• Fetch • Decode • Execute
• MAR [PC] • MAR NUM1
• PC [PC] + 1 • MDR [MEM([MAR])]
• MDR [MEM([MAR])] • R1 [MDR]
• IR [MDR]
18
Another Example
ADD #1,R1
• Fetch • Execute
• MAR [PC] • R1 1 + [R1]
• PC [PC] + 1
• MDR [MEM([MAR])]
• IR [MDR]
19
Bus Structures
• Bus: Set of wires/lines, that interconnects all the components (subsystems) of a
computer
• In addition to the lines that carry the data, the bus must have lines for address and
control information.
Single Bus Structure
All units are connected to the same bus. Since the bus can be used for only one
transfer at a time, only two units can actively use the bus at any given time.
Bus Structures
Single Bus Structure
Advantages:
• Simple
• Low cost
• Flexibility to attach peripheral devices.
Disadvantages:
Disadvantages:
• Complex
• Costlier
Bus Structures
• The devices connected to a bus vary widely in their speed of operation.
• Some electromechanical devices, such as keyboards and printers, are relatively slow.
• Others, like magnetic or optical disks, are considerably faster.
• Results in
• Timing differences among processors, memories, and I/O devices.
• High-speed processor being locked to a slow I/O device during a sequence of data transfers.
• Solution- To smooth out the differences in timing among processors, memories, and external devices -
buffer registers are used
. 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.
• The length P of one clock cycle is an important parameter that affects processor performance. Its
inverse is the clock rate,
R = 1/ P, which is measured in cycles per second.
Example
Note
BASIC PERFORMANCE EQUATION
T=(N*S)/R
T-processor time required to execute a program
N-actual number of machine instruction executions
S-Avg. Number of basic steps needed to execute one machine instruction
R- clock rate (R cycles per second)
To achieve high performance, the computer designer must seek ways to reduce the value
of T, which means reducing N and S, and increasing R.
• The value of N is reduced if the 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 or if the execution of instructions is overlapped.
• Using a higher-frequency clock increases the value of R, which means that the time
required to complete a basic execution step is reduced.
Clock Rate
T=(N*S)/R
• First, improving the integrated-circuit (IC) technology makes logic circuits faster, which reduces the time
needed to complete a basic step. This allows the clock period, P, to be reduced and the clock rate, R, to be
increased.
• Second, reducing the amount of processing done in one basic step also makes it possible to reduce the
clock period, P. However, if the actions that have to be performed by an instruction remain the same; the
number of basic steps needed may increase.
PERFORMANCE MEASUREMENT
• But computing the value of T is not simple. Parameters such as the clock speed (R) and
various architectural features are not reliable indicators of the expected performance.
• The program is compiled for the computer under test, and the running time on a real
computer is measured. The same program is also compiled and run on one computer
selected as a reference.
PERFORMANCE MEASUREMENT
• SPEC rating of 50 means that the computer under test is 50 times faster than the reference
computer. The test is repeated for all the programs in the SPEC suite, and the geometric mean of
the results is computed.
• SPEC rating is a measure of the combined effect of all the factors affecting performance, including
the compiler, the operating system, the processor, and the memory of the computer being tested
Note:
RISC (Reduced Instruction Set Computer) Architectures
CISC (Complex Instruction Set Computer) Architectures
2.The effective value of S for a RISC machine is 1.2 and for CISC is 1.5. Both machines have the
same clock rate R. The time for execution on CISC machine is to be no longer than that of RISC
machine. For this to happen, what is the largest allowable value for N, i.e., no. of instructions
executed on CISC machine expressed as a percentage of N value for the RISC machine.
No. of instructions executed on CISC machine is 80% of the no. of instructions executed on
RISC machine.
3.Assuming that the reference computer is Ultra SPARC10 workstation with 300 MHz Ultra
SPARC processor. A company has to purchase 1000 new computers, hence ordered testing
of new computers with SPEC 2000. Following observations were made:
• The company system manager will place the order for purchasing new computers only if
the overall SPEC rating is at least 12. After the said test, will system manager place order
for purchase of new computer?
11.70
Since overall SPEC rating is 11.70, the purchase order will not be placed.
4.List the steps needed to execute the machine instruction Add LOCA,R0 in terms of transfers between the
components of the processor and some control commands. Assume that the instruction itself is stored in the
memory at location INSTR and that this address is initially in register PC. Also include the steps needed to
update the contents of PC from INSTR to INSTR+1 so that the next instruction can be fetched.
There is a 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
The sum of 1 and 1 requires the 2-bit vector 10 to represent the value 2. We say that the sum
is 0 and the carry-out is 1.
ADDITION AND SUBTRACTION OF SIGNED NUMBERS
N = 16.
addition of +7 to -3.
1. To add two numbers, add their n-bit representations, ignoring the carry-out
signal from the most significant bit (MSB) position. The sum will be the
algebraically correct value in the 2’s-complement representation as long as the
answer is in the range -2^n-1 through +2^n-1 – 1
EX: (-2^4-1 to +2^4-1 -1 = -8 to +7).
The rules for addition and subtraction of n-bit signed numbers using the 2’s-complement
recomplement representation system are:
• In 1's there is a -0 (1111) and a +0 (0000), i.e two value for the same 0. On the other hand, in
2's complement, there is only one value for 0 (0000).
• While doing arithmetic operations like addition or subtraction using 1's, we have to add an
extra carry bit, i.e 1 to the result to get the correct answer, +7 (0111) add -7 (1000) = 1111
+1 =0000
• 4 bit number system, the range of numbers that can be represented is -8 through +7. If
the result of an arithmetic operation is outside the representable range, then we say that
arithmetic overflow has occurred.
• Thus, overflow may occur if both summands have the same sign. Clearly, the addition of
numbers with different signs cannot cause overflow.
• We say that the word locations have aligned addresses. In general, 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.
• In general, the number of bytes in a word is a power of 2. Hence, if the word length
is 16 (2 bytes), aligned words begin at byte addresses 0, 2, 4, 6. . . , and for a word
length of 64 (2^3 bytes), aligned words begin at byte addresses 0, 8, 16, . . . .
• If words begin at an arbitrary byte address then they are said to have unaligned
addresses.
MEMORY OPERATIONS
• Both program instructions and data operands are stored in the memory.
• To execute an instruction by processor control circuits - transfer is required between memory to the
processor.
• Two basic operations involving the memory are Load (or Read or Fetch) and Store (or Write).
Load operation
• Transfers a copy of the contents of a specific memory location to the processor. The memory
contents remain unchanged.
• To start a Load operation, the processor sends the address of the desired location to the memory and
requests that its contents be read. The memory reads the data stored at that address and sends them to
the processor.
Store operation
• Transfers an item of information from the processor to a specific memory location, destroying the
initial contents of that location.
• The processor sends the address of the desired location to the memory, together with the data to be
written into that location.
INSTRUCTIONS AND INSTRUCTION SEQUENCING
The instruction set provides commands to the processor, to tell it what it needs to do.
A computer must have instructions capable of performing four types of operations: (Instruction Set
Architecture)
• MOVE NUM1,R1
• R1 [NUM1]
• MOVE #1,R2 • R2 1
• ADD #1,R1 • R1 1 + [R1]
• If k bits are needed to specify the memory address of each operand, the encoded form of the above
instruction must contain 3k bits for addressing purposes in addition to the bits needed to denote the
Add operation.
Example X=(A+B)(C+D)
ADD A, B,T1 M[A]+M[B] →M[T1]
ADD C, D, T2 M[C]+M[D] → M[T2]
MUL T1, T2,X M[T1]+M[T2] → M[X]
Two-address instruction:
• Format: Operation Source, Destination
Example X=(A+B)(C+D)
• LD A M[A] → AC
• ADD B ACC+M[B] → AC
• ST X AC→ M[X]
• LD C M[C] → AC
• ADD D AC+M[D] → AC
• MUL X AC*M[X] → AC
• ST X AC → M[X]
Zero-address instruction
• Stack architecture
• store operands in a structure called a pushdown stack
C=A+B
PUSH A
PUSH B
ADD
POP C
Zero-address instruction
Example X=(A+B)(C+D)
• PUSH AM[A] → TOS
• PUSH BM[B] → TOS
• ADD TOS+TOS-1 → TOS
• PUSH CM[C] → TOS
• PUSH D M[D] → TOS
• ADD TOS+TOS-1 → TOS
• MUL TOS*TOS-1 → TOS
• POP X TOS → M[X]
Branch>0 LOOP
causes a branch to location LOOP if the result of the immediately preceding instruction,
which is the decremented value in register R1, is greater than zero.
CONDITION CODES
• Condition code flags in a processor register – status register or condition code
register
Condition code register or status register
• Keeps track of information about the results of various operations for use by subsequent
conditional branch instructions
• Condition code flags are set to 1 or cleared to 0, depending on the outcome of the
operation performed.
Four commonly used flags are
CONDITION CODES
status register
Problems
• Represent -29 using 6 bits in all three representation systems. Convert the following pair of
decimal numbers to 7-bit, signed 2’s-complement binary numbers and perform subtraction
operation on them. Also, state whether overflow occurs or not.
Sign-and-Magnitude System: 111101
1’s-complement system: 100010
2’s-complement system: 100011
1001000 (-56)
+ 1011110 (-34 in 2's complement)
------------
1 0100110
Problems
• Give the significance of the four commonly used condition code flags.
Also, find the status of each of these flags after the addition of the
numbers -5 and -4 in a 4-bit, signed 2’s-complement system.