diff --git a/vvp/vpi_event.cc b/vvp/vpi_event.cc index f531ca2a5..f1ce84baa 100644 --- a/vvp/vpi_event.cc +++ b/vvp/vpi_event.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 2002-2017 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 @@ -63,6 +63,16 @@ char* __vpiNamedEvent::vpi_get_str(int code) return generic_get_str(code, scope_, name_, NULL); } +vpiHandle __vpiNamedEvent::vpi_put_value(p_vpi_value, int) +{ + // p_vpi_value may be NULL, and an event doesn't care + // what the value is + vvp_vector4_t val; + vvp_net_ptr_t dest(funct, 0); + vvp_send_vec4(dest, val, vthread_get_wt_context()); + + return this; +} vpiHandle __vpiNamedEvent::vpi_handle(int code) { diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index c77ebee37..d12ac50d2 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2016 Stephen Williams (steve@icarus.com) + * Copyright (c) 2008-2017 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 @@ -464,6 +464,7 @@ int vpip_time_units_from_handle(vpiHandle obj) struct __vpiSysTaskCall*task; __vpiScope*scope; struct __vpiSignal*signal; + struct __vpiNamedEvent*event; if (obj == 0) return vpip_get_time_precision(); @@ -483,6 +484,11 @@ int vpip_time_units_from_handle(vpiHandle obj) scope = vpip_scope(signal); return scope->time_units; + case vpiNamedEvent: + event = dynamic_cast<__vpiNamedEvent*>(obj); + scope = event->get_scope(); + return scope->time_units; + default: fprintf(stderr, "ERROR: vpip_time_units_from_handle called with " "object handle type=%u\n", obj->get_type_code()); @@ -1104,7 +1110,10 @@ vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp, vpip_put_value_event*put = new vpip_put_value_event; put->handle = obj; - put->value = *vp; + if (!dynamic_cast<__vpiNamedEvent*>(obj)) { + assert(vp); + put->value = *vp; + } /* Since this is a scheduled put event we must copy any pointer * data to keep it available until the event is actually run. */ switch (put->value.format) { diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 5479a1f0b..c26e6da50 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -1,7 +1,7 @@ #ifndef IVL_vpi_priv_H #define IVL_vpi_priv_H /* - * Copyright (c) 2001-2015 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2017 Stephen Williams (steve@icarus.com) * Copyright (c) 2016 CERN Michele Castellana (michele.castellana@cern.ch) * * This source code is free software; you can redistribute it @@ -479,8 +479,10 @@ class __vpiNamedEvent : public __vpiHandle { __vpiNamedEvent(__vpiScope*scope, const char*name); ~__vpiNamedEvent(); int get_type_code(void) const; + __vpiScope*get_scope(void) const { return scope_; } int vpi_get(int code); char* vpi_get_str(int code); + vpiHandle vpi_put_value(p_vpi_value val, int flags); vpiHandle vpi_handle(int code); inline void add_vpi_callback(__vpiCallback*cb)