Unit 2 - Co
Unit 2 - Co
UNIT 2
Register Transfer
Computer registers are designated by capital letters (sometimes followed by numerals)
to denote the function of the register.
For example:
MAR: memory address register
PC: program counter
IR: instruction register
R1: processor register
Information transfer from one register to another is designated in symbolic form by means
of a replacement operator. The statement:
𝑅2 ← 𝑅1
Denotes a transfer of the content of register Rl into register R2. It designates a replacement
of the content of R2 by the content of Rl. By definition, the content of the source register Rl
does not change after the transfer.
If we want the transfer to occur only under a predetermined control condition. This can
be shown by means of an if-then statement.
𝐼𝑓(𝑃 = 1)𝑡ℎ𝑒𝑛(𝑅2 ← 𝑅1)
where P is a control signal generated in the control section. It is sometimes convenient to
separate the control variables from the register transfer operation control function by specifying
a control function.
𝑃: 𝑅2 ← 𝑅1
The control condition is terminated with a colon. It symbolizes the requirement that the
transfer operation be executed by the hardware only if P = 1.
To separate two or more operations that is executed at the same time by using the comma as
the statement:
𝑇: 𝑅2 ← 𝑅1, 𝑅5 ← 𝑅3
The basic symbols of the register transfer notation are listed in Table (1) Registers are
denoted by capital letters, and numerals may follow the letters. Parentheses are used to denote a
part of a register by specifying the range of bits or by giving a symbol name to a portion of a
register.
The table(2) shows the register that is selected by the bus for each of the four possible
binary values of the selection lines.
The symbolic statement for a bus transfer may mention the bus or its presence may be
implied in the statement. When the bus is includes in the statement, the register transfer is
symbolized as follows:
𝐵𝑢𝑠 ← 𝐶 , 𝑅1 ← 𝐵𝑢𝑠
The content of register C is placed on the bus, and the content of the bus is loaded
into register Rl by activating its load control input. If the bus is known to exist in the
system, it may be convenient just to show the direct transfer.
𝑅1 ← 𝐶
A bus system can be constructed with three-state gates. The graphic symbol of a three-
state buffer gate is shown:
To construct a common bus for four registers of n bits each using three-state buffers, we need n
circuits with four buffers in each as shown in Fig(4). Each group of four buffers receives one
significant bit from the four registers.
The transfer of information from a memory word to the outside environment is called a
read operation. The transfer of new information to be stored into the memory is called a write
operation. Consider a memory unit that receives the address from a register, called the address
register, symbolized by AR. The data are transferred to another register, called the data register,
symbolized by DR.
𝑅𝑒𝑎𝑑: 𝐷𝑅 ← 𝑀[𝐴𝑅]
The write operation transfers the content of a data register to a memory word M
selected by the address.
𝑊𝑟𝑖𝑡𝑒: 𝑀[𝐴𝑅]← 𝐷𝑅
Arithmetic Microoperations
The multiply and divide are not listed in Table(3), these two operations are valid
arithmetic operations but are not included in the basic set of microoperations. In most computers,
Varun Dalli Computer Organization
Unit 2
the multiplication operation is implemented with a sequence of add and shift microoperations.
Division is implemented with a sequence of subtract and shift microoperations.
The digital circuit that generates the arithmetic sum of two binary numbers of any length is called
a binary adder as shown in Fig(5).
The addition and subtraction operations can be combined into one common circuit by including
an exclusive-OR gate with each full-adder as shown in Fig(6).
The increment microoperation 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. The diagram of a 4- bit
combinational circuit incrementer is shown in Fig(7):
The arithmetic microoperations listed in the Table above can be implemented in one composite
arithmetic circuit. The basic component of an arithmetic circuit is the parallel adder. By
controlling the data inputs to the adder, it is possible to obtain different types of arithmetic
operations as shown in Fig(8).
Logic Microoperations
Logic microoperations specify binary operations for strings of bits stored in registers.
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 Rl and R2 is
symbolized by the statement:
𝑃: 𝑅1 ← 𝑅1 ⊕ 𝑅2
It specifies a logic microoperation to be executed on the individual bits of the registers provided
that the control variable P = 1. As a numerical example, assume that each register has four bits.
Let the content of Rl be 1010 and the content of R2 be 1100. The exclusive-OR microoperation
stated above symbolizes the following logic computation:
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(5):
The 16 Boolean functions of two variables x and y are expressed in algebraic form in the first
column of Table(6):
The diagram shows (Fig 9-a) one typical stage with subscript i. For a logic circuit with n bits,
the diagram must be repeated n times for i = 0,1, 2,..., n - 1. The selection variables are applied
to all stages. The function table in Fig.(9-b) lists the logic microoperations obtained for each
combination of the selection variables.
Shift Microoperations
Shift microoperations are used for serial transfer of data. The contents of a register can be
shifted to the left or the right. There are three types of shifts: logical, circular, and arithmetic.
The symbolic notation for the shift microoperations is shown in Table (7):
An arithmetic shift is a microoperation that shifts a signed binary number to the left or
right. The arithmetic shift-left inserts a 0 into R0, and shifts all other bits to the left. The initial
bit of Rn-1 is lost and replaced by the bit from Rn-2 . A sign reversal occurs if the bit in Rn-1
changes in value after the shift and caused an overflow.
The arithmetic shift-right leaves the sign bit unchanged and shifts the number (including the
sign bit) to the right.
Ex: If the content of 8 bits register is (10100011). What is the result of the operation after
executing to the register:
a. shl R: shift left register by 3. b. cil R : circular shift left register by 3.
c. ashl R: arithmetic shift left register by 3. d. ashr R: arithmetic shift right register by 3.
Ans:
(a) 00011000. (b) 00011101. (c) 00011000. Overflow (d) 11110100
Instruction Codes
A computer instruction is a binary code that specifies a sequence of microoperations for
the computer. Instruction codes together with data are stored in memory. The computer reads
each instruction from memory and places it in a control register. The control then interprets the
binary code of the instruction and proceeds to execute it by issuing a sequence of
microoperations. Every computer has its own unique instruction set. The ability to store and
execute instructions, the stored program concept, is the most important property of a general-
purpose computer. An instruction code is a group of bits that instruct the computer to perform a
specific operation. It is usually divided into parts, each having its own particular interpretation.
The most basic part of an instruction code is its operation part. The operation code of an
instruction is a group of bits that define such operations as add, subtract, multiply, shift, and
complement. The number of bits required for the operation code of an instruction depends on
the total number of operations available in the computer.
The simplest way to organize a computer is to have one processor register and an
instruction code format with two parts. The first part specifies the operation to be performed and
the second specifies an address. The memory address tells the control where to find an operand
in memory. This operand is read from memory and used as the data to be operated on together
with the data stored in the processor register.
For a memory unit with 4096 words we need 12 bits to specify an address since 212=
4096. If we store each instruction code in one 16-bit memory word, we have available four bits
for the operation code (abbreviated opcode) to specify one out of 16 possible operations, and 12
bits to specify the address of an operand. The control reads a 16-bit instruction from the program
portion of memory. It uses the 12-bit address part of the instruction to read a 16-bit operand
from the data portion of memory. Fig(12) depicts this type of organization.
Computers that have a single-processor register usually assign to it the name accumulator and
label it AC.
For example, operations such as clear AC, complement AC, and increment AC operate on data
stored in the AC register.
When the second part of an instruction immediate code specifies an operand, this type is called
immediate operand. When the second part specifies the address of an operand, the instruction
is said to have a direct address. The third possibility called indirect address, where the bits in
the second part of the instruction designate an address of a memory word in which the address
of the operand is found. One bit of the instruction code can be used to distinguish between a
direct and an indirect address.
As an illustration of this configuration, consider the instruction code format shown in Fig(13).
Computer Registers
Computer instructions are normally stored in consecutive memory locations and are
executed sequentially one at a time. The control reads an instruction from a specific address in
memory and executes it. It then continues by reading the next instruction in sequence and
executes it, and so on. This type of instruction sequencing needs a counter to calculate the
address of the next instruction after execution of the current instruction is completed. The
computer needs processor registers for manipulating data and a register for holding a memory
address. These requirements dictate the register configuration are listed in Table(9) and shown
in Fig(14).
The basic computer has eight registers, a memory unit, and a control unit. The connection
of the registers and memory of the basic computer to a common bus system is shown in Fig(15).
Two registers, AR and PC, have 12 bits each since they hold a memory address. When
the contents of AR or PC are applied to the 16-bit common bus, the four most significant bits
are set to 0's. When AR or PC receive information from the bus, only the 12 least significant
bits are transferred into the register.
The input register INPR and the output register OUTR have 8 bits each and communicate
with the eight least significant bits in the bus. The INPR receives a character from an input
device which is then transferred to AC. OUTR receives a character from AC and delivers it to
an output device. There is no transfer from OUTR to any of the other registers.
Five registers have three control inputs: LD (load), INR (increment), and CLR (clear).
Computer Instructions
The basic computer has three instruction code formats, as shown in Figure. Each format
has 16 bits.
The type of instruction is recognized by the computer control from the four bits in
positions 12through 15 of the instruction. If the three opcode bits in positions 12 through 14 are
not equal to 111, the instruction is a memory-reference type and the bit in position 15 is taken
as the addressing mode J. If the 3-bit opcode is equal to 111, control then inspects the bit in
position 15. If this bit is 0, the instruction is a register-reference type. If the bit is 1, the
instruction is an input-output type. Note that the bit in position 15 of the instruction code is
designated by the symbol J but is not used as a mode bit when the operation code is equal to
111.
The instructions for the computer are listed in Table(10):
The set of instructions are said to be complete if the computer includes a sufficient
number of instructions in each of the following categories:
1. Arithmetic, logical, and shift instructions.
2. Instructions for moving information to and from memory and processor registers.
3. Instructions that check status information to provide decision making capabilities.
4. Input and output instructions.
5. The capability of stopping the computer.
SC is incremented with every positive clock transition, unless its CLR input is active.
This produces the sequence of timing signals T0, T1, T2, T3, T4, and so on, as shown in the
diagram. (Note the relationship between the timing signal and its corresponding positive
clock transition.) If SC is not cleared, the timing signals will continue with T 5, T6, up to T15
and back to T0.
As an example, consider the case where SC is incremented to provide timing signals T 0, T1
T2, T3, and T4 in sequence. At time T4, SC is cleared to 0 if decoder output D3 is active. This
is expressed symbolically by the statement
𝐷3𝐷4: 𝐷𝐷 ← 0
Instruction Cycle
A program residing in the memory unit of the computer consists of a sequence of
instructions. The program is executed in the computer by going through a cycle for each
instruction. In the basic computer each instruction cycle consists of the following phases:
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.
This process continues indefinitely unless a HALT instruction is encountered. Initially, the
program counter PC is loaded with the address of the first instruction in the program. The
sequence counter SC is cleared to 0, providing a decoded timing signal T0. After each clock
pulse, SC is incremented by one, so that the timing signals go through a sequence T 0, T1, T2,
and so on. The microoperations for the fetch and decode phases can be specified by the
following register transfer statements.
𝑇0: 𝐴𝑅 ←𝑃𝐶
𝑇1 : 𝐼𝑅 ← 𝑀[𝐴𝑅], 𝑃𝐶 = 𝑃𝐶 + 1
𝑇2: 𝐷0, , , , 𝐷7 ← 𝐷𝑒𝑐𝑜𝑑𝑒 𝐼𝑅(12 − 14), 𝐴𝑅 ← 𝐼𝑅(0 − 11), 𝐼 ← 𝐼𝑅(15)
It is necessary to use timing signal T1 to provide the following connections in the bus system.
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 in Table(12). These instructions
are executed with the clock transition associated with timing signal T3.
Consider a computer that can go through an instruction cycle in 1µs. Assume that the
input-output device can transfer information at a maximum rate of 10 characters per second.
This is equivalent to one character every 100,000µs. Two instructions are executed when the
computer checks the flag bit and decides not to transfer the information. This means that at the
maximum rate, the computer will check the flag 50,000 times between each transfer. The
computer is wasting time while checking the flag instead of doing some other useful processing
task.
The way that the interrupt is handled by the computer can be explained by means of the
flowchart of Fig(19). An interrupt flip-flop R is included in the computer.
In order to design the logic associated with AC, it is necessary to go over the
register transfer statements and extract all the statements that change the content
of AC.