1 /*
2  * Copyright (c) 2002 Stephen Williams (steve@icarus.com)
3  *
4  *    This source code is free software; you can redistribute it
5  *    and/or modify it in source code form under the terms of the GNU
6  *    General Public License as published by the Free Software
7  *    Foundation; either version 2 of the License, or (at your option)
8  *    any later version.
9  *
10  *    This program is distributed in the hope that it will be useful,
11  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *    GNU General Public License for more details.
14  *
15  *    You should have received a copy of the GNU General Public License
16  *    along with this program; if not, write to the Free Software
17  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 /*
21  * This file contains an example VPI module to demonstrate the tools
22  * to create vpi modules. To compile this module, use the iverilog-vpi
23  * command like so:
24  *
25  *    iverilog-vpi hello_vpi.c
26  *
27  * The result is the hello_vpi.vpi module. See the hello_vpi.vl
28  * program for example Verilog code to call this module.
29  */
30 
31 # include  <vpi_user.h>
32 
my_hello_calltf(char * xx)33 static PLI_INT32 my_hello_calltf(char *xx)
34 {
35       vpi_printf("Hello World, from VPI.\n");
36       return 0;
37 }
38 
my_hello_register()39 static void my_hello_register()
40 {
41       s_vpi_systf_data tf_data;
42 
43       tf_data.type      = vpiSysTask;
44       tf_data.tfname    = "$my_hello";
45       tf_data.calltf    = my_hello_calltf;
46       tf_data.compiletf = 0;
47       tf_data.sizetf    = 0;
48       vpi_register_systf(&tf_data);
49 
50 }
51 
52 /*
53  * This is a table of register functions. This table is the external
54  * symbol that the simulator looks for when loading this .vpi module.
55  */
56 void (*vlog_startup_routines[])() = {
57       my_hello_register,
58       0
59 };
60