如何编译和运行一个调用C函数的verilog程序?

时间:2015-08-16 00:47:57

标签: c verilog system-verilog edaplayground

我不是试图使用DPI调用,而是一个简单的Verilog程序,它在内部使用它的PLI来调用用C语言编写的函数。我不知道静态链接。我正在使用edaplayground。

任何人都可以告诉我应该使用哪个模拟器并切换我应该通过链接Verilog和C?我应该在Verilog中包含C文件吗?

示例代码如下

// C function implementation
#include <stdio.h>  
void hello() {
   printf ("\nHello world\n");
 }

// SV function call
module sv_pli ();

  initial begin
    $hello;
     #10  $finish;
  end

 endmodule

我想知道是否有需要注册pli,因为目前没有检测到pli调用hello。

1 个答案:

答案 0 :(得分:-1)

我将您的C代码放在一个名为test.c的新文件中,并将SV-DPI添加到您的Verilog代码中,从$ hello任务中删除美元符号以成为DPI调用。

查看模拟器输出,它应该是您的示例代码的预期结果。