Computer Organization Complete Notes Unit2
Computer Organization Complete Notes Unit2
UNIT-II, Notes
In the Basic Computer, since the memory contains 4096 (= 2**12) words, so 12 bits specify
which memory address this instruction will use .
In the Basic Computer, bit 15 of the instruction specifies the addressing mode (0: direct
addressing, 1: indirect addressing)
Since the memory words, and hence the instructions, are 16 bits long, that leaves 3 bits for
the instruction’s op-code .
Addressing Modes
Three addressing modes
1. Immediate operand: when the second part of the instruction code specifies an operand.
2. Direct address: when the second part of the instruction code specifies the address of the
operand.
3. Indirect address: when this part specifies an address in a memory where we can find the
true address of the operand.
The (I) bit of the instruction code specifies direct addressing If I=0 or Indirect addressing if
I=1.
1. Accumulator Register (AC): exist in single register processors (AC) and all operations
areperformed with memory operand and this register.
Effective Address (EA):
The address that can be directly used without modification to access an operand for a
computation-type instruction, or as the target address for a branch-type instruction
The previous figure shows an example of addressing mode. In location 22 there is an ADD
instruction that adds the AC with operand in location 457 as an indication for direct
addressing mode as I=0.
On the other hand, the second part of the figure shows in location 35 and ADD instruction
between AC and the address of operand found in location 300. Location 300 contains the
operand address of 1350. In 1350 the operand will be read and added to the AC register, as
I=1 shows.
2. Computer Registers
A processor has many registers to hold instructions after it has been fetched from memory,
addresses of operands need to be accessed data manipulated with accumulator, general
purpose register, and others.
3. Program Counter (PC): used is to hold the memory address of the next instruction to be
executed. Size: 12 bits. :
4. Address Register (AR) is used to keep track of what a location in memory processor
isaddressing. Size: 12 bit
This AR register is always connected to address pins of memory unit.
5. Data Register (DR): When an operand is found, using either direct or indirect
addressing, itis placed in DR.
The processor then uses this value as data for its operation.
DR is connected to data pins of memory unit.
6. Accumulator (AC):
The Basic Computer has a single general purpose register–the Accumulator
(AC). It can be referred to in instructions.
E.g. load AC with the contents of a specific memory location;
store the contents of AC into a specified memory location.
AC is always one side in any data computation.
7. Temporary Register (TR):
A scratch register used to store intermediate results or other temporary data.
A path needed to transfer data between 8 registers beside memory unit and registers.
So a common bus will be the answer for that problem. The next figure shows the answer
consisting of a multiplexer or 3 state buffers with decoder. This gives a savings in circuitry
over complete connections between registers.
Three control lines, S2, S1, and S0 control which register the bus selects as its input and so
the selected register will issue its output to the bus.
The lines from the common bus are connected to the input of each register.
Either one of the registers will have its load signal activated, or the memory will have its read
signal activated.
And this will determine where the data from the bus gets loaded to during next clock
transition.
The memory will put its content to the bus when S2S1S0 =111 and its read control signal is
activated.
In the same manner, the memory will save the content of the bus,when its write control signal
is activated.
AR register is always used to hold address of data accessed from memory.
4 registers of 16-bit each, DR, AC, IR, and TR. Also we have two registers PC and AR are 12
bits each. The 12-bit registers, AR and PC, have 0’s loaded onto the bus in the high order 4
bit positions.
OUTR and INPR are 8-bit each and are connected to the lower 8 bits of the bus.
Five registers have 3 control inputs, LD, INC, CLR; those are AC, AR, TR, PC, and DR.
two registers, OUTR, and IR will only have a LD input.
The data to the AC register comes from ALU unit which accepts operands from AC register,
INPR register, or DR register.
Any and only one source of those register can be selected to apply its content to the bus and
during the same clock cycle the bus content could be directed to one or many destinations of
Computer Instructions
Sequence counter is used to synchronize action with those 16 different time intervals.
Sequence counter can be incremented and cleared synchronously.
Most of the time it is incremented to generate sequence of timing signals
Once in a while it is cleared by specific condition causing next timing sequence to go back to
T0.
Example on Timing Control:
Consider a case where SC is incremented to provide timing sequence T0, T1, T2, T3,
and T4, then T0 again.
At time T4 Sc is cleared based on a condition D3 is true.
Expressed in symbolic RTL form: D3T4: SC 0
The next figure shows its timing diagram.
When D3T4 is true then at first positive clock transition SC is cleared.
If SC is not cleared then it will continue its counting from T5 to T15 then it rolls over to T0
again.
For a memory read operation, it must be clear that between 2 rising edge of the clock, the data
should be read and applied to the bus, so that at next rising edge the data can be saved in
destination register.
T0: AR PC
That specifies transfer of data from PC to AR register in one clock pulse T0.
The content PC is put on the bus (S2S1S0=010) and LD of AR register is enabled during T0
cycle only.
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
After an instruction is executed, the cycle starts again at step 1, for the next instruction
Fetch and Decode:
Initially the PC is loaded with address with first instruction in the program then SC is cleared
giving time instance T0.
After each clock pulse SC is incremented resulting of T1, T2, and so on.
The first seven instructions will be carried on accumulator or carry bit, E bit.
The next 4 skip instructions will add one to PC register only if their condition is met.Those
conditions will be
Used here a 3 by 8 decoder is used to decode the 3 bits to 8 lines D0 to D7, although
D7 not used here.
The effective address of the instruction is in AR and was placed there during timing
signal T2 when I = 0, or during timing signal T3when I = 1.
The execution of MR instruction starts with T4. The complete execution of this type
of instructions will require a sequence of micro-operations during T4 and T5 and
likely T6.
The serial info from the keyboard is received serially and shifted into INPR.
COA CSE211 Jhuan Kumar Page 13
Assistant Professor
Lovely Professional University (LPU), Phagwara,
Punjab, India.
CSE211: COMPUTER ORGANIZATION AND DESIGN
UNIT-II, Notes
The serial info for the printer is stored in the OUTR and converted to serial and sends
to the printer.
The 1 bit FGI is a control flip flop that sets to 1 when new data is available in input
device and cleared to m0 (by processor) when computer receives it (needed to
synchronize time difference between processor and input device).
When key is pressed in keyboard its code is shifted to serial and shifted to INPR and
FGI is set (by the device). This insures that data in INPR will be untouched by
another key pressed till it’s cleared by the processor.
First the FGO is set to 1 (usually by the device) and processor scans that flag. If FGO
is 1 then it will transfer AC to OUTR and clears FGO to 0. The output device accepts
data in OUTR and sets FGO to 1 indicating it ready for another transfer.
the program controlled data transfer using flags and INPR and OUTR.
INP instruction transfer data from INPR register to AC0 to AC7 and clears FGI=0
OUT instruction transfers AC0 to AC7 to OUTR and clears FGO=0
The next 2 instructions scans flags and skip next instruction if flag=1 (usually
designed for branching to different locations in program based on value of FGI or FGI
flags).
The last 2 instructions sets and clear Interrupt Enable flip flop (see next section).
Interrupt Initiated IO and Interrupt Cycle
Program controlled transfer described earlier keeps scanning flag bits and when set it
initiate data transfer.
Inefficient since keeps processor doing nothing except scanning IO flags. Also.
For slow device transfer it can be considered wasting a lot of time (different data
transfer rate between IO and processor).
The solution will be the device can interrupt and tell processor when it wants to be
served.
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. CPU does not check the flags except when it is
interrupted by the device.
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.
Interrupt Cycle
The interrupt cycle is a HW implementation of a branch and save return address
operation.
The return address is stored in PC and it will be stored in location 0 of
memory (RAM).
PC will be updated to 1 which means it will execute the instruction held at
address = 1 and
Clears both IEN=0 and R=0.
At end of interrupt routine BUN to 0 is inserted with I=1. Means go back to
where it was interrupted from by "indirect BUN 0".
Fetch and decode phase will be modified in order to service the interrupt operations involved.
Need modified T0, T1, and T2 phases only for interrupt cycle