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:
parent
f7fb754ee8
commit
5f8f7bc6fc
|
|
@ -551,8 +551,15 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
switch (vpi_get(vpiType, item)) {
|
switch (vpi_get(vpiType, item)) {
|
||||||
|
|
||||||
case vpiNet: type = "wire"; if(0){
|
case vpiNet: type = "wire"; if(0){
|
||||||
case vpiIntegerVar:
|
|
||||||
case vpiMemoryWord:
|
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 vpiTimeVar:
|
||||||
case vpiReg: type = "reg"; }
|
case vpiReg: type = "reg"; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -563,8 +563,15 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
switch (vpi_get(vpiType, item)) {
|
switch (vpi_get(vpiType, item)) {
|
||||||
|
|
||||||
case vpiNet: type = "wire"; if(0){
|
case vpiNet: type = "wire"; if(0){
|
||||||
case vpiIntegerVar:
|
|
||||||
case vpiMemoryWord:
|
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 vpiTimeVar:
|
||||||
case vpiReg: type = "reg"; }
|
case vpiReg: type = "reg"; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -519,8 +519,15 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
switch (vpi_get(vpiType, item)) {
|
switch (vpi_get(vpiType, item)) {
|
||||||
|
|
||||||
case vpiNet: type = "wire"; if(0){
|
case vpiNet: type = "wire"; if(0){
|
||||||
case vpiIntegerVar:
|
|
||||||
case vpiMemoryWord:
|
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 vpiTimeVar:
|
||||||
case vpiReg: type = "reg"; }
|
case vpiReg: type = "reg"; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* 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) {
|
while ((arg=vpi_scan(argv)) != NULL) {
|
||||||
switch(vpi_get(vpiType, arg)) {
|
switch(vpi_get(vpiType, arg)) {
|
||||||
case vpiMemoryWord:
|
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) {
|
if (vpi_get(vpiConstantSelect, arg) == 0) {
|
||||||
vpi_printf("ERROR: %s:%d: ", vpi_get_str(vpiFile, callh),
|
vpi_printf("ERROR: %s:%d: ", vpi_get_str(vpiFile, callh),
|
||||||
(int)vpi_get(vpiLineNo, callh));
|
(int)vpi_get(vpiLineNo, callh));
|
||||||
|
|
@ -253,6 +263,7 @@ PLI_INT32 sys_dumpvars_compiletf(PLI_BYTE8 *name)
|
||||||
vpi_get_str(vpiType, arg));
|
vpi_get_str(vpiType, arg));
|
||||||
vpi_control(vpiFinish, 1);
|
vpi_control(vpiFinish, 1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* The module types. */
|
/* The module types. */
|
||||||
case vpiModule:
|
case vpiModule:
|
||||||
case vpiTask:
|
case vpiTask:
|
||||||
|
|
|
||||||
|
|
@ -674,6 +674,9 @@ static int vpi_array_vthr_A_get(int code, vpiHandle ref)
|
||||||
case vpiRightRange:
|
case vpiRightRange:
|
||||||
return parent->lsb.value;
|
return parent->lsb.value;
|
||||||
|
|
||||||
|
case vpiIndex:
|
||||||
|
return (int)obj->get_address() + parent->first_addr.value;
|
||||||
|
|
||||||
case vpiAutomatic:
|
case vpiAutomatic:
|
||||||
return (int) parent->scope->is_automatic;
|
return (int) parent->scope->is_automatic;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue