Fri Sep 12 16:29:41 CEST 2008

towards standard machine architecture

There are essentially 2 kinds of semantics involved: the PE semantics,
which is scheme with infinite precesion and all kinds of data types,
and the concrete machine semantics.  All the rest is just intermediate
and should be derived or at least verified.

In order to improve test-driven development, these need to be made
comparable: some redundancy needs to be inserted to check compiler
correctness and machine model correctness.

So, is it possible to create a model for the 'generic risc' chip
emulating a stack machine, and then gradually use this model in
compiler generation/verification?

Microcontroller HAL:

   Harvard architecture (2 memory pointers)
   2 Stacks.
   Arithmetic operations operating on parameter stack.
   Function call/jump
   Conditional jumps.

It looks like this is the same problem as creating a simulator for a
specific processor based on a generic simulator writer framework.

Roadmap: build a verifyier for the current PIC18 compiler first.  This
means that all instructions used should have annotations that allow
semantics to be added, enabling simulation and so verification.

The processor (logic) specification language can be a simple
functional language with named nodes (multi in/out functions).  Maybe
SSA, essentially parallel dataflow (really?), is actually the most
convenient representation?

(define-io (add (a b) (dst w n ov z c dc))
  (! (c W) (+ a b))
  (! z (zero? W))
  (! n  (ref W 3))
  (! dc (ref W 7))
  (! ov (xor c n)))

Then the base language: If i'm not going to express it down to the
gate level, some meaningful intermediate level needs to be used.
Here there is really no alternative other than C.

Simulator conclusions:

  * Compared to compilation, ultimately simulation needs to be FAST.
    The only way to make things run fast on arbitrary host systems
    (workstations) is to generate C, and specialize a simulator to a

  * This answers the question of primitive semantics: C and it's bit
    manipulations.  The composition mechanism can be kept at SSA,
    which is trivially transferred to/from other dataflow

  * Such a primitive language is easily simulated in scheme when speed
    isn't important, but it's important to keep that layer to not use
    too many higher order tricks that would prevent compilation to C