Chapter 3
Chapter 3
1 1 0 TR
1 1 1 Memory
• The particular register whose LD (Load) input is enabled receives the data from the bus
during the next clock pulse transition. The memory receives the contents of the bus when
its write input is activated.
• The memory places its 16 bit output onto the bus when the read input is activated and
the value of S2, S1, and S0 is 111.
• Four registers DR, AC, IR and TR have 16 bits each and two registers AR and PC have 12
bits each since they hold a memory address.
• When the content of AR and PC are applied to the 16-bit common bus, the four MSBs are
set to 0’s.
• When AR and 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.
• INPR is connected to provide information to the bus but OUTR can only receive
information from the bus.
• Five registers have three control inputs: LD (load), INR (increment) and
CLR(Clear).
• Two registers have only a LD input.
• AR must always be used to specify memory address; therefore memory
address is connected to AR. The 16 inputs of AC come from an Adder and Logic
Circuit. This circuit has three inputs.
• Set of 16- bit inputs come from the outputs of AC.
• Set of 16-bit inputs come from the data register DR.
• Set of 8-bit inputs come from the input register INPR.
• The result of an addition is transferred to AC and the end carry out of
the addition is transferred to flip flop E (extended AC-bit).
• The clock transition at the end of the cycle transfers the content of
the bus into the designated destination register and the output of the
adder and logic circuit into AC.
3.3 Basic Computer Instructions
The basic computer has 3 instruction code formats. Type of the
instruction is recognized by the computer control from 4-bit positions
12 through 15 of the instruction.
• Memory-Reference Instructions
• Register-Reference Instructions
• Input-Output Instructions
1. Memory-Reference Instructions:
2. Register-Reference Instructions
3. Input-Output Instructions
Instruction Set Completeness
An instruction set is said to be complete if it contains sufficient instructions to perform operations in
following categories:
Functional Instructions
• Arithmetic, logic, and shift instructions
• Examples: ADD, CMA, INC, CIR, CIL, AND, CLA
Transfer Instructions
• Data transfers between the main memory and the processor registers
• Examples: LDA, STA
Control Instructions
• Program sequencing and control
• Examples: BUN, BSA, ISZ
Input/output Instructions
• Input and output
• Examples: INP, OUT
Instruction set of Basic computer is complete because:
• ADD, CMA (complement), INC can be used to perform addition and subtraction
and CIR (circular right shift), CIL (circular left shift) instructions can be used to
achieve any kind of shift operations. Addition subtraction and shifting can be used
together to achieve multiplication and division. AND, CMA and CLA (clear
accumulator) can be used to achieve any logical operations.
• LDA instruction moves data from memory to register and STA instruction moves
data from register to memory.
• The branch instructions BUN, BSA and ISZ together with skip instruction provide
the mechanism of program control and sequencing.
• INP instruction is used to read data from input device and OUT instruction is used
to send data from processor to output device.
3.3Timing and Control Unit
Control Unit
Control unit (CU) of a processor translates from machine instructions to the control
signals for the microoperations that implement them. There are two types of control
organization:
a) Hardwired Control
b) Microprogrammed Control
a) Hardwired Control
CU is made up of sequential and combinational circuits to generate the control signals.
If logic is changed, we need to change the whole circuit.
Expensive
Fast
b) Microprogrammed Control
A control memory on the processor contains microprograms that
activate the necessary control signals.
If logic is changed, we only need to change the microprogram.
Cheap
Slow
Control Unit of a Basic
Computer (Hardwired Control)
The block diagram of a hardwired control unit is shown below. It
consists of two decoders, a sequence counter, and a number of control
logic gates.
Timing Signal
• Generated by 4-bit sequence counter and 4x16 decoder.
• The SC can be incremented or cleared.
• Example: T0, T1, T2, T3, T4, T0, T1 . . .
• Assume: At time T4, SC is cleared to 0 if decoder output D3 is active:
• D3T4: SC 0
3.5 Instruction Cycle of Basic
Computer
Processing required for complete execution of an instruction is called instruction cycle.
In Basic Computer, a machine instruction is executed in the following cycle:
• Fetch an instruction from memory
• Decode the instruction
• Read the effective address from memory if the instruction has an indirect
address
• Execute the instruction
• Upon the completion of step 4, control goes back to step 1 to fetch,
decode and execute the next instruction. This process is continued
indefinitely until HALT instruction is encountered.
Fetch and Decode
Sequence of steps required for fetching instruction from memory to
CPU internal register is known as fetch cycle. The microoperations for
the fetch and decode phases can be specified by the following resister
transfer statements: (first two steps for fetch and third step for decode)
• Determine the type of the instruction
The timing signal that is active after decoding is T3. During time T3, the
control unit determines the type of instruction that was just read from
memory. Following flowchart presents an initial configuration for the
instruction cycle and shows how the control determines the instruction
type after decoding.
Then, among decoded, D7 determines which type of instruction.
1) If D7 = 1, it will be either register-reference or input-output
instruction.
If I = 1, input-output instruction is executed during T3.
If I = 0, register-reference instruction is executed during T3.
2) If D7 = 0, it will be memory-reference instruction.
If I = 1, indirect addressing mode instruction during T3.
If I = 0, direct addressing mode instruction during T3.
The SC is reset after executing each instruction.
Register-Reference Instructions
Register Reference Instructions are identified when
• - D7 = 1, I = 0
• - Register Ref. Instr. is specified in b0 ~ b11 of IR
• - Execution starts with timing signal T3
• Let r = D7 I’T3 => Common to all Register Reference Instruction
• Bi = IR (i), i=0, 1, 2... 11. [Bit in IR(0-11) that specifies the operation]
Memory-reference instructions
• Once an instruction has been loaded to IR, it may require further access to
memory to perform its intended function (direct or indirect).
• The effective address of the instruction is in the AR and was placed their
during:
- Time signal T2 when I = 0 or
- Time signal T3 when I = 1
• Execution of memory reference instructions starts with the timing signal
T4.
• Described symbolically using RTL.
Input-Output Configuration
The terminal sends and receives serial information. Each quantity of
information has 8 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 input—output configuration is shown in
figure. 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.
Scenario1: when a key is struck in the keyboard, an 8-bit alphanumeric
code is shifted into INPR and the input flag FGI is set to 1. As long as the
flag is set, the information in INPR cannot be changed by striking another
key. The control checks the flag bit, if 1, contents of INPR is transferred in
parallel to AC and FGI is cleared to 0. Once the flag is cleared, new
information can be shifted into INPR by striking another key.
Scenario2: OUTR works similarly but the direction of information flow is
reversed. Initially FGO is set to 1. The computer checks the flag bit; if it is 1,
the information is transferred in parallel to OUTR and FGO is cleared to 0.
The output device accepts the coded information, prints the corresponding
character and when operation is completed, it sets FGO to 1.
Input-output Instructions : I/O instructions are needed to transferring
information to and form AC register, for checking the flag bits and for
controlling the interrupt facility.
Program Interrupt
• Input and Output interactions with electromechanical peripheral devices
require huge processing times compared with CPU processing times – I/O
(milliseconds) versus CPU (nano/micro-seconds)
• Interrupts permit other CPU instructions to execute while waiting for I/O to
complete
• 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.
Description
• The flowchart consists of R – an interrupt flip flop where if R=0 it proceeds to
instruction cycle and if R=1, it proceeds to interrupt cycle.
• When R=0, the computer goes through an instruction cycle. During the
execution phase of the instruction cycle, IEN (Interrupt enable flip flop) 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= 1, control checks the flag bit, If both flags are 0, it indicates that
neither the input nor the output registers are ready for the 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.
Continue…..
• When R=1, the interrupt instruction executes the following steps:
a) Save the current program and return to the interrupt where PC
proceed to zero memory.
M[0] PC
b) Control then issues address 1 into PC.
c) Finally, interrupt is finished or cleared then IEN=0, R=0, further
proceed to instruction cycle.
Register Transfer in Interrupt Cycle
Design of Basic Computer
The basic computer consists of the following hardware components:
A memory unit with 4096 words of 16 bits each.
Nine registers: AR(Address Reg.), PC (Program Counter), DR(Data Reg.), AC
(Accumulator), IR (Instruction Reg.), TR (Temp. Reg.),
OUTR (Output Reg.), INPR (Input Reg.), and SC (Sequence Counter).
Flip-flops: IEN (Interrupt Enable), FGI (Input Flag), and FGO (Output Flag).
Two decoders: a 3 x 8 operation decoder and a 4 x 16 timing decoder
A 16-bit common bus.
Control logic gates.
Adder and logic circuit connected to the input of AC.
Control Functions and Microoperations of
Basic Computer
Design of Accumulator Logic