V0.9: Stopgap fix for br916.

Currently, when a variable expression is passed to a system task,
the expression value is stored in thread memory. Values stored
in thread memory cannot safely be passed to $strobe or $monitor,
because the thread memory may get reused or deallocated before
the $strobe or $monitor task actually executes. As a temporary
measure, we just trap this case and terminate with a "sorry"
message. A proper fix would require the expression value to be
calculated at the time the $strobe or $monitor executes, not at
the time it is called.
This commit is contained in:
Martin Whitaker 2013-02-02 18:55:29 +00:00 committed by Cary R
parent 200951275c
commit 0f4658135e
7 changed files with 63 additions and 10 deletions

View File

@ -1023,6 +1023,10 @@ static char *get_display(unsigned int *rtnsz, const struct strobe_cb_info *info)
return rtn;
}
#ifdef BR916_STOPGAP_FIX
static char br916_hint_issued = 0;
#endif
static int sys_check_args(vpiHandle callh, vpiHandle argv, const PLI_BYTE8*name,
int no_auto, int is_monitor)
{
@ -1060,6 +1064,31 @@ static int sys_check_args(vpiHandle callh, vpiHandle argv, const PLI_BYTE8*name,
case vpiIntegerVar:
case vpiTimeVar:
case vpiRealVar:
#ifdef BR916_STOPGAP_FIX
// no_auto implies either $strobe or $monitor
if (no_auto) {
switch (vpi_get(_vpiFromThr, arg)) {
case _vpiVThr:
case _vpiWord:
case _vpiString:
vpi_printf("SORRY: %s:%d: ",
vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("currently only simple signals or constant "
"expressions may be passed to %s.\n", name);
if (!br916_hint_issued) {
vpi_printf("NOTE: You can work round this by "
"assigning the desired expression "
"to an intermediate net (using a "
"continuous assignment) and passing "
"that net to %s.\n", name);
}
ret = 1;
default:
break;
}
}
#endif
case vpiSysFuncCall:
break;

View File

@ -584,6 +584,25 @@ extern void vpip_format_strength(char*str, s_vpi_value*value, unsigned bit);
extern void vpip_set_return_value(int value);
extern s_vpi_vecval vpip_calc_clog2(vpiHandle arg);
/*
* Stopgap fix for br916. We need to reject any attempt to pass a thread
* variable to $strobe or $monitor. To do this, we use some private VPI
* properties that are normally only used by the VVP thread cleanup code.
* Normally the following definitions are provided by vvp/vpi_priv.h, but
* for the stopgap fix we need to make them more widely available.
*/
#define BR916_STOPGAP_FIX
#ifdef BR916_STOPGAP_FIX
#define _vpiFromThr 0x1000001
# define _vpiNoThr 0
# define _vpiString 1
# define _vpiVThr 2
# define _vpiWord 3
# define _vpi_at_PV 4
# define _vpi_at_A 5
# define _vpi_at_APV 6
#endif
EXTERN_C_END
#endif

View File

@ -507,7 +507,7 @@ static int vpi_array_var_word_get(int code, vpiHandle ref)
case vpiAutomatic:
return (int) parent->scope->is_automatic;
#ifdef CHECK_WITH_VALGRIND
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
case _vpiFromThr:
return _vpiNoThr;
#endif
@ -699,7 +699,7 @@ static int vpi_array_vthr_A_get(int code, vpiHandle ref)
case vpiAutomatic:
return (int) parent->scope->is_automatic;
#ifdef CHECK_WITH_VALGRIND
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
case _vpiFromThr:
return _vpi_at_A;
#endif

View File

@ -51,7 +51,7 @@ static int string_get(int code, vpiHandle ref)
case vpiAutomatic:
return 0;
#ifdef CHECK_WITH_VALGRIND
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
case _vpiFromThr:
return _vpiNoThr;
#endif
@ -363,7 +363,7 @@ static int binary_get(int code, vpiHandle ref)
case vpiAutomatic:
return 0;
#ifdef CHECK_WITH_VALGRIND
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
case _vpiFromThr:
return _vpiNoThr;
#endif
@ -564,7 +564,7 @@ static int dec_get(int code, vpiHandle ref)
case vpiAutomatic:
return 0;
#ifdef CHECK_WITH_VALGRIND
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
case _vpiFromThr:
return _vpiNoThr;
#endif
@ -675,7 +675,7 @@ static int real_get(int code, vpiHandle ref)
case vpiAutomatic:
return 0;
#ifdef CHECK_WITH_VALGRIND
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
case _vpiFromThr:
return _vpiNoThr;
#endif

View File

@ -40,7 +40,7 @@
/*
* Private VPI properties that are only used in the cleanup code.
*/
#ifdef CHECK_WITH_VALGRIND
#if defined(CHECK_WITH_VALGRIND) && !defined(BR916_STOPGAP_FIX)
#define _vpiFromThr 0x1000001
# define _vpiNoThr 0
# define _vpiVThr 1

View File

@ -557,6 +557,11 @@ static int signal_get(int code, vpiHandle ref)
case vpiAutomatic:
return (int) vpip_scope(rfp)->is_automatic;
#ifdef BR916_STOPGAP_FIX
case _vpiFromThr:
return _vpiNoThr;
#endif
case _vpiNexusId:
if (rfp->msb == rfp->lsb)
return (int) (unsigned long) rfp->node;
@ -1081,7 +1086,7 @@ static int PV_get(int code, vpiHandle ref)
case vpiAutomatic:
return vpi_get(vpiAutomatic, rfp->parent);
#ifdef CHECK_WITH_VALGRIND
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
case _vpiFromThr:
return _vpi_at_PV;
#endif

View File

@ -93,7 +93,7 @@ static int vthr_vec_get(int code, vpiHandle ref)
case vpiSize:
return rfp->wid;
#ifdef CHECK_WITH_VALGRIND
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
case _vpiFromThr:
return _vpiVThr;
#endif
@ -504,7 +504,7 @@ static int vthr_word_get(int code, vpiHandle ref)
case vpiConstType:
return rfp->subtype;
#ifdef CHECK_WITH_VALGRIND
#if defined(CHECK_WITH_VALGRIND) || defined(BR916_STOPGAP_FIX)
case _vpiFromThr:
return _vpiWord;
#endif