Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

COMPUTER SYSTEM

ARCHITECTURE
ASSIGNMENT
Submitted to:-DR.ANUJA SONI mam
Submitted by:-Mayank Sharma
Roll no.:-19hcs4034
In this presentation, we will create text-file as well as its machine
using CPU SIMULATOR.
So first we learn a little about CPU SIMULATOR…

CPU SIMULATOR is a software development


environment that simulate basic computers.

CPU SIMULATOR allows user to edit and run


assembly language programs for the CPU being
simulated.
In CPU SIMULATOR, Operations (like arithmetic, logical,
complement and many more) are performed with the help of various
registers.
These registers facilitate:-
1. Fetching of instruction from memory.
2. Decoding of instruction.
3. Read the effective address from memory if the instruction has indirect
address.
4. Execution of instruction.

The above four steps are performed during the execution of every
program. These are the basic steps of Instruction cycle.
The registers use in CPU SIMULATOR are given in table below along with their symbol, size and
function.
*(size may vary in different
REGISTER Computers,
NUMBER here we size
OF BITS of memory
REGITER is 4096 X 16)
NAME FUNCTION
SYMBOL
DR 16 DATA REGISTER HOLD MEMORY
OPERAND
AR 12 ADDRESS REGISTER HOLD ADDRESS FOR
MEMORY
AC 16 ACCUMULATOR PROCESSOR REGISTER
REGISTER
IR 16 INSTRUCTION HOLDS INSTRUCTION
REGISTER CODE
PC 12 PROGRAM REGISTER HOLDS ADDRESS OF
INSTRUCTIONS
TR 16 TEMPORARY REGISTER HOLDS TEMPORARY
DATA
INPR 8 INPUT REGISTER HOLD INPUT
CHAHRACTER
OUTR 8 OUTPUT REGISTER HOLD OUTPUT
The given table represent the path of transfer of information from one
Register to another known as Common Bus System.
LD represents Load(Load value in register), INR represents Increment
(Increment in value of register), CLR represents Clear(Clear value to
0).
❖ When data is transfer from memory to register, then it require-
❑ enable the Read input of memory.
❑ Place the content of memory onto the bus by making some value
of
S2S1S0.
❑ Transfer
❖ Incrementthe
ofcontent
registerof
is the bus
done bytoenabling
the register by enabling
the INR input ofits LD.
register.
❖ Register is clear to 0 by enabling CLR input of register.

Input and Output path between various registers and memory shown
in
given Figure.
FETCH AND
DECODE
Firstly, the program counter PC is loaded with the address of the first instruction in the program. The
sequence
counter is cleared to 0,providing a timing signal T0, which is incremented by one.
T0: P
AR
T1: IR CM[AR], PC PC+1
T2: DO…..D7 DECODE IR(12-14), AR IR(0-11), I IR(15)
Since, only AR is connected to address input of memory, so address transfer from PC to AR during T0.
The instruction read from memory is placed in IR and PC is also incremented by 1 to hold address of next
instruction during T1.At time T2, the operation code in IR is decoded, the indirect bit is transferred to flip
flop I, and address part to AR.
-------------------------------------------------------------------------------------------------------------------------------------------
ILLUSTRATI During T2: Decoding of Instruction Format.
--------
ON
I OPCODE ADDRESS OF
INSTRUCTION
15 14…………………….12 11…………………………………………………………..0 (bits)
If ( I=0, represent Direct Address, requires two references to memory)
If ( I=1, represent Indirect Address, requires three references to
memory)
OPCODE represent the required operation to be perform.
If (OPCODE = 000 through 110 AND I = 0/1), then it is known as Memory- reference
instruction.
I OPCODE ADDRESS OF
INSTRUCTION
15 14…………………….12 11…………………………………………………………..0 (bits
)
If (OPCODE = 111 AND I = 0), then it is known as Register-reference
instruction.
I OPCODE REGISTER
OPERATION
15 14…………………….12 11…………………………………………………………..0 (bits
)
If (OPCODE =111 AND I = 1), then it is known as Input-Output
instruction.
I OPCODE INPUT-OUTPUT
OPERATION
15 14…………………….12 11…………………………………………………………..0 (bits
)

------------------------------------------------------------------------------------------------------------------------------------------
--------
DETERMINING INSTRUCTION TYPE AND
EXECUTION

The timing signal that is active after the decoding


is T3.
The control unit determine the type of instruction,
If D7= 1 and I = 0, the instruction must be
Register-reference.
If D7= 1 and I = 0, the instruction must be
Input-Output-
reference.
If D7= 0 and I = 0/1, the instruction must be
Memory-reference.

After determining the type of instruction, the


