Lisp CPU

This is the architecture for a Lisp CPU, which should fit in a small FPGA,
like the one used in the Spartan-3
Starter Kit. With "Lisp CPU" I mean that the core evaluates a
binary form of s-expressions without compiling it to a lower machine code level,
like described in Design
of LISP-Based Processors or, SCHEME: A Dielectric LISP or, Finite Memories Considered
Harmful or, LAMBDA: The Ultimate Opcode. My goal is not a full featured
Common Lisp implementation, but a Lisp dialect which is good enough for writing
applications like games, without the need to do all the low-level handlings
like in C. While the application logic will be written in Lisp, special hardware
functions and performance critical tasks, like sound generation, will be implemented
in hardware and available with primitive Lisp functions.

Pointers and values

Every value and pointer is saved in a word, with some extra bits for the type
information.

Type

Meaning of the word without the type bits

fixnum

fixnum

symbol

pointer to a symbol structure

list

pointer to a list structure

primitive

the identifier of a primitive function

array

pointer to an array

function

pointer to a function

nil

the word is not used

Structures

symbol structure: 3 words with type information:

value-slot: list of pointers of any type. A new value is prepended on function
call and removed on function return.

function-slot: pointer of type "primitive" or "list"

name-slot: pointer of type "array"

list structure: 2 words with type information:

car: pointer of any type

cdr: pointer of any type

array structure: first fixnum specifies the size, followed by the typed values
or pointers.

function structure: two list pointers: first list is a list of symbols for
the parameters, second list is the function body.

Lisp Primitives

+ - < > <= >= /= = * set quote setq defun progn if cons
car cdr nil

set-lednumber : sets the LED bit-pattern (8 bits)

get-led : gets the LED bit-pattern (8 bits)

whileconditionbody : a loop: if the evaluation
of condition is not nil, body will be evaluated (implicit
progn) and then it starts again with checking condition, until it is
nil.

defun : the standard defun, but with dynamic scope and without
special lambda list details, like default parameters, keyword arguments etc.
All symbols are global and when a function is called, the function arguments
are prepended in the value slot of the symbol and removed on function return.

Building a CPU in Lisp

This program can be transformed into the binary s-epression representation
and evaluated with lispcpu.lisp.txt.

Building a CPU in Verilog

It's more difficult than I thought to built a Lisp CPU. Perhaps the Verilog
language is not so good, because some nice standard language featuers (forever-loop etc.) are
missing in the Xilinx-Tools. But it
is possible, the code looks only a bit more complicated. For learning how to
built a CPU at all and how to implement RAM, ROM, program counter and an evaluator,
I started with a simple CPU, which will be enhanced to the Lisp CPU: