Mon Sep 3 10:05:21 EDT 2018


So I have some cargo-culted code that compiles and runs.  Now I want
to know how exactly I get "events".  What I miss is the shape of the
context these functions are supposed to run in.

This is quite typical: the API is too granular to reconstruct this
kind of context.  Examples are essential to get the big picture.

I find this in the myhdl.c code:


Googling for that, I find:


Some remarks:

- userdata has nothing to do with the argument to a function.  it
  seems to be just a user state pointer.

- everything is dynamically typed, and referenced using vpiHandle

- some calls allocate objects that need to be freed,
  e.g. vpi_iterate() (EDIT: this caused a crash... reference manual?)


Now, how to put it all together?

Instead of syncing on clock inside the module, what about calling it
like this:

always @(posedge clock)

This could then read out all the registers that were tagged in
$to_seq(), and write to all the registers tagged in $from_seq().

This seems straightforward.  The problem is then how to define the
protocol between the Haskell side and the simulation?

EDIT: This seems to work.  Proof of concept, clean up later.

Next: generic way to get an I/O pipe into a C program from Haskell.
TCP?  Named pipe?

The most straightforward way I can think of:
- Have Haskell set up the pipes
- Put pipe locations in environemnt
- Let module open the pipes

EDIT: How to set this up?
There is this, which is a higher level interface:

Seems overkill.  I just need the system calls.
EDIT: Trying named pipes, but this is really hacky.
Unix socket?

EDIT: Basic unix socket infra is in place.  How to (de)serialize?

I don't understand how to link the Char8 to the Data.Binary.Get

    • Couldn't match expected type ‘Data.ByteString.Lazy.Internal.ByteString’
                  with actual type ‘Data.ByteString.Internal.ByteString’