4

The DPI functionality in System Verilog always mentions that you can interface it with any language, the most common one being C/C++. I want to interface my system Verilog code with Ruby. Is there any documentation or support for this functionality? Any known way to do this?

I should add that my main goal is to call a ruby script from my system Verilog uvm test.

Thanks

Greg
  • 18,111
  • 5
  • 46
  • 68
noobuntu
  • 903
  • 1
  • 18
  • 42

2 Answers2

6

While the standard mentions that the DPI can interface SystemVerilog with any other foreign language, it then chickens out and says:

For now, however, SystemVerilog defines a foreign language layer only for the C programming language.

This means that you should get DPI-C support in all IEEE 1800 compliant simulators, but any other foreign languages you get depend on your simulator vendor. Mine for example also offers SystemC, but requires that the SystemC code be patched (i.e. it won't work out of the box).

Some guys in my company managed to interface Python with SystemVerilog through the DPI, but they did it via a 2-step approach: Python -> C and C -> SystemVerilog. You would probably need to do something similar.

Tudor Timi
  • 7,453
  • 1
  • 24
  • 53
  • Thanks Tudor. I realized that this is probably not natively doable after some research. I have a question - I want to create a random test using SystemVerilog using the randomize() function on it and program my registers in the DUT with these random variables. I also want to invoke my software model (for scoreboard checking) with the same random register variables. This scoreboard is written in ruby. Right now I am leaning towards using system calls. I guess this is probably the only way? – noobuntu Jul 18 '14 at 16:29
  • 1
    It's also the only one I see, unless you want to implement the 2-step approach I outlined above. – Tudor Timi Jul 18 '14 at 17:56
  • 3
    @noobuntu Somebody else has already done the work for you and kindly made the source code available: Check out the [ruby-vpi](http://snk.tuxfamily.org/lib/ruby-vpi/) gem which provides access to VPI from ruby (via C). – Chiggs Jul 19 '14 at 13:39
1

This is as close as you get to Ruby, but using VPI:

If you like Python, you can try coco_tb:

Amal
  • 243
  • 1
  • 3
  • 8