From 5f8f7bc6fc90781cf9e60e41d16fc3ba960c6fea Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 16 Apr 2009 11:57:00 -0700 Subject: [PATCH] Add support for dumping non-constant array selects as a constant select. Dumping array words is an enhancement that we have added to Icarus. The problem was that if you wanted to dump the whole array you would like to use a for loop as follows: for (lp = 0; lp < max ; lp = lp + 1) $dumpvars(0, array[lp]); This used to work, but some of the VPI rework broke it because it counted on the word select to be constant. This patch restores the functionality by converting the variable word select into a constant word select in the calltf routine. This is done without warning and only for the $dumpvars() routine. Adding this functionality necessitated adding support for vpiIndex to the &A<> routines. --- vpi/sys_lxt.c | 9 ++++++++- vpi/sys_lxt2.c | 9 ++++++++- vpi/sys_vcd.c | 9 ++++++++- vpi/vcd_priv.c | 13 ++++++++++++- vvp/array.cc | 3 +++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/vpi/sys_lxt.c b/vpi/sys_lxt.c index cb50d8a69..10311c203 100644 --- a/vpi/sys_lxt.c +++ b/vpi/sys_lxt.c @@ -551,8 +551,15 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) switch (vpi_get(vpiType, item)) { case vpiNet: type = "wire"; if(0){ - case vpiIntegerVar: case vpiMemoryWord: + if (vpi_get(vpiConstantSelect, item) == 0) { + /* Turn a non-constant array word select into a + * constant word select. */ + vpiHandle array = vpi_handle(vpiParent, item); + PLI_INT32 index = vpi_get(vpiIndex, item); + item = vpi_handle_by_index(array, index); + } + case vpiIntegerVar: case vpiTimeVar: case vpiReg: type = "reg"; } diff --git a/vpi/sys_lxt2.c b/vpi/sys_lxt2.c index e31f8995a..e4776dc1e 100644 --- a/vpi/sys_lxt2.c +++ b/vpi/sys_lxt2.c @@ -563,8 +563,15 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) switch (vpi_get(vpiType, item)) { case vpiNet: type = "wire"; if(0){ - case vpiIntegerVar: case vpiMemoryWord: + if (vpi_get(vpiConstantSelect, item) == 0) { + /* Turn a non-constant array word select into a + * constant word select. */ + vpiHandle array = vpi_handle(vpiParent, item); + PLI_INT32 index = vpi_get(vpiIndex, item); + item = vpi_handle_by_index(array, index); + } + case vpiIntegerVar: case vpiTimeVar: case vpiReg: type = "reg"; } diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index bcb678826..8f2b1d531 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -519,8 +519,15 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) switch (vpi_get(vpiType, item)) { case vpiNet: type = "wire"; if(0){ - case vpiIntegerVar: case vpiMemoryWord: + if (vpi_get(vpiConstantSelect, item) == 0) { + /* Turn a non-constant array word select into a + * constant word select. */ + vpiHandle array = vpi_handle(vpiParent, item); + PLI_INT32 index = vpi_get(vpiIndex, item); + item = vpi_handle_by_index(array, index); + } + case vpiIntegerVar: case vpiTimeVar: case vpiReg: type = "reg"; } diff --git a/vpi/vcd_priv.c b/vpi/vcd_priv.c index 4418dbb49..e3e2c6af0 100644 --- a/vpi/vcd_priv.c +++ b/vpi/vcd_priv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2009 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 @@ -246,6 +246,16 @@ PLI_INT32 sys_dumpvars_compiletf(PLI_BYTE8 *name) while ((arg=vpi_scan(argv)) != NULL) { switch(vpi_get(vpiType, arg)) { case vpiMemoryWord: +/* + * We need to allow non-constant selects to support the following: + * + * for (lp = 0; lp < max ; lp = lp + 1) $dumpvars(0, array[lp]); + * + * We need to do a direct callback on the selected element vs using + * the &A<> structure. The later will not give us what we want. + * This is implemented in the calltf routine. + */ +#if 0 if (vpi_get(vpiConstantSelect, arg) == 0) { vpi_printf("ERROR: %s:%d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); @@ -253,6 +263,7 @@ PLI_INT32 sys_dumpvars_compiletf(PLI_BYTE8 *name) vpi_get_str(vpiType, arg)); vpi_control(vpiFinish, 1); } +#endif /* The module types. */ case vpiModule: case vpiTask: diff --git a/vvp/array.cc b/vvp/array.cc index 4bac1fe3c..270544fce 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -674,6 +674,9 @@ static int vpi_array_vthr_A_get(int code, vpiHandle ref) case vpiRightRange: return parent->lsb.value; + case vpiIndex: + return (int)obj->get_address() + parent->first_addr.value; + case vpiAutomatic: return (int) parent->scope->is_automatic;