1999-08-15 03:23:56 +02:00
|
|
|
/*
|
2010-04-12 08:39:08 +02:00
|
|
|
* Copyright (c) 1999-2010 Stephen Williams (steve@icarus.com)
|
1999-08-15 03:23:56 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
|
2008-06-06 04:25:19 +02:00
|
|
|
#include "sys_priv.h"
|
|
|
|
|
#include <string.h>
|
2007-07-20 19:38:50 +02:00
|
|
|
|
2010-10-04 18:31:01 +02:00
|
|
|
static PLI_INT32 sys_finish_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name)
|
2007-07-20 19:38:50 +02:00
|
|
|
{
|
2010-04-14 06:29:15 +02:00
|
|
|
vpiHandle callh, argv;
|
2007-07-20 19:38:50 +02:00
|
|
|
s_vpi_value val;
|
|
|
|
|
long diag_msg = 1;
|
|
|
|
|
|
|
|
|
|
/* Get the argument list and look for the diagnostic message level. */
|
|
|
|
|
callh = vpi_handle(vpiSysTfCall, 0);
|
|
|
|
|
argv = vpi_iterate(vpiArgument, callh);
|
|
|
|
|
if (argv) {
|
2010-04-14 06:29:15 +02:00
|
|
|
vpiHandle arg = vpi_scan(argv);
|
2007-07-20 19:38:50 +02:00
|
|
|
vpi_free_object(argv);
|
|
|
|
|
val.format = vpiIntVal;
|
|
|
|
|
vpi_get_value(arg, &val);
|
|
|
|
|
diag_msg = val.value.integer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp((char*)name, "$stop") == 0) {
|
|
|
|
|
vpi_control(vpiStop, diag_msg);
|
2003-02-21 04:24:03 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-20 19:38:50 +02:00
|
|
|
vpi_control(vpiFinish, diag_msg);
|
1999-08-15 03:23:56 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sys_finish_register()
|
|
|
|
|
{
|
|
|
|
|
s_vpi_systf_data tf_data;
|
2010-04-12 08:39:08 +02:00
|
|
|
vpiHandle res;
|
1999-08-15 03:23:56 +02:00
|
|
|
|
|
|
|
|
tf_data.type = vpiSysTask;
|
|
|
|
|
tf_data.tfname = "$finish";
|
|
|
|
|
tf_data.calltf = sys_finish_calltf;
|
2008-06-06 04:25:19 +02:00
|
|
|
tf_data.compiletf = sys_one_opt_numeric_arg_compiletf;
|
1999-08-15 03:23:56 +02:00
|
|
|
tf_data.sizetf = 0;
|
2008-06-06 04:25:19 +02:00
|
|
|
tf_data.user_data = "$finish";
|
2010-04-12 08:39:08 +02:00
|
|
|
res = vpi_register_systf(&tf_data);
|
|
|
|
|
vpip_make_systf_system_defined(res);
|
2001-01-01 20:33:44 +01:00
|
|
|
|
|
|
|
|
tf_data.type = vpiSysTask;
|
|
|
|
|
tf_data.tfname = "$stop";
|
|
|
|
|
tf_data.calltf = sys_finish_calltf;
|
2008-06-06 04:25:19 +02:00
|
|
|
tf_data.compiletf = sys_one_opt_numeric_arg_compiletf;
|
2001-01-01 20:33:44 +01:00
|
|
|
tf_data.sizetf = 0;
|
2008-06-06 04:25:19 +02:00
|
|
|
tf_data.user_data = "$stop";
|
2010-04-12 08:39:08 +02:00
|
|
|
res = vpi_register_systf(&tf_data);
|
|
|
|
|
vpip_make_systf_system_defined(res);
|
1999-08-15 03:23:56 +02:00
|
|
|
}
|