2 * Copyright (c) 2003 Stephen Williams (steve@icarus.com)
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)
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 #ident "$Id: sys_vcdoff.c,v 1.5 2007/03/14 04:05:52 steve Exp $"
23 # include "sys_priv.h"
26 * This file contains the implementations of the VCD related
27 * functions. These are stub versions
30 # include "vpi_user.h"
39 # include "vcd_priv.h"
42 static FILE*dump_file
= 0;
44 static PLI_INT32
sys_dumpoff_calltf(PLI_BYTE8
*name
)
49 static PLI_INT32
sys_dumpon_calltf(PLI_BYTE8
*name
)
54 static PLI_INT32
sys_dumpall_calltf(PLI_BYTE8
*name
)
59 static void open_dumpfile(const char*path
)
61 dump_file
= fopen(path
, "w");
65 "VCD Error: Unable to open %s for output.\n",
69 fprintf(dump_file
, "VCD Dump suppressed.\n");
73 static PLI_INT32
sys_dumpfile_calltf(PLI_BYTE8
*name
)
77 vpiHandle sys
= vpi_handle(vpiSysTfCall
, 0);
78 vpiHandle argv
= vpi_iterate(vpiArgument
, sys
);
81 if (argv
&& (item
= vpi_scan(argv
))) {
84 if (vpi_get(vpiType
, item
) != vpiConstant
85 || vpi_get(vpiConstType
, item
) != vpiStringConst
) {
88 " %s parameter must be a string constant\n",
93 value
.format
= vpiStringVal
;
94 vpi_get_value(item
, &value
);
95 path
= strdup(value
.value
.str
);
97 vpi_free_object(argv
);
100 path
= strdup("dumpfile.vcd");
108 assert(dump_file
== 0);
116 static PLI_INT32
sys_dumpvars_calltf(PLI_BYTE8
*name
)
118 if (dump_file
== 0) {
119 open_dumpfile("dumpfile.vcd");
127 void sys_vcdoff_register()
129 s_vpi_systf_data tf_data
;
131 tf_data
.type
= vpiSysTask
;
132 tf_data
.tfname
= "$dumpall";
133 tf_data
.calltf
= sys_dumpall_calltf
;
134 tf_data
.compiletf
= 0;
136 tf_data
.user_data
= "$dumpall";
137 vpi_register_systf(&tf_data
);
139 tf_data
.type
= vpiSysTask
;
140 tf_data
.tfname
= "$dumpoff";
141 tf_data
.calltf
= sys_dumpoff_calltf
;
142 tf_data
.compiletf
= 0;
144 tf_data
.user_data
= "$dumpoff";
145 vpi_register_systf(&tf_data
);
147 tf_data
.type
= vpiSysTask
;
148 tf_data
.tfname
= "$dumpon";
149 tf_data
.calltf
= sys_dumpon_calltf
;
150 tf_data
.compiletf
= 0;
152 tf_data
.user_data
= "$dumpon";
153 vpi_register_systf(&tf_data
);
155 tf_data
.type
= vpiSysTask
;
156 tf_data
.tfname
= "$dumpfile";
157 tf_data
.calltf
= sys_dumpfile_calltf
;
158 tf_data
.compiletf
= 0;
160 tf_data
.user_data
= "$dumpfile";
161 vpi_register_systf(&tf_data
);
163 tf_data
.type
= vpiSysTask
;
164 tf_data
.tfname
= "$dumpvars";
165 tf_data
.calltf
= sys_dumpvars_calltf
;
166 tf_data
.compiletf
= sys_vcd_dumpvars_compiletf
;
168 tf_data
.user_data
= "$dumpvars";
169 vpi_register_systf(&tf_data
);
173 * $Log: sys_vcdoff.c,v $
174 * Revision 1.5 2007/03/14 04:05:52 steve
175 * VPI tasks take PLI_BYTE* by the standard.
177 * Revision 1.4 2006/10/30 22:45:38 steve
178 * Updates for Cygwin portability (pr1585922)
180 * Revision 1.3 2004/10/04 01:10:58 steve
181 * Clean up spurious trailing white space.
183 * Revision 1.2 2004/01/21 01:22:53 steve
184 * Give the vip directory its own configure and vpi_config.h
186 * Revision 1.1 2003/03/06 20:04:42 steve
187 * Add means to suppress wveform output