Breakthrough in Ruby-VPI's C extension and Ruby 1.9 support

Suraj N. Kurapati

Mikhail Ravkine suggested that regular development activity would stimulate this community, so I thought I’d share some exciting news: for about a month now, I’ve been working on adding support for Ruby 1.9, and this past weekend I finally made a breakthrough.

Instead of running the Ruby interpreter (which in turn runs the executable specification) inside a pthread and using pthread mutex to transfer control between Ruby and Verilog, I would simply run the executable specification inside a Ruby thread and use Ruby’s thread-safe Queue class (a mailbox) to perform the control transfer.

This approach has the advantage that we completely avoid the difficulties associated with initializing the Ruby interpreter’s stack inside a pthread (since a pthread’s stack is small compared to the main process).

Furthermore, since the Ruby interpreter is compiled with support for the pthreads library on some systems, it becomes even more tricky to initialize the interpreter’s stack correctly.

Nevertheless, this new approach works well with VCS, CVER, and NCSIM. Unfortunately, it fails completely with VSIM reporting an internal simulation kernel failure. This leading me to believe that VSIM invokes all vlogstartuproutines somewhere outside the execution stack of the main process (perhaps inside a pthread or within its own threading implementation).

Anyway, that’s the latest news about the C extension. There’s still some more work to be done on the Ruby side of Ruby-VPI before Ruby 1.9 is fully supported. I’m planning to work on that this weekend and make a release in the middle of next week.