From f8bc2b6198a59711b56444e295c418e3c73c8f28 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 15 Oct 2011 20:26:26 +0100 Subject: [PATCH] V0.9 Fix for pr3420994. The VPI object data model diagrams show a one to many relationship between the "mod path" and "path term" objects. This means that the correct way to obtain handles to "path term" objects is to use the vpi_iterate and vpi_scan functions. Support for the old method of obtaining handles to "path term" objects using the vpi_handle function is retained for backwards compatibility. --- vvp/delay.cc | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/vvp/delay.cc b/vvp/delay.cc index 9b6698467..e5b16f362 100644 --- a/vvp/delay.cc +++ b/vvp/delay.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2009 Stephen Williams + * Copyright (c) 2005-2011 Stephen Williams * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -749,6 +749,11 @@ static vpiHandle modpath_src_get_handle(int code, vpiHandle ref) return vpi_handle(scope); } + // Handles to path term objects should really be obtained via + // the vpi_iterate and vpi_scan functions. Continue to allow + // them to be obtained here for backwards compatibility with + // older versions of Icarus Verilog. + case vpiModPathIn: return vpi_handle(&rfp->path_term_in); @@ -758,7 +763,31 @@ static vpiHandle modpath_src_get_handle(int code, vpiHandle ref) return 0; } -static vpiHandle modpath_src_index ( vpiHandle ref, int code ) +static vpiHandle modpath_src_iterate(int code, vpiHandle ref) +{ + struct __vpiModPathSrc*rfp = vpip_modpath_src_from_handle(ref); + assert(rfp); + + // Module paths with multiple sources or destinations are + // currently represented by a separate modpath object for + // each source/destination combination, so there is only + // ever one input path term and one output path term. + switch (code) { + case vpiModPathIn: { + vpiHandle*args = (vpiHandle*)calloc(1, sizeof(vpiHandle*)); + args[0] = vpi_handle(&rfp->path_term_in); + return vpip_make_iterator(1, args, true); + } + case vpiModPathOut: { + vpiHandle*args = (vpiHandle*)calloc(1, sizeof(vpiHandle*)); + args[0] = vpi_handle(&rfp->dest->path_term_out); + return vpip_make_iterator(1, args, true); + } + } + return 0; +} + +static vpiHandle modpath_src_index ( vpiHandle ref, int) { assert( (ref->vpi_type->type_code == vpiModPathIn ) ); return 0 ; @@ -919,7 +948,7 @@ static const struct __vpirt vpip_modpath_src_rt = { modpath_src_get_value, modpath_src_put_value, modpath_src_get_handle, - 0, /* modpath_src_iterate,*/ + modpath_src_iterate, modpath_src_index, modpath_src_free_object, modpath_src_get_delays,