CPU Sim
   HOME

TheInfoList



OR:

CPU Sim is a software development environment for the simulation of simple computers. It was developed by Dale Skrien to help students understand
computer architectures In computer engineering, computer architecture is a description of the structure of a computer system made from component parts. It can sometimes be a high-level description that ignores details of the implementation. At a more detailed level, the ...
. With this application the user is able to simulate new or existing simple CPUs. Users can create new virtual CPUs with custom
machine language In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a very ...
instructions, which are implemented by a sequence of micro instructions. CPU Sim allows the user to edit and run assembly language programs for the CPU being simulated. CPU Sim has been programmed using the
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
Swing package. This means that it is
platform independent In computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is designed to work in several computing platforms. Some cross-platform software r ...
(runs on every platform that has a
Java virtual machine A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes ...
installed).


Wombat 1 Sample CPU

A sample computer system, the Wombat 1, is provided with CPU Sim. It has the following registers: * pc (
program counter The program counter (PC), commonly called the instruction pointer (IP) in Intel x86 and Itanium microprocessors, and sometimes called the instruction address register (IAR), the instruction counter, or just part of the instruction sequencer, is ...
); * acc ( accumulator); * ir (
instruction register In computing, the instruction register (IR) or current instruction register (CIR) is the part of a CPU's control unit that holds the instruction currently being executed or decoded. In simple processors, each instruction to be executed is loaded ...
); * mar (
memory address register In a computer, the memory address register (MAR) is the Central processing unit, CPU Hardware register, register that either stores the memory address from which data will be fetched to the CPU registers, or the address to which data will be sent ...
); * mdr (
memory data register A memory buffer register (MBR) or memory data register (MDR) is the register in a computer's CPU that stores the data being transferred to and from the immediate access storage. It contains a copy of the value in the memory location specified by t ...
); * status. The
assembly language In computer programming, assembly language (or assembler language, or symbolic machine code), often referred to simply as Assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence be ...
of the Wombat 1 computer consists of 12 instructions. Each instruction is stored on 16 bits; the first 4 are the
opcode In computing, an opcode (abbreviated from operation code, also known as instruction machine code, instruction code, instruction syllable, instruction parcel or opstring) is the portion of a machine language instruction that specifies the operat ...
and the other 12 are the address field.


Features

CPU Sim has the following features: * allows the creation of a CPU (a virtual one), including the registers, RAM, microinstructions, and machine instructions; * allows the creation, editing, and execution of assembly language programs for the simulated CPU; * allows stepping forward and backward through the execution of assembly language programs.


Example program for the Wombat 1 CPU

This program reads in integers until a negative integer is read. It then outputs the sum of all the positive integers.
Start:	read		// read n -> acc
	jmpn  Done  	// jump to Done if acc < 0.
	add   sum  	// add sum to the acc
	store sum 	// store the new sum
	jump  Start	// go back & read in next number
Done:	load  sum 	// load the final sum
	write 		// write the final sum
	stop  		// stop

sum:	.data 2 0	// 2-byte location where sum is stored
The following modification of the program is also used sometimes:
Start:	read		// read n -> acc
	jmpz  Done  	// jump to Done if nacc is 0.
	add   sum  	// add sum to the acc
	store sum 	// store the new sum
	jump  Start	// go back & read in next number
Done:	load  sum 	// load the final sum
	write 		// write the final sum
	stop  		// stop

sum:	.data 2 0	// 2-byte location where sum is stored
This one can use negative input to subtract, or 0 to break the loop.


See also

*
Comparison of EDA software This page is a comparison of electronic design automation (EDA) software which is used today to design the near totality of electronic devices. Modern electronic devices are too complex to be designed without the help of a computer. Electronic dev ...
*
List of free electronics circuit simulators List of free analog and digital electronic circuit simulators, available for Windows, macOS, Linux, and comparing against UC Berkeley SPICE. Some of the following simulators don't include a graphical visual interface, so a separate program must be ...
*
Computer architecture simulator A computer architecture simulator is a program that simulates the execution of computer architecture. Computer architecture simulators are used for the following purposes: * Lowering cost by evaluating hardware designs without building physical ha ...


References


External links

*
GitHub Source Repository

CPUSim Youtube Playlist


{{DEFAULTSORT:Cpu Sim Electronic circuit simulators