Csa Unit 2
Csa Unit 2
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 .
The (I) bit of the instruction code specifies direct addressing If I=0 or Indirect addressing if
I=1.
Accumulator Register (AC): exist in single register processors (AC) and all operations are
performed 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.
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.
-For instruction reading, a PC is used to hold address of next instruction to be fetched and
executed.
- First the PC value is copied into AR to start an instruction reading cycle, then the 16 bit
instruction is fetched and placed in Instruction Register (IR).
The Basic Computer uses a very simple model of input/output (I/O) operations.
Input devices are considered to send 8 bits of character data to the processor.
And the processor can send 8 bits of character data to output devices.
The Input Register (INPR): holds an 8 bit character gotten from an input device; the
Output Register (OUTR ) : holds an 8 bit character to be send to an output device.
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
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.
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
registers or memory unit. For example we can do the next micro-operation:
DR AC and AC DR
S2S1S0 = 100
LD of DR is enabled
Transferring DR through ALU to AC
LD of AC is enabled
Computer Instructions
The Basic Computer has 3 instruction code formats
The content PC is put on the bus (S2S1S0=010) and LD of AR register is enabled during T0
cycle only.
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.
During T1
Memory RD=1 which means memory unit will get its data out as AR register
indicates.
S2S1S0=111 which means what is read from memory goes to the bus
IR register LD = 1 which means what on the bus will go into IR register .
PC register INR = 1 which means increment PC register.
D7= 1 and I = 0
Execution of register reference starts with timing signal T3 and completed here.
Also Sc is cleared to indicate the end of execution and return to fetch new instruction
with T0.
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.
List of all memory reference Instructions:
The serial info from the keyboard is received serially and shifted into INPR.
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