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.
This commit is contained in:
Cary R 2008-01-06 17:52:55 -08:00 committed by Stephen Williams
parent d85683965d
commit 4263f29044
3 changed files with 15 additions and 20 deletions

View File

@ -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_);
}

View File

@ -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

View File

@ -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;