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.
This commit is contained in:
Cary R 2009-04-16 11:57:00 -07:00 committed by Stephen Williams
parent f7fb754ee8
commit 5f8f7bc6fc
5 changed files with 39 additions and 4 deletions

View File

@ -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"; }

View File

@ -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"; }

View File

@ -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"; }

View File

@ -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:

View File

@ -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;