Vengineerの妄想(準備期間)

人生は短いけど、長いです。人生を楽しみましょう!

Aldec : vlog -dpiheader


無償ツールで実践する「ハード・ソフト協調検証」(4) ―― SystemVerilog側のDPI-Cの記述を作成するのリスト6の部分をvlog -dpiheader コマンドでヘッダ部を生成してみたのが、下記のコード。
C/C++側から見た各関数内部でVerilogDPIExpInitとVerilogDPIExpCallを使って、SystemVerilog側の世界にアクセスしている。

ModelSimでは、vsim -dpiexportobj コマンドで生成したオブジェクトファイル内で同じようなことをしているのだろうな?

#define DPI_DPI_HEADER_H

#include "svdpi.h"

#ifdef __cplusplus
extern "C" {
#endif
DPI_DLLISPEC const void* VerilogDPIExpInit( const char* _subprogram_name, const char* _description );
DPI_DLLISPEC void VerilogDPIExpCall( const void* _handle, ... );

static void bfm_write32(unsigned int32_t _port0, unsigned int32_t _port1)
{
	static const void* handle = (void*)0;
	if(!handle) handle = VerilogDPIExpInit("bfm_write32","IIUIIU.");
	VerilogDPIExpCall(handle,_port0,_port1);
}
static void bfm_read32(unsigned int32_t _port0, unsigned int32_t *_port1)
{
	static const void* handle = (void*)0;
	if(!handle) handle = VerilogDPIExpInit("bfm_read32","IIUOIU.");
	VerilogDPIExpCall(handle,_port0,_port1);
}
static void bfm_write16(unsigned int32_t _port0, unsigned short int _port1)
{
	static const void* handle = (void*)0;
	if(!handle) handle = VerilogDPIExpInit("bfm_write16","IIUIiU.");
	VerilogDPIExpCall(handle,_port0,_port1);
}
static void bfm_read16(unsigned int32_t _port0, unsigned short int *_port1)
{
	static const void* handle = (void*)0;
	if(!handle) handle = VerilogDPIExpInit("bfm_read16","IIUOiU.");
	VerilogDPIExpCall(handle,_port0,_port1);
}
static void bfm_write8(unsigned int32_t _port0, unsigned char _port1)
{
	static const void* handle = (void*)0;
	if(!handle) handle = VerilogDPIExpInit("bfm_write8","IIUIBU.");
	VerilogDPIExpCall(handle,_port0,_port1);
}
static void bfm_read8(unsigned int32_t _port0, unsigned char *_port1)
{
	static const void* handle = (void*)0;
	if(!handle) handle = VerilogDPIExpInit("bfm_read8","IIUOBU.");
	VerilogDPIExpCall(handle,_port0,_port1);
}
static void bfm_nop(int32_t _port0)
{
	static const void* handle = (void*)0;
	if(!handle) handle = VerilogDPIExpInit("bfm_nop","IIS.");
	VerilogDPIExpCall(handle,_port0);
}
#ifdef __cplusplus
}
#endif
#endif

検証、Verification、Aldec、SystemVerilog