execution of instructions take place as per given
flowchart.
Now, we have learn enough to create a program using CPU
So, let’s start with our
SIMULATOR . first program i.e.,
❖ ADDITION OF TWO NUMBERS ONE IS ENTERED BY USER AND OTHER ONE IS STORED IN
REGISTER ALREADY.
We follow some steps for making a given program.
Step 1:- Create a text file of given program in CPU SIMULATOR and save it with
extension (.a).
Step 2:- For Creating a machine, we declare first memory size as 4096 x 16 with
name M.
Step 3:- Now, we declare all the required Registers with their size.
Step 4:- Write the Fetch sequence.
Step 5:- Write Machine Instructions and implement them with their necessary
Micro-
instructions.
Step 6:- Set proper indexing of the Machine instructions.
Step 7:- Save the machine with extension (.cpu).
Step 8:- Compile, load and run the program.
Let us see some screenshots of text files, machine instruction and micro-instructions that will how to
make
program in CPU SIMULATOR step by step: (i) Creating Text-File:
(ii) Creating RAM and required REGISTERS:

Firstly, we define the memory size as


4096 x 16 under RAM(type of module).
It means 4096 words and each word
have size 16 bits.
From here we can determine number
of bits assign for address register i.e.,
12 bits(as 2^12 =4096) and data
register i.e., 16 bits.
We define required registers for
transferring data between them and for
performing various operations like
arithmetic, logical, circular shift and
many more with their size.

Here, we define a 3-bit register


Sizes of Initial
STATUS for setting a stop registers bit
criteria for the program and value

working of other registers we


have discuss in previous slides.
(iii) Writing
MICRO-INSTRUCTIONS
of FETCHING SEQUENCE :

The adjacent picture showing the


fetching-Sequence which is firstly, the
PC is loaded with first instruction
which is transferred to AR and
Further Micro-instructions are
shown in picture.
(iv) Writing MACHINE INSTRUCTIONS with their format
fields:

✔ In machine instructions, we declare three


Fields names opcode have size 4 bits,
address have size 12 bits and unused have
size 12 bits and have ignored type, while
opcode and address have required type.
Here, we have four Machine
instructions read, add, write and
stop. Instruction add has format
fields having opcode and
address because it requires to
read address of operand from
memory to perform addition,
while remaining three
instructions have format fields
which having opcode and
unused as they don’t require
any address for reading and
writing into or from memory
respectively
(v) Implementation (Writing Micro-instruction):
After format, we write
micro-instructions of each
machine instruction with its
proper and, drag & drop it under
particular instruction with
proper Execution sequence, End
micro-instruction must be include
at end for
terminating instruction.
In the adjacent picture, the
microinstructions of add are
given with proper execution
are given. Similarly, we
write micro-instructions of
other instructions.

For stop instructions, first


we set a stopping
criteria(HALT_BIT).
(vi) Set proper Indexing and Saving Text file and Machine:
Sometimes, program gives error due to improper
indexing so before saving program make sure that
it has proper indexing.
Since, our program have registers such as IR
which
have initial bit starts from left, so we set the
indexing
as left.

Finally, after completion we save the


program:
a.) Text-file with extension (.a).
b.) Machine with extension (.cpu).
(vii) Assemble & load program:

--
(viii) Run Program:
INPUT:
OUTPU
T:
After saving both text-file and Machine. We assemble and load the program under execution option
for converting the instructions into machine language i.e., into 0 and 1 and run the program for giving
input and perform the operation.
---------------------------------------------------------------------------------------------------------------------------------------------------
--------
Illustration of above program output:-
Here, we are taking one input i.e., 40.
It gives output 70 by adding 40 with 30(operand stored in Memory)
i.e., 40+30=70.
Hence, program is working perfectly.
---------------------------------------------------------------------------------------------------------------------------------------------------
----------
DEBUG
MODE:
We use debug mode(under execute option) for detecting error, by using debug mode we can run program’s
instructions or micro-instructions step by step for understanding the internal working of machine by
examining the transferring of data between different registers and we can detect error easily.
Debug Mode
Now, let us see second version addition program which is slightly different from first
one

❖ Add two user entered Numbers

This program will add two user entered numbers. The program take two inputs.
Majorly, Machine instructions will be same except some modifications as we
create one more register TR to hold one operand temporarily from AC, which
later transfer data to DR for arithmetic operation.
(i) Creating Text-File
(ii) Create RAM and
Registers

-------------------------------------------------------------------------

Here, we need one more register TR as compared to


previous program.
(iii) Fetch
Sequence:
(iv) Creating Machine instructions with their
format:

Two read for reading two


Operand.
(v) Implementation(Writing Micro-instructions):

Transferring first operand into


TR
and second one remain in AC.
(Transferring operand from TR to DR
to
perform addition.)

(Performing Addition)
(vi) Indexing
After Saving Text-file and Machine:
(vii) Assemble & load
Program
(viii) Run Program
INPU
T
OUTPU
T
THANK YOU!!
FOR YOUR ATTENTION

You might also like