Salut YG and list,

> 
> you could just use a "new", all in VHDL.
> 

No, I'm actually initializing a struct on the C side using my C
<entity>_new() routine. The access variable is kinda abusive.

> you should know however that GHDL's arrays are actually descriptors
> (a small "record") that gives the bounds, as well as the pointer
> to the actual data.
> 

Yes, up to a certain point I had no problems reading the internal
structs from C, but I kinda figured it would be easier to not create too
much VHDL overhead for user defined objects.

>> Inside the clock sensitive process are calls to a ram_write() and
>> ram_read() function implemented in C. So the rambuf_t is just a
>> anonymous handle (C world: pointer) to VHDL.
> 
> if you use the "new", all-VHDL approach, you spare ram_write() and
> ram_read() :-)
> 

I need these, because the virtual RAM is accessed through another thread
(kind of a back door to the memory).

> 
> I think you found the hard way that GHDL is not thread-safe ;-)
> 

It wasn't hard. In fact, it can be made thread safe using the VHPI
approach. That way, multiple simulations can communicate with each other
(through the network as well, so they can run on different machines). So
all the mutex guarding is done on the C side. This turned out very safe,
plus convenient for some simulation throttling (inserted sleeps when
there's no activity on the I/O FIFOs).

I have no insight to the GRT internals so far, so I haven't evaluated
any hacks to get more control over threading to speed up simulation for
asynchronously running entities. I guess this must have been discussed
before and would require massive architectural changes.

> This is why I go to these extreme dirt-digging exercises,
> I add a high-level communication protocol (with timing management)
> and I do all I can to keep the whole program in one thread.
> As a result, I do some manual "multitasking" but at least I'm sure
> I don't create race conditions and I avoid any interference with the GRT.
> 
> Hopefully it will be published within a few months and everybody
> will enjoy it :-)
> 

Let me know when you've got something to play with.

Greetings,

- Martin

_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss

Reply via email to