Table of Contents

Computer Organization CPU Simulator

Objective

To better understand the concepts covered in the course, we will be implementing a working CPU simulator enabling us to program, execute, and debug machine code (at the hexadecimal level) for the given microprocessor architecture.

Background

The CPU is in many ways the brain of a computer. Processing requests (commands), it has a finite set of instructions which can be combined in various ways to accomplish any number of tasks.

Target CPU

For this semester, we will be focusing on implementing the 8-bit Motorola 6800 CPU.

Simulator

The simulator you build must do the following:

The various options are described in greater depth below:

Enter program

Your simulator will emulate a certain amount of memory. When you enter this program entry mode, you should give the user a prompt that display the current memory address (start at hex address 0x0). As each instruction is entered, adjust the prompt with the next appropriate memory address (note all instructions may not be of the same size, so the prompt may increment several memory addresses depending on the most recently entered instruction)

You may want to incorporate some sort of “Enter program AT” functionality as well, allowing you to move to a specific memory address, instead of always starting at 0x0.

Run program

This will instruct your simulator to start processing any entered code and executing it. You may also want to have some sort of “Run program AT” functionality if you don't always want to start execution at memory address 0x0.

Single Step program

A powerful debugging tool, single stepping allows you to run a program, but to do so a single instruction at a time. While single stepping, you should provide the user with the following options:

Memory dump

When doing a memory dump, you will see (in hex) memory addresses and their contents (also in hex). This provides the end user with a way to verify what is in memory.

You will likely want to come up with some sort of nice grid display (rows and columns).

Register display

The register display functionality will display all the CPU's registers and their contents (in hex). This provides a useful means of debugging.

Exit

Simply exits the simulator.

Instructions

In addition to the menu, you need to implement the actual instructions and registers and instruction logic to make the CPU behave as it should.

Utilizing various resources on the selected CPU, you will need to find such things as:

Implementing the instructions can take many approaches… commonly, starting off with a big switch-case block on hex values will do the trick, and perform the appropriate operations.

Note that instructions will likely be register specific, and depending on the outcome of the instruction, different flags will need to be adjusted.

For this project, you do NOT need to be concerned with CPU cycle accuracy. You are not forbidden from implementing such, but note that it is not a requirement for this project. Just focus on making the instructions work as they should, with flags and registers and memory reacting in a functioning manner.

Repository

You are to place all code for this project in a subversion repository, making frequent commits so progress can be tracked throughout the semester.

References