Performance comparison between $system and DPI

I’m wondering if there is any difference in performance when calling C reference model by using $system to execute binary or through DPI to call imported function equivalent to main().

In reply to likewind:

The DPI should give you the best performance. Of course there will always be exceptions to these guidelines depending on how you reference model was originally written and what might be needed to adapt it into either mechanism.

The SystemVerilog Direct Programming Interface (DPI) was created to provide the most efficient way for C and SystemVerilog models to communicate with each other.

Using $system to execute a binary might be the simplest, but communication would have to go through file I/O channels.

In reply to dave_59:

Thank you for your feedback. One more question I would like to ask.
If user need to write JSON parser to handle json format with less than 1K elements, which way do you recommend?

  1. Pure SysmtemVerilog
  2. SV with DPI to call C/C++ json parser. In this case, data structure resides in C and get its pointer with chandle and pass it to DPI for APIs

Thanks in advance

In reply to likewind:

It’s better to use existing C/C++ libraries to parse JSON text files.