- A simple CPU which should relatively easy to implement using RISC principles
- 64 kB memory
- A simple tty output device, connected to standard output
- A simple tty input device, connected to standard input
The first queue is an event queue on which all system operations are put and executed. This is done through callbacks. Every callback must have its own lexical state and return 0. Only the callback which executes the CPU returns 1 or 2. 1 signifies that the CPU has entered HALT state, while 2 just notifies that a CPU step has been executed. This makes it possible to know that the simulator has executed one cycle, which can consist of a whole series of events. This is necessary for single-step functionality.
The second queue is a timer event queue. On this queue a count value and a callback are placed. The callbacks here are ordered ascending. On the event queue a count down event is placed, so that every cycle the timers are decreased. For timers which reach zero, the associated callbacks are placed on the event queue and executed from there.
The system is complete with an assembler. It uses s-expression syntax and is written in Common Lisp. Using pattern matching functionality from Common Lisp makes it possible to easily extend the assembler with higher level functions which are translated to assembler.
In the directory asm/util there is also some Emacs Lisp code which makes it possible to point at a directory where Emacs can find assembly code, which can then be edited, assembled and loaded and executed onto the simulator. This should improve the turnaround time for developing programs.
With this system set up, it now becomes possible to develop the same microprocessor on a Digilent Atlys board. The simulator makes it possible to test programs first before they are loaded onto the hardware.
The simulator has been tested with CLISP and SBCL. On a MacBook Pro it provides the following performance:
Implementation | Instructions/s |
---|---|
CLISP, interpreted | 4300 |
CLISP, compiled | 110000 |
SBCL | 2000000 |
Since SBCL always compiles before it executes, there is no need to make the same distinction as for CLISP.