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.
This commit is contained in:
Martin Whitaker 2011-10-15 18:21:37 +01:00 committed by Stephen Williams
parent 6184871242
commit 1e814cfc1e
1 changed files with 31 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005-2010 Stephen Williams <steve@icarus.com>
* Copyright (c) 2005-2011 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
@ -771,6 +771,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);
@ -780,6 +785,30 @@ static vpiHandle modpath_src_get_handle(int code, vpiHandle ref)
return 0;
}
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);
@ -946,7 +975,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,