computer science essay

CPU Design And Simulation Computer Science Essay

Published: 23, March 2015

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

The report first exemplifies the aim and objective of the CPU assignment. First I will explain what computer instruction, operand are and how they are added and executed. In this report I will explain the designing CPU SIMULATOR, part contain of developing the algorithm for the simulator and developing it using C++ and later the simulator is experienced by executing set of instructions. After testing and debug I will conclude this assignment with references.

AIM AND OBJETIVE

To design an 8-bit CPU simulator that can perform basic operations can take input and execute them and will be able to perform following operations.

The main aim of this assignment is to write a code in C++ to simulate the 8-bit CPU.

Define a instruction set for the 8-bit CPU simulation.

Describe the Simulator Algorithm and

Code in C++ for 8-bit CPU Simulator.

Introduction

A CPU is made of combination of gates and flip-flops to carry out mathematical operations, all the arithmetic operation of a microprocessor taken place in the ALU (Arithmetic Logic Unit). Control Unit send signals to perform an operation. The data on which operation are performed will come from external input or memory. Then the input is operated in appropriate manner with the contents of the accumulator and the output will placed in the accumulator. From accumulator output will be transferred to memory or to an output unit.

In genral computer BUS plays an important role to transfaring data within computer components or between computers. There are mainly three kinds of bus Address Bus which is used to transfer addresses from Central Processing Unit to Main Memory and Input-output devices. Data bus is bi-directional bus which transfer data between CPU , Memory and Peripheral devices. All the computer computer components talks to CPU and memory using Data bus. CPU uses control bus to control peripheral devices or the external device to send synchronization message to the CPU.

Overall Central Processing Unit (CPU) is a general-purpose instruction set which operates on instructions and data which are obtained by the processor from memory or input/output devices.

Instruction Set

To design a CPU first thing we need to keep in mind is instruction that needs to support. Finally, now come to the core of computing: the programs how and what to direct central processing unit to control and finally find the result is instruction set.There are mainly two type of instruction sets CISC (Complex instruction set computer) and RISC (reduced instruction set computers).

CISC are compact register which can support complex, powerful and large instruction set. RISC is numerous registers which can support simple hard-wired machine code and Limited instruction set but still works on many processers that are arranged in parallel and are able to execute simple instruction concurrently.

Instruction set design:

The main four basic component instruction contains are:

Operation Code (OP-CODE): is a machine language instruction which control what type of action the computer should take, e.g. add, sub, load, and store. In our 8-bit CPU design the most important 3-bits might be the op-code giving 8 possible operations and other given parameter addressing mode and operand. Every op-code must be unique with each other.

On the above example 3 bit is use for OPCODE which is 2^3=8 is used for instruction set. Operation Code is a Code that instructs the computer to execute the instruction. In our Simulator will able to instruct following instructions.

Instrution

Mnemonic

Add

ADD N or ADD [N]

Sub

SUB N or SUB [N]

Load

LDA N or LDA [N]

Store

STA N or STA [N]

Branch

BRA

Stop

STOP

the 7 instruction we required at least 3 bit of the instruction (as 2^3 =8, meaning up to 8 instruction can be represented)

The operational code for the instruction is as follows

OPCODE

Add

000

Sub

001

Load

010

Store

011

Branch

100

Branch & compare

101

Stop

110

Source Operand reference: must specify in instruction, Operand can be passed directly which is called direct instruction or through the address, which contains the value to be use which is called indirect addressing.

Result Reference: The result of the operation is placed in some place that is called result reference. This also can be direct or indirect depends on whether the value supplied directly or indirectly through an address reference.

Next instruction Reference: This show how and where another instruction could be finding.

The Algorithm for the CPU Simulator:

First to design the CPU Simulator we need to do the develop the algorithm for all duty that CPU needs to do either enter instruction or execute instruction, etc.

A user can give instruction as per displayed on the screen the program counter (PC) will start from the location 0. User first need to select operational code (op-code), then the addressing mode (AMOD) and then the operand.

[A] = N!, [PC] ïƒŸ N; Compare accumulator with data and branch to program Memory location if the values are equal

[PC] ïƒŸ STOP; Stop execution

THE SOURCE CODE

The 8-bit CPU Simulator is developed in C++. Because C++ is an object oriented programming language designed mainly for system programming. There is two classes define separately. Class "input" is use to fetch the input from the user and other Class "CpuSim" which have its register and this class helps execute the instruction provided.

THE SOURCE CODE COMPILATION

The code is written and compiled in Borland Dev-C++ and given name CpuSim.cpp and the CpuSim.exe file is provided in CD with this project.

THE CPU SIMULATOR IN RUNNING STATE.

When we execute the exe file the black command line window is seen the main screen is in the screenshot.

Now CPU Simulator is ready to work and in running state.

User can enter the value of option given to start the CpuSim.

TESTING THE CPU SIMULATOR

Now the CpuSim is ready and can tested entering instruction and executing them. Here is some example instruction which we can use to test the simulator.

1. Load DIRECT 4

2. ADD DIRECT 3

3. Store DIRECT 0

4. Subtract DIRECT 3

5.Store INDIRECT 5

6.Stop

These instruction will load 4 to Accumulator register Acc, add 3 to Acc and save the result in data memory location 0 again substract 3 from Accumulator register Acc and load in data memory location 5.

To load user need to select 3.

Screen ask for the Addressing mode choose 1 for direct.

Now Screan will ask for operand enter 4.

Now operand is loded in Accumulator.

To add user need to select 1

Screen ask for the Addressing mode choose 1 for direct

Now screen will ask for operand enter 3.

Now we can see the Accumullator is changed to 7

To store user need to select op-code 4

Screen ask for the Addressing mode choose 1 for direct

Now screen will ask for memory location enter 0.

Now we can see the memory location 0 is changed to 7

To substract user need to select opcode option 2

Screen ask for the Addressing mode choose 1 for direct

Now screen will ask for operand enter 3.

Now we can see the Accumullator is changed to 4

To store user need to select op-code 4

Screen ask for the Addressing mode choose 0 for Indirect

Now screen will ask for memory location enter 5.

Now we can see the memory location 5 is changed to 4

All the above screen shots and the example shows that the instruction given to do some task to CPU is working properly.

Conclusion

The main aim of this assignment is, to design, builds and tests a simple, easy to use

8-bit CPU simulator was successfully tested.

The 8-bit instruction set taking instruction from the user process the instruction in cup and give result in the output. It displays the registry and memory status. This is just initial construction of CPU SIMLATOR in C++, we are just using 8 bit CPU with 3 bits for operational code 1 bit for Addressing mode and 4-bits are used for operand. On the report not only simulating CPU it also defines the important concepts of CPU design and how it works in different forms.

Our experts can help you with your essay question

Writing Services

Essay Writing Service

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing Service

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision Service

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.

Request Removal

If you are the original writer of this essay and no longer wish to have the essay published on the UK Essays website then please click on the link below to request removal: