Cao Unit 1 Cao Notes
Cao Unit 1 Cao Notes
UNIT-1
SYLLABUS
Computer: Digital Computer is a fast electronic calculating machine that Accepts digitized input information,
processes it according to a list of internally stored instructions, And produces the resulting output information.
INPUT UNIT: Computer receives data and instructions through the input unit. Input unit consists of one or
more input devices.
Input device include:
1. Mouse
2. Keyboard
3. Joystick
OUTPUT UNIT: Computer provides information and results of computations to the outside world through the
output unit. Output unit consists of one or more output devices.
Output device include:
FUNCTIONS OF CPU:
It performs all calculations.
It takes all decisions.
It controls all units of the computer.
CONTROL UNIT:
It controls all units of the computer.
STORAGE UNIT:
The storage unit of the computer holds data and instructions that are entered through the input unit,
before they are processed. Storage devices are divided into two categories:
Primary memory or main memory
Secondary memory
Those are
1. Desktop
2. Note Book
3. Workstations
4. Mainframes
5. Servers
6. Supercomputer
Desktop: It has
Processing & Storage units (e.g., Hard disks, CD‐ROMs),
Servers:
Contain big database storage units.
Handles large volumes of data requests
Requests and responses are transported via Internet
They are widely accessible to all.
Supercomputers:
Faster than mainframes
Helps in large scale numerical calculations
Used for aircraft design and testing, military
application, weather forecasting, etc.
Generations of computers:
There are 5 generations of computers
1.First generation (1946 -1957)
2. Second generation (1958 -1964)
3. Third generation (1965 -1971)
4. Fourth generation (1972 -1977)
5. Fifth generation (1978 -onward)
First generation (1946 -1957): First generation computers
use Vacuum tubes; Magnetic tape drives and magnetic core
memories were developed. Its size was too much large. This
was very hard to read and write programs
Advantages:
It was only electronic device
First device to hold memory
Downloaded by Harpreet Singh (happy04cheema@gmail.com)
lOMoARcPSD|53928134
Disadvantages:
Large in size
Vacuum tubes burn frequently
There were producing heat
Maintenance problems
Second generation (1958 -1964): Second generation
computers use Transistors instead of Vacuum tubes.
Storage capacity of computer also increase
Advantages:
Size reduced considerably
They are fast
Very much reliable
Disadvantages:
They are over heated
Maintenance problems
Third generation (1965 -1971): Third generation
computers use ICs instead of Transistors. Which is
combination of number of transistors and other electronic
components fused together on single crystal.
Advantages:
ICs are very small in size
Improved performance
Production cost cheap
Disadvantages:
ICs are sophisticated
Computer Design: Is concerned with the h/w design of the computer. That is, it is concerned
with the determination of what h/w should be used and how the parts should be connected.
Once the computer specifications are formulated, it is the task of the
designer to develop h/w for the system
NOTE: All students of computing should acquire some understanding and appreciation of a
computer system’s functional components, their characteristics, their performance, and their
interactions. There are practical implications as well. Students need to understand computer
architecture in order to structure a program so that it runs more efficiently on a real machine.
In selecting a system to use, they should be able to understand the tradeoff among various
components, such as CPU clock speed vs. memory size.
R2 ← R4
BLOCK DIAGRAM OF A REGISTER:
Often, we want the transfer to occur only under a predetermined control condition.
if (p=1) then (R2 ←R1)
where 8p9 is a control signal generated in the control section.
In digital systems, this is often done via a control signal, called a control function
3 If the signal is 1, the action takes place
• This is represented as:
P: R2 ← R1
• The same clock controls the circuits that generate the control function and the destination register
• Registers are assumed to use positive-edge-triggered flip-flops
SIMULTANEOUS OPERATIONS: If two or more operations are to occur simultaneously, they are separated
with commas
P: R3← R5, MAR ← IR
• Here, if the control function P = 1, load the contents of R5 into R3, and at the same time (clock), load the
contents of register IR into register MAR
BUS AND MEMORY TRANSFERS A more efficient scheme for transferring information between
registers in a multiple-registerconfiguration is a Common Bus System.
A bus consists of a set of a common lines, one for each bit of reregister through
which binary information is transferred one at a time. Control signals determine
which reregister is selected by the bus during a particular register transfer.Different ways of constructing a
common bus system
Using Multiplexers
Using Tri-state Buffers
Downloaded by Harpreet Singh (happy04cheema@gmail.com)
lOMoARcPSD|53928134
common bus system with Multiplexers: The Multiplexers in common bus system select one of many
registers as the source register whose binary information is then placed on the bus using select inputs.
The bus consists of four 4 x 1 multiplexers each having four data inputs, 0 through 3, and two
BUS TRANSFER IN RTL: Depending on whether the bus is to be mentioned explicitly or not, register transfer
can be indicated as either
R2 ←R1
or
BUS ←R1, R2 ←BUS
• In the former case the bus is implicit, but in the latter, it is explicitly indicated
Tri-state Buffers: Tri state buffer is a logic circuit element that has 3 states
0,1 and high impedance (output is disconnected)
The high impedance states behave like an open circuit and does not have logic significance.
Because of this feature, a large number of three-state gate outputs can be connected with wires to
form a common bus line without endangering loading effects.
ARITHMETIC MICROOPERATIONS:
Computer system micro-operations are of four types:
Register transfer micro-operations transfer binary information from one register to another
Arithmetic micro-operations perform arithmetic operations on Numeric data stored in registers.
Logic micro-operations perform bit manipulation operations on Non numeric data stored in
registers.
Shift micro-operations perform shift operations on data stored in Registers.
R3 ← R1 + R2 Contents of R1 plus R2
transferred to R3
R3 ←R1 - R2 Contents of R1 minus R2
transferred to R3
R2 ←R2’ Complement the contents
of R2
R2 ← R2’+ 1 2's complement the
contents of R2 (negate)
R3 ←R1 + R2’+ 1 subtraction
R1 ← R1 + 1 Increment
R1 ← R1 - 1 Decrement
The arithmetic Micro-operation defined by the statement below specifies the add micro-operation.
R3 ← R1 + R2
It states that the contents of R1 are added to contents of R2 and sum is transferred to R3.
To implement this statement hardware requires 3 registers and digital component that performs
addition
Subtraction is most often implemented through complementation and addition.
The subtract operation is specified by the following statement
R3 ← R1 + R2 + 1
instead of minus operator, we can write as
Binary Adder:
Digital circuit that forms the arithmetic sum of 2 bits and the previous carry is called FULL ADDER.
Digital circuit that generates the arithmetic sum of 2 binary numbers of any lengths is called
BINARY ADDER.
Figure shows the interconnections of four full-adders (FA) to provide a 4-bit binary adder.
The augends bits of A and the addend bits of B are designated by subscript numbers from right to
left, with subscript 0 denoting the low-order bit.
The carries are connected in a chain through the full-adders. The input carry to the binary adder
is Co and the output carry is C4. The S outputs of the full-adders generate the required sum bits.
An n-bit binary adder requires n full-adders.
The addition and subtraction operations can be combined into one common circuit by including an
exclusive-OR gate with each full-adder.
A 4-bit adder-sub tractor circuit is shown in Fig
The mode input M controls the operation. When M = 0 the circuit is an adder and when M = 1 the circuit
becomes a sub tractor.
Each exclusive-OR gate receives input M and one of the inputs of B
When M = 0, we have B xor 0 = B. The full-adders receive the value of B, the input carry is 0, and
the circuit performs A plus B.
When M = 1, we have B xor 1 = B' and Co = 1.
The B inputs are all complemented and a 1 is added through the input carry.
The circuit performs the operation A plus the 2's complement of B.
Binary Incrementor:
The increment micro-operation adds one to a number in a register.
For example, if a 4-bit register has a binary value 0110, it will go to 0111 after it is incremented.
This can be accomplished by means of half-adders connected in cascade.
The diagram of a 4-bit 'combinational circuit incrementor is shown in Fig.
One of the inputs to the least significant half-adder (HA) is connected to logic-1 and the other input is
connected to the least significant bit of the number to be incremented.
The output carry from one half-adder is connected to one of the inputs of the next-higher-order
half-adder.
The circuit receives the four bits from A0 through A3, adds one to it, and generates the
incremented output in S0 through S3.
The output carry C4 will be 1 only after incrementing binary 1111. This also causes outputs S0
through S3 to go to 0.
The circuit of Fig. can be extended to an n -bit binary incremented by extending the diagram to include n
half-adders.
The least significant bit must have one input connected to logic-1. The other inputs receive the number
to be incremented or the carry from the previous stage.
Arithmetic Circuit:
By controlling the data inputs to the adder, it is possible to obtain different types of arithmetic
operations.
The diagram of a 4-bit arithmetic circuit is shown in Fig. It has four full-adder circuits that constitute
the 4-bit adder and four multiplexers for choosing different operations.
The four inputs from A go directly to the X inputs of the binary adder.
Each of the four inputs from B are connected to the data inputs of the multiplexers.
The other two data inputs are connected to logic-0 and logic-1.
The four multiplexers are controlled by two selection inputs S 1 and S0. The input carry Cin, goes to the carry
input of the FA in the least significant position. The other carries are connected from one stage to the next.
By controlling the value of Y with the two selection inputs S 1 and S0 and making Cin equal to 0 or 1, it is
possible to generate the eight arithmetic micro-operations listed in Table
Addition:
When S1S0= 00, the value of B is applied to the Y inputs of the adder.
Subtraction:
When S1S0 = 01, the complement of B is applied to the Y inputs of the adder.
If Cin = 1, then D = A + B + 1. This produces A plus the 2's complement of B, which
is equivalent to a subtraction of A -B.
When Cin = 0 then D = A + B. This is equivalent to a subtract with borrow, that is,
A-B-1.
Increment:
When S1S0 = 10, the inputs from B are neglected, and instead, all 0's are inserted into the Y inputs. The
output becomes D = A + 0 + Ci;n. This gives D = A when Cin = 0 and D = A + 1 when Cin = 1.
In the first case we have a direct transfer from input A to output D.
In the second case, the value of A is incremented by 1.
Decrement:
When S1S0= 11, all l's are inserted into the Y inputs of the adder to produce the decrement
operation D = A -1 when Cin = 0.
This is because a number with all 1's is equal to the 2's complement of 1 (the 2's complement of
binary 0001 is 1111). Adding a number, A to the 2's complement of 1 produces F = A + 2's complement
of 1 = A 4 1. When Cin = 1, then D = A -1 + 1=A, which causes a direct transfer from input A to output
D.
Logic Micro-operations:
Logic microoperations specify binary operations for strings of bits stored in registers.
Downloaded by Harpreet Singh (happy04cheema@gmail.com)
lOMoARcPSD|53928134
These operations consider each bit of the register separately and treat them as binary variables.
For example, the exclusive-OR microoperation with the contents of two registers RI and R2 is
symbolized by the statement
It specifies a logic microoperation to be executed on the individual bits of the registers provided
that the control variable P = 1.
There are 16 different logic operations that can be performed with two binary variables.
They can be determined from all possible truth tables obtained with two binary variables as
shown in Table
The 16 Boolean functions of two variables x and y are expressed in algebraic form in the first
column of Table.
The 16 logic microoperations are derived from these functions by replacing variable x by the
binary content of register A and variable y by the binary content of register B.
The logic micro-operations listed in the second column represent a relationship between the
binary content of two registers A and B.
Hardware Implementation:
The hardware implementation of logic microoperations requires that logic gates be inserted for
each bit or pair of bits in the registers to perform the required logic function.
Although there are 16 logic microoperations, most computers use only four--AND, OR, XOR
(exclusive-OR), and complement from which all others can be derived.
Figure shows one stage of a circuit that generates the four basic logic microoperations.
It consists of four gates and a multiplexer. Each of the four logic operations is generated through a
gate that performs the required logic.
The outputs of the gates are applied to the data inputs of the multiplexer. The two selection inputs S1 and S0
choose one of the data inputs of the multiplexer and direct its value to the output
Some
Applications:
Logic micro-operations are very useful for manipulating individual bits or a portion of a word stored
in a register.
They can be used to change bit values, delete a group of bits or insert new bits values into a register.
The following example shows how the bits of one register (designated by A) are manipulated by
logic microoperations as a function of the bits of another register (designated by B).
Selective set
The selective-set operation sets to 1 the bits in register A where there are corresponding l's in
register B. It does not affect bit positions that have 0's in B. The following numerical example clarifies
this operation:
Selective complement
The selective-complement operation complements bits in A where there are corresponding 1's
in B. It does not affect bit positions that have 0's in B. For example:
Insert
The insert operation inserts a new value into a group of bits. This is done by first masking
the bits and then ORing them with the required value.
For example, suppose that an A register contains eight bits, 0110 1010. To replace the four
leftmost bits by the value 1001 we first mask the four unwanted bits:
The
mask
operation is
an AND
Clear
The clear operation compares the words in A and B and produces an all 0's result if the two
numbers are equal. This operation is achieved by an exclusive-OR microoperation as shown by
the following example
Shift Microoperations:
Shift micro-operations are used for serial transfer of data.
The contents of a register can be shifted to the left or the right.
During a shift-left operation the serial input transfers a bit into the rightmost position.
During a shift-right operation the serial input transfers a bit into the leftmost position.
There are three types of shifts: logical, circular, and arithmetic.
The symbolic notation for the shift micro-operations is shown in Table
Hardware Implementation:
The shift micro operations are often performed in a separate unit, but sometimes the shift unit is
made part of the overall ALU.
The arithmetic, logic, and shift circuits introduced in previous sections can be combined into one
ALU with common selection variables. One stage of an arithmetic logic shift unit is shown in Fig..
Particular micro operation is selected with inputs S1 and S0. A 4 x 1 multiplexer at the output
chooses between an arithmetic output in Di and a logic output in Ei.
The data in the multiplexer are selected
with inputs S3 and S2. The other two data
inputs to the multiplexer receive inputs Ai-
1 for the shift-right operation and Ai+1 for
the shift-left operation.
The circuit whose one stage is specified
in Fig. provides eight arithmetic
operation, four logic operations, and two
shift operations.
Each operation is selected with the five
variables S3, S2, S1, S0 and Cin.
The input carry Cin is used for selecting
an arithmetic operation only.
Table lists the 14 operations of the ALU. The first eight are arithmetic operations and are
Basic Computer Organization and Design:
STORED PROGRAM ORGANIZATION: A computer instruction is often divided into two parts
An opcode (Operation Code) that specifies the
operation for that instruction
instruction’s opcode
Indirect address: the address in memory of the address in memory of the data to use
• TIMING AND CONTROL: Control unit (CU) of a processor translates from machine instructions to
the control signals for the microoperations that implement them
• Control units are implemented in one of two ways
• Hardwired Control
3 CU is made up of
sequential and
combinational circuits to
generate the control
signals
Microprogrammed Control
3 A control memory on the
processor contains
microprograms that
activate the necessary
control signals
Example:
INSTRUCTION CYCLE: In Basic Computer, a machine instruction is executed in the following cycle:
1. Fetch an instruction from memory
2. Decode the instruction
3. Read the effective address from memory if the instruction has an indirect address
4. Execute the instruction
After an instruction is executed, the cycle starts again at step 1, for the next instruction
I 000~110 Address
The effective address of the instruction is in the address register AR and was placed
there during timing signal T2 when I = 0, or during timing signal T3 when I = 1.
The execution of the memory-reference instructions starts with timing signal T4.
AND to AC
This is an instruction that performs the AND logic operation on pairs of bits in AC and the memory word
specified by the effective address. The result of the operation is transferred to AC.
D0T4: DR←M[AR]
D0T5: AC ← AC ← DR, SC ← 0
ADD to AC
This instruction adds the content of the memory word specified by the effective address to the value of AC.
The sum is transferred into AC and the output carry Cout is transferred to the E (extended accumulator) flip-
flop.
D1T4: DR←M[AR]
D1T5: AC ←AC + DR, E ← Cout, SC 0
LDA: Load to AC
This instruction transfers the memory word specified by the effective address to AC.
D2T4: DR ← M[AR]
D2T5: AC ← DR, SC ← 0
STA: Store AC
This instruction stores the content of AC into the memory word specified by the effective address.
D3T4: M[AR] ← AC, SC ← 0
BUN: Branch Unconditionally
This instruction transfers the program to instruction specified by the effective address. The BUN instruction
allows the programmer to specify an instruction out of sequence and the program branches (or jumps)
unconditionally.
D4T4: PC ← AR, SC ← 0
BSA: Branch and Save Return Address
This instruction is useful for branching to a portion of the program called a subroutine or procedure. When
executed, the BSA instruction stores the address of the next instruction in sequence (which is available in PC)
into a memory location specified by the effective address.
M[AR] ← PC, PC ← AR + 1 M[135] ←21, PC ←135 + 1 =136
It is not possible to perform the operation of the BSA instruction in one clock cycle when we use the bus
system of the basic computer. To use the memory and the bus properly, the BSA instruction must be executed
with a sequence of two microoperations:
D5T4:M[AR] ← PC, AR←AR + 1 D5T5: PC ←AR, SC ← 0
ISZ: Increment and Skip if Zero
These instruction increments the word specified by the effective address, and if the incremented value is equal
to 0, PC is incremented by 1. Since it is not possible toincrement a word inside the memory, it is necessary to
read the word into DR, increment DR, and store the word back into memory.
D6T4:DR ← M[AR] D6T5:DR←DR + 1
D6T4:M[AR] ← DR, if (DR = 0) then (PC ← PC + 1), SC ← 0
Downloaded by Harpreet Singh (happy04cheema@gmail.com)
lOMoARcPSD|53928134
Control Flowchart
The terminal sends and receives serial information and each quantity of information has
eight bits of an alphanumeric code.
The serial information from the keyboard is shifted into the input register INPR.
The serial information for the printer is stored in the output register OUTR.
These two registers communicate with a communication interface serially and with the
AC in parallel.
The transmitter interface receives serial information from the keyboard and transmits it to
INPR. The receiver interface receives information from OUTR and sends it to the printer
serially.
The 1-bit input flag FGI is a control flip-flop. It is set to 1 when new information is available
in the input device and is cleared to 0 when the information is accepted by the computer.
The flag is needed to synchronize the timing rate difference between the input device
and the computer.
The process of information transfer is as follows:
Input-Output instructions
Input and output instructions are needed for transferring information to and from AC
register, for checking the flag bits, and for controlling the interrupt facility.
Input-output instructions have an operation code 1111 and are recognized by the control
when D7 = 1 and I = 1.
The remaining bits of the instruction specify the particular operation.
The control functions and microoperations for the input-output instructions are listed
below.
INP Input char. to AC
AC(0-7) INPR, FGI 0
OUT Output char. from AC
OUTR AC(0-7), FGO 0
SKI Skip on input flag
if(FGI = 1) then (PC PC + 1)
SKO Skip on output flag
if(FGO = 1) then (PC PC + 1)
ION Interrupt enable on
IEN 1
IOF Interrupt enable off
IEN 0
Table: Input Output Instructions
The INP instruction transfers the input information from INPR into the eight low-order
bits of AC and also clears the input flag to 0.
The OUT instruction transfers the eight least significant bits of AC into the output
register OUTR and clears the output flag to 0.
The next two instructions in Table 2.2 check the status of the flags and cause a skip of
the next instruction if the flag is 1.
The instruction that is skipped will normally be a branch instruction to return and check
the flag again.
The branch instruction is not skipped if the flag is 0. If the flag is 1, the branch instruction
is skipped and an input or output instruction is executed.
The last two instructions set and clear an interrupt enable flip-flop IEN. The purpose of
IEN is explained in conjunction with the interrupt operation.
Interrupt Cycle
The way that the interrupt is handled by the computer can be explained by means of theflowchart shown in figure
An interrupt flip-flop R is included in the computer.
When R = 0, the computer goes through an instruction cycle.
During the execute phase of the instruction cycle IEN is checked by the control.
If it is 0, it indicates that the programmer does not want to use the interrupt, so control
continues with the next instruction cycle.
If IEN is 1, control checks the flag bits.
If both flags are 0, it indicates that neither the input nor the output registers are readyfor
transfer of information.
In this case, control continues with the next instruction cycle. If either flag is set to 1
while IEN = 1, flip-flop R is set to 1.
At the end of the execute phase, control checks the value of R, and if it is equal to 1, it
goes to an interrupt cycle instead of an instruction cycle.