首页 > 系统相关 >4、linux环境下,使用VCS进行Verilog和C语言联编译

4、linux环境下,使用VCS进行Verilog和C语言联编译

时间:2022-09-28 11:07:15浏览次数:78  
标签:vpi C语言 PLIbook VCS user linux tf data hello


`timescale 1ns / 1ns
module test;

initial
begin
$hello;
// #10 $stop;
#10 $finish;
end
endmodule
/**********************************************************************/

文件名为hello_test.v

#include <stdlib.h>    /* ANSI C standard library */
#include <stdio.h> /* ANSI C standard input/output library */
#include <stdarg.h> /* ANSI C standard arguments library */
#include "vpi_user.h" /* IEEE 1364 PLI VPI routine library */

/**********************************************************************
* calltf routine
*********************************************************************/
PLI_INT32 PLIbook_hello_calltf(PLI_BYTE8 *user_data)
{
vpi_printf("\nHello World!\n\n");
return(0);
}

/**********************************************************************
* $hello Registration Data
* (add this function name to the vlog_startup_routines array)
*********************************************************************/
void PLIbook_hello_register()
{
s_vpi_systf_data tf_data;

tf_data.type = vpiSysTask;
tf_data.sysfunctype = 0;
tf_data.tfname = "$hello";
tf_data.calltf = PLIbook_hello_calltf;
tf_data.compiletf = NULL;
tf_data.sizetf = NULL;
tf_data.user_data = NULL;
vpi_register_systf(&tf_data);
}

文件名为hello_vpi.c

#include "vpi_user.h"

/* prototypes of the PLI registration routines */
extern void PLIbook_hello_register();

void (*vlog_startup_routines[])() =
{
/*** add user entries here ***/
PLIbook_hello_register,
0 /*** final entry must be 0 ***/
};

文件名为 vpi_user.c

进行VCS编译 执行

gcc -m32 vpi_user.c hello_vpi.c -fPIC -shared -o hello.so
vcs +cli+3 +vpi -R -load ./hello.so:PLIbook_hello_register ./hello_test.v

进行NCverilog编译 执行

gcc -m32 vpi_user.c hello_vpi.c -fPIC -shared -o hello.so
ncverilog +access+r -loadvpi ./hello.so:PLIbook_hello_register ./hello_test.v

 

前提:存在vpi_user.h文件 》》》》github存在 ​​https://github.com/steveicarus/iverilog​​ (缺失的两个文件都在这里面,另一个文件去掉多余的后缀.in 就可以)

4、linux环境下,使用VCS进行Verilog和C语言联编译_#include

4、linux环境下,使用VCS进行Verilog和C语言联编译_github_02

 

 

标签:vpi,C语言,PLIbook,VCS,user,linux,tf,data,hello
From: https://blog.51cto.com/u_12504263/5718735

相关文章

  • 操作系统:Linux基本系统命令的使用
      SHANGHAI UNIVERSITY操作系统(一)实验报告   一、  实验目的与要求实验目的:1.了解Linux运行环境,熟悉交互式分时系统、多用户环境的的运行机制。2.练......
  • linux 请求命令
     1概述Curl是一个命令行实用程序,允许用户创建网络请求。Curl在Windows、Linux和Mac上皆可使用,这使它成为开发人员的首选。在本文中,我们将解释如何使用CURL......
  • C语言:全局变量与局部变量
    #include<stdio.h>intd=1;fun(intq){intd=5;d+=q++;printf("%d",d);}main(){inta=3;fun(a);d+=a++;printf("%d\n",d);......
  • linux 自动备份Oracle
    1.root用户登录oracle服务器#新建Oracle数据库备份存放目录mkdir–p/home/oracle/backup#设置目录权限为oinstall用户组的oracle用户chown-roracle:oinstall/......
  • 宝塔linux面板重启、重置等命令
    安装宝塔Centos安装脚本yuminstall-ywget&&wget-Oinstall.shhttp://download.bt.cn/install/install.sh&&shinstall.shUbuntu/Deepin安装脚本wget-Oinsta......
  • linux 测试对方地址通不通
    1. pingxxxxx  如没返回就不通 2.telnet172.25.97.1018088或 telnet172.25.97.101如果返回telnet:commandnotfound说明未安装  解决方法:安装te......
  • Linux指令
    设置环境变量#方法一:手动修改/etc/environment文件,此法为永久修改#方法二:修改~/.bashrc,在行尾添加下面的信息,此法为永久修改exportPATH=$PATH:/home/book#方法一......
  • Linux PM机制
    概述RPM即Runtimepowermanagement的缩写,之Linux提供的一套电源管理框架。核心思想是分而治之的管理思想,将具体的控制策略和控制权力下放到各个驱动。为所有device提供......
  • Linux网络日志分析与流量监控 pdf
    高清扫描版下载链接:https://pan.baidu.com/s/1OG-5_4ebMeQjSUeO_3l-IA点击这里获取提取码 ......
  • Linux新手要了解的十个知识点
    Linux对于有的新手来说,感觉无从下手,或者不知道从哪儿学起?怎么学?针对这些问题,我给大家说说新手学习Linux需要了解的十个知识点。注意大小写Linux是大小写敏感的系......