From 92e4ca3a925b318ff86a0fae25d7884e6051506e Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 12 Dec 2013 17:07:47 -0800 Subject: [PATCH] Report that vpi_handle_by_index() is not supported for a vpiNet --- vvp/vpi_priv.h | 1 + vvp/vpi_signal.cc | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index bd0d743b5..0f6c0b693 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -279,6 +279,7 @@ struct __vpiSignal : public __vpiHandle { vpiHandle vpi_put_value(p_vpi_value val, int flags); vpiHandle vpi_handle(int code); vpiHandle vpi_iterate(int code); + vpiHandle vpi_index(int idx); union { // The scope or parent array that contains me. vpiHandle parent; diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index 71bc453dc..30fc9f11d 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -653,6 +653,24 @@ static vpiHandle signal_iterate(int code, vpiHandle ref) return 0; } +static vpiHandle signal_index(int idx, vpiHandle ref) +{ + struct __vpiSignal*rfp = dynamic_cast<__vpiSignal*>(ref); + assert(rfp); + /* Check to see if the index is in range. */ + if (rfp->msb >= rfp->lsb) { + if ((idx > rfp->msb) || (idx < rfp->lsb)) return 0; + } else { + if ((idx < rfp->msb) || (idx > rfp->lsb)) return 0; + } + /* Return a handle for the individual bit. */ + cerr << "Sorry: Icarus does not currently support " + << "vpi_get_handle_by_index() for " + << vpi_get_str(vpiType, ref); + cerr << " objects (" << vpi_get_str(vpiName, ref) << ")." << endl; + return 0; +} + static unsigned signal_width(const struct __vpiSignal*rfp) { unsigned wid = (rfp->msb >= rfp->lsb) @@ -895,6 +913,9 @@ vpiHandle __vpiSignal::vpi_handle(int code) vpiHandle __vpiSignal::vpi_iterate(int code) { return signal_iterate(code, this); } +vpiHandle __vpiSignal::vpi_index(int idx) +{ return signal_index(idx, this); } + struct signal_reg : public __vpiSignal { inline signal_reg() { } int get_type_code(void) const { return vpiReg; }