Table of Contents Previous page Next page Index

ModelSim Documentation Bookcase

Model Technology Inc.


VPI example

The following example is a trivial, but complete VPI application.

hello.c: 
	#include "vpi_user.h"
	static hello()
	{
		vpi_printf( "Hello world!\n" );
	} 
	void RegisterMyTfs( void )
	{
		s_vpi_systf_data systf_data;
		systf_data.type        = vpiSysTask;
		systf_data.sysfunctype = vpiSysTask;
		systf_data.tfname      = "$hello";
		systf_data.calltf      = hello;
		systf_data.compiletf   = 0;
		systf_data.sizetf      = 0;
		systf_data.user_data   = 0;
		vpi_register_systf( &systf_data );
		vpi_free_object( systf_handle );
	} 
	void (*vlog_startup_routines[])() = {
		RegisterMyTfs,
		0
	}; 
hello.v: 
	module hello;
		initial $hello;
	endmodule 
Compile the VPI code for the Solaris operating system: 
	% gcc -c -I<install_dir>/include hello.c
	% ld -G -o hello.sl hello.o 
Compile the Verilog code: 
	% vlib work
	% vlog hello.v 
Simulate the design: 
	% vsim -c -pli hello.sl hello
	# Loading work.hello
	# Loading ./hello.sl
	VSIM 1> run -all
	# Hello world!
	VSIM 2> quit 


Note: A general VPI example can be found in <install_dir>/modeltech/examples/vpi.


Model Technology Inc.
Model Technology Incorporated
Voice: (503) 641-1340
Fax: (503)526-5410
www.model.com
sales@model.com
Table of Contents Previous page Next page Index

ModelSim Documentation Bookcase