Professional Documents
Culture Documents
Q2. Fetching and decoding of any instruction takes three clock cycles.
How?
Ans:-
1. The computer memory: since the program is stored there, as is the data
2. The Address and Data buses: since copies of the instructions are stored
in memory but must be decoded in the CPU. Similarly any Data needed must be
transferred to a Register in the CPU
3. The CPU:
§ Program Counter (PC) holds the address the next instruction in memory
§ General Purpose registers hold the data (if any) on which the instruction
will operate
o The Control Unit – here logic decodes the instruction OpCode and
identifies what should happen during execution (The PC and the IR are in the
Control Unit)
o The ALU executes the decoded instructions on the data in the Register (if
any)
Fetch
· The CPU communicates this address over the address bus to main
memory, with signals indicating it needs the instruction stored at that address
(This activates the Memory location) (1 clock cycle)
· Main memory then transmits the instruction along the data bus to the
CPU (The Control Unit sends a READ signal) (another clock cycle)
· Sometimes several fetch steps may be required to get all the parts of a
specific instruction ( for example the instruction may act on specific data which
also needs to be recovered from memory in separate clock cycles (another 2
clock cycles)
Decoding
what kind of action needs to take place (Links the OpCode in the
Instruction Register to electronic circuitry inside the ALU) This
Opcode is a part of the Instruction Set for the CPU
if data is being used, where does the computer obtain that data (eg.
Which register)
Where should the result be sent (same or another register ?)
Execution
· Once an instruction has been fetched and decoded, it can be carried out
(or executed) in the Arithmetic Logic Unit
· These instructions are carried out at an electronics level within the ALU
T0
T1
T2
T3
T4
D3
CLR
SC
(i) It consist of a 3 bit operation code,12 bit address , and an indirect address
mode bit designated by” I” .the mode bit is 0 for a direct address and 1 is for
indirect address. A direct bit address instruction is shown in fig (b) it is placed
in address 22 in memory . the I bit is 0, so the address is considered as direct
address instruction format, the op code specifies th add operation .the address
part is the binary eqivalent of 457. the control finds the operand in memeory at
address 457 and adds it to the content AC.
(ii)The instruction in address 35 shown in fig(c) has amode bit I =1 therefore it
is considered as indirect address instruction. The address part is binary
equuivalent of 300.the control goes to the address 300 to find the address of the
operand. The address of the operand in this case is 1350.the operand found at
address 1350 is added to the content AC.
(a)
15 14 12 11 0
I OPCODE ADDRESS
(b)
15 14 12 11 0
I 111 Register reference
(c)
15 14 12 11 0
I 111 I/O reference
Micro programmed control is better than hardwired here are some reasons why
it is better than hardwired.
routine
->Process interrupt
->Restore context and continue interrupted
program
Open communication only when some data has to be passed --> interrupt.
- The I/O interface, instead of the CPU, monitors the I/O device.
- When the interface founds that the I/O device is ready for data transfer, it
generates an interrupt request to the CPU
- Upon detecting an interrupt, the CPU stops
momentarily the task it is doing, branches to the service
routine to process the data transfer, and then returns to
the task it was performing.