From 4263f290442fef66eaac73280c315fd4a2f9edd7 Mon Sep 17 00:00:00 2001 From: Cary R Date: Sun, 6 Jan 2008 17:52:55 -0800 Subject: [PATCH] Schedule sfunc invocations to avoid recursion and clean up. This patch schedules the input value change to .sfuns calls to avoid potential recursion problems. It also cleans up two put_value calls that did unneeded loops when putting VectorVals and the width was greaten than 32 bits. --- vvp/sfunc.cc | 10 ++++++---- vvp/sfunc.h | 16 ++++------------ vvp/vpi_tasks.cc | 9 +++++---- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/vvp/sfunc.cc b/vvp/sfunc.cc index 074d329da..b4d8595d8 100644 --- a/vvp/sfunc.cc +++ b/vvp/sfunc.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2007 Stephen Williams (steve@icarus.com) + * Copyright (c) 2006-2008 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 @@ -51,7 +51,8 @@ void sfunc_core::recv_vec4_from_inputs(unsigned port) obj->bits = value(port); - invoke_function_(); + /* Schedule the actual call after this finishes. */ + schedule_generic(this, 0, false); } void sfunc_core::recv_real_from_inputs(unsigned port) @@ -64,10 +65,11 @@ void sfunc_core::recv_real_from_inputs(unsigned port) obj->value = value_r(port); - invoke_function_(); + /* Schedule the actual call after this finishes. */ + schedule_generic(this, 0, false); } -void sfunc_core::invoke_function_() +void sfunc_core::run_run() { vpip_execute_vpi_call(0, sys_); } diff --git a/vvp/sfunc.h b/vvp/sfunc.h index a3b203cb3..8b6b8eb13 100644 --- a/vvp/sfunc.h +++ b/vvp/sfunc.h @@ -1,7 +1,7 @@ #ifndef __sfunc_H #define __sfunc_H /* - * Copyright (c) 2006 Stephen Williams (steve@icarus.com) + * Copyright (c) 2006-2008 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 @@ -18,13 +18,10 @@ * 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: sfunc.h,v 1.1 2006/06/18 04:15:50 steve Exp $" -#endif # include "pointers.h" -class sfunc_core : public vvp_wide_fun_core { +class sfunc_core : public vvp_wide_fun_core, protected vvp_gen_event_s { public: sfunc_core(vvp_net_t*ptr, vpiHandle sys, unsigned argc, vpiHandle*argv); @@ -34,7 +31,8 @@ class sfunc_core : public vvp_wide_fun_core { void recv_vec4_from_inputs(unsigned port); void recv_real_from_inputs(unsigned port); - void invoke_function_(); + void run_run(); + private: vpiHandle sys_; @@ -42,10 +40,4 @@ class sfunc_core : public vvp_wide_fun_core { vpiHandle*argv_; }; -/* - * $Log: sfunc.h,v $ - * Revision 1.1 2006/06/18 04:15:50 steve - * Add support for system functions in continuous assignments. - * - */ #endif diff --git a/vvp/vpi_tasks.cc b/vvp/vpi_tasks.cc index 794f90c3c..7cace3ae3 100644 --- a/vvp/vpi_tasks.cc +++ b/vvp/vpi_tasks.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2008 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 @@ -224,8 +224,8 @@ static vpiHandle sysfunc_put_value(vpiHandle ref, p_vpi_value vp) unsigned long aval = vp->value.vector[word].aval; unsigned long bval = vp->value.vector[word].bval; - for (unsigned idx = 0 ; (wdx+idx) < (unsigned)rfp->vwid ; - idx += 1) + for (unsigned idx = 0 ; (wdx+idx) < (unsigned)rfp->vwid && + idx < 32; idx += 1) { int bit = (aval&1) | ((bval<<1)&2); vvp_bit4_t bit4; @@ -339,7 +339,8 @@ static vpiHandle sysfunc_put_4net_value(vpiHandle ref, p_vpi_value vp) unsigned long aval = vp->value.vector[word].aval; unsigned long bval = vp->value.vector[word].bval; - for (unsigned idx = 0 ; (wdx+idx) < vwid ; idx += 1) { + for (unsigned idx = 0 ; (wdx+idx) < vwid && idx < 32; + idx += 1) { int bit = (aval&1) | ((bval<<1)&2); vvp_bit4_t bit4;