191 lines
4.6 KiB
C
191 lines
4.6 KiB
C
/*
|
|
* Copyright (c) 2003 Stephen Williams (steve@icarus.com)
|
|
*
|
|
* This source code is free software; you can redistribute it
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
* General Public License as published by the Free Software
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
*/
|
|
#ifdef HAVE_CVS_IDENT
|
|
#ident "$Id: sys_vcdoff.c,v 1.5 2007/03/14 04:05:52 steve Exp $"
|
|
#endif
|
|
|
|
# include "sys_priv.h"
|
|
|
|
/*
|
|
* This file contains the implementations of the VCD related
|
|
* functions. These are stub versions
|
|
*/
|
|
|
|
# include "vpi_user.h"
|
|
# include <stdio.h>
|
|
# include <stdlib.h>
|
|
# include <string.h>
|
|
# include <assert.h>
|
|
# include <time.h>
|
|
#ifdef HAVE_MALLOC_H
|
|
# include <malloc.h>
|
|
#endif
|
|
# include "vcd_priv.h"
|
|
|
|
|
|
static FILE*dump_file = 0;
|
|
|
|
static PLI_INT32 sys_dumpoff_calltf(PLI_BYTE8*name)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static PLI_INT32 sys_dumpon_calltf(PLI_BYTE8*name)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static PLI_INT32 sys_dumpall_calltf(PLI_BYTE8*name)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static void open_dumpfile(const char*path)
|
|
{
|
|
dump_file = fopen(path, "w");
|
|
|
|
if (dump_file == 0) {
|
|
vpi_mcd_printf(6,
|
|
"VCD Error: Unable to open %s for output.\n",
|
|
path);
|
|
return;
|
|
} else {
|
|
fprintf(dump_file, "VCD Dump suppressed.\n");
|
|
}
|
|
}
|
|
|
|
static PLI_INT32 sys_dumpfile_calltf(PLI_BYTE8*name)
|
|
{
|
|
char*path;
|
|
|
|
vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
|
|
vpiHandle argv = vpi_iterate(vpiArgument, sys);
|
|
vpiHandle item;
|
|
|
|
if (argv && (item = vpi_scan(argv))) {
|
|
s_vpi_value value;
|
|
|
|
if (vpi_get(vpiType, item) != vpiConstant
|
|
|| vpi_get(vpiConstType, item) != vpiStringConst) {
|
|
vpi_mcd_printf(6,
|
|
"VCD Error:"
|
|
" %s parameter must be a string constant\n",
|
|
name);
|
|
return 0;
|
|
}
|
|
|
|
value.format = vpiStringVal;
|
|
vpi_get_value(item, &value);
|
|
path = strdup(value.value.str);
|
|
|
|
vpi_free_object(argv);
|
|
|
|
} else {
|
|
path = strdup("dumpfile.vcd");
|
|
}
|
|
|
|
if (dump_file) {
|
|
fclose(dump_file);
|
|
dump_file = 0;
|
|
}
|
|
|
|
assert(dump_file == 0);
|
|
open_dumpfile(path);
|
|
|
|
free(path);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name)
|
|
{
|
|
if (dump_file == 0) {
|
|
open_dumpfile("dumpfile.vcd");
|
|
if (dump_file == 0)
|
|
return 0;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void sys_vcdoff_register()
|
|
{
|
|
s_vpi_systf_data tf_data;
|
|
|
|
tf_data.type = vpiSysTask;
|
|
tf_data.tfname = "$dumpall";
|
|
tf_data.calltf = sys_dumpall_calltf;
|
|
tf_data.compiletf = 0;
|
|
tf_data.sizetf = 0;
|
|
tf_data.user_data = "$dumpall";
|
|
vpi_register_systf(&tf_data);
|
|
|
|
tf_data.type = vpiSysTask;
|
|
tf_data.tfname = "$dumpoff";
|
|
tf_data.calltf = sys_dumpoff_calltf;
|
|
tf_data.compiletf = 0;
|
|
tf_data.sizetf = 0;
|
|
tf_data.user_data = "$dumpoff";
|
|
vpi_register_systf(&tf_data);
|
|
|
|
tf_data.type = vpiSysTask;
|
|
tf_data.tfname = "$dumpon";
|
|
tf_data.calltf = sys_dumpon_calltf;
|
|
tf_data.compiletf = 0;
|
|
tf_data.sizetf = 0;
|
|
tf_data.user_data = "$dumpon";
|
|
vpi_register_systf(&tf_data);
|
|
|
|
tf_data.type = vpiSysTask;
|
|
tf_data.tfname = "$dumpfile";
|
|
tf_data.calltf = sys_dumpfile_calltf;
|
|
tf_data.compiletf = 0;
|
|
tf_data.sizetf = 0;
|
|
tf_data.user_data = "$dumpfile";
|
|
vpi_register_systf(&tf_data);
|
|
|
|
tf_data.type = vpiSysTask;
|
|
tf_data.tfname = "$dumpvars";
|
|
tf_data.calltf = sys_dumpvars_calltf;
|
|
tf_data.compiletf = sys_vcd_dumpvars_compiletf;
|
|
tf_data.sizetf = 0;
|
|
tf_data.user_data = "$dumpvars";
|
|
vpi_register_systf(&tf_data);
|
|
}
|
|
|
|
/*
|
|
* $Log: sys_vcdoff.c,v $
|
|
* Revision 1.5 2007/03/14 04:05:52 steve
|
|
* VPI tasks take PLI_BYTE* by the standard.
|
|
*
|
|
* Revision 1.4 2006/10/30 22:45:38 steve
|
|
* Updates for Cygwin portability (pr1585922)
|
|
*
|
|
* Revision 1.3 2004/10/04 01:10:58 steve
|
|
* Clean up spurious trailing white space.
|
|
*
|
|
* Revision 1.2 2004/01/21 01:22:53 steve
|
|
* Give the vip directory its own configure and vpi_config.h
|
|
*
|
|
* Revision 1.1 2003/03/06 20:04:42 steve
|
|
* Add means to suppress wveform output
|
|
*
|
|
*/
|
|
|