WRAMP CPU Simulator

A large part of the course COMP200 at the University of Waikato involves writing programs for a custom-built CPU called the WRAMP processor – Waikato RISC Architecture Micro Processor, running on the REX board. We have a computer lab with a number of boards, and students work in the lab to complete various assignments covering several aspects of computer architecture: namely assembly programming, higher-level languages and conventions using the call stack, parallel and serial I/O devices, interrupt handling and multitasking kernel design.

As tutor for this course, I’ve heard many students wanting the ability to work away from campus, which is difficult when you need specialised hardware. So over the past year, I’ve created a REX board simulator in C# as a personal project.

The Simulator

The main form runs over a photo of the actual hardware board, and allows buttons to be pressed, switches toggled, seven-segment LED displays to be seen, and shows the values of the address and data buses. There are also interrupt LEDs that light up when a device asserts its IRQ line.

Below the REX board photo is a number of checkboxes that show or hide various views of devices. This provides an insight into the inner workings in of the hardware in realtime that is not possible with the actual hardware. There are several categories of forms, outlined below.

Serial Ports

The REX board has two serial ports, and these forms simulate simple terminals where any typed characters are sent to the serial ports on the board, and display anything received. They can also send files, which is most useful for uploading code to the board.

Registers

The WRAMP processor has two sets of registers: general purpose, which can be used for any purpose (hence the name), and the special purpose registers that influence the operation of the CPU, and reports its status.

Memory

The memory view shows the current contents of RAM, along with the disassembly of instructions. In addition, various pointers are shown pointing to their relevant memory addresses.

Device Control Registers

There are several devices with status and control registers  that share the same address space with memory. These forms show the current values of their relevant registers.

Download / Source Code

Visit the SourceForge project webpage at http://sourceforge.net/projects/rexsimulator/

Disclaimer: this simulator is provided to you in the hope that it is useful. There is no guarantee that it will work correctly, and if there is any difference between the simulator and real hardware, the real hardware is correct. Use at your own risk.

Get a demo project here, containing:

  • hello.s, WRAMP assembly source code
  • hello.o, WRAMP object code (after assembly)
  • hello.srec, the executable code to load to the board (after linking)

To run this code, run the simulator, and in the Serial Port 1 terminal, type “load”. Next, select “Upload File”, choose “hello.srec”, and wait. Then, type “go”. If everything worked fine, you should see “hello” scrolling across the seven-segment displays!

Bugs!

As an experimental piece of software, there is no doubt there will be bugs. If you do find any, please use the comments form below to let me know about it, and how to repeat it.

Leave a Reply