Accept memory words as parameter to $display.

This commit is contained in:
steve 2000-02-13 19:18:27 +00:00
parent e77bcf6910
commit a8d787bd66
7 changed files with 85 additions and 12 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: t-vvm.cc,v 1.98 2000/01/18 04:53:57 steve Exp $"
#ident "$Id: t-vvm.cc,v 1.99 2000/02/13 19:18:27 steve Exp $"
#endif
# include <iostream>
@ -581,8 +581,26 @@ void vvm_parm_rval::expr_ident(const NetEIdent*expr)
void vvm_parm_rval::expr_memory(const NetEMemory*mem)
{
assert(mem->index() == 0);
result = string("&") + mangle(mem->name()) + ".base";
if (mem->index() == 0) {
/* If the expression is a memory without an index, then
return the handle for the memory object. System tasks
can take such things as parameters. */
result = string("&") + mangle(mem->name()) + ".base";
} else if (const NetEConst*idx = dynamic_cast<const NetEConst*>(mem->index())){
/* If the expression is a memory with a constant index,
then generate a call to vpi_handle_by_index() to get
the memory word handle. */
unsigned long val = idx->value().as_ulong();
ostrstream res;
res << "vpi_handle_by_index(&" << mangle(mem->name()) <<
".base, " << val << ")" << ends;
result = res.str();
} else {
assert(0);
}
}
void vvm_parm_rval::expr_scope(const NetEScope*escope)
@ -2041,6 +2059,9 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
* Revision 1.99 2000/02/13 19:18:27 steve
* Accept memory words as parameter to $display.
*
* Revision 1.98 2000/01/18 04:53:57 steve
* missing break is switch.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: sys_display.c,v 1.9 1999/11/07 02:25:07 steve Exp $"
#ident "$Id: sys_display.c,v 1.10 2000/02/13 19:18:27 steve Exp $"
#endif
# include "vpi_user.h"
@ -188,6 +188,7 @@ static void do_display(struct strobe_cb_info*info)
case vpiNet:
case vpiReg:
case vpiMemoryWord:
value.format = vpiBinStrVal;
vpi_get_value(item, &value);
vpi_printf("%s", value.value.str);
@ -412,6 +413,9 @@ void sys_display_register()
/*
* $Log: sys_display.c,v $
* Revision 1.10 2000/02/13 19:18:27 steve
* Accept memory words as parameter to $display.
*
* Revision 1.9 1999/11/07 02:25:07 steve
* Add the $monitor implementation.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_user.h,v 1.11 2000/01/20 06:04:55 steve Exp $"
#ident "$Id: vpi_user.h,v 1.12 2000/02/13 19:18:28 steve Exp $"
#endif
#ifdef __cplusplus
@ -207,6 +207,7 @@ extern void vpi_sim_control(int operation, ...);
extern vpiHandle vpi_handle(int type, vpiHandle ref);
extern vpiHandle vpi_iterate(int type, vpiHandle ref);
extern vpiHandle vpi_scan(vpiHandle iter);
extern vpiHandle vpi_handle_by_index(vpiHandle ref, int index);
extern void vpi_get_time(vpiHandle obj, s_vpi_time*t);
extern int vpi_get(int property, vpiHandle ref);
@ -227,6 +228,9 @@ extern void (*vlog_startup_routines[])();
/*
* $Log: vpi_user.h,v $
* Revision 1.12 2000/02/13 19:18:28 steve
* Accept memory words as parameter to $display.
*
* Revision 1.11 2000/01/20 06:04:55 steve
* $dumpall checkpointing in VCD dump.
*

View File

@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: Makefile.in,v 1.18 2000/01/24 00:18:20 steve Exp $"
#ident "$Id: Makefile.in,v 1.19 2000/02/13 19:18:28 steve Exp $"
#
#
SHELL = /bin/sh
@ -117,4 +117,4 @@ uninstall:
rm -f $(includedir)/vpi_priv.h
-include $(patsubst %.o, dep/%.d, $O)
-include $(patsubst %.o, dep/%.d, $O $P)

View File

@ -26,7 +26,7 @@
* Picture Elements, Inc., 777 Panoramic Way, Berkeley, CA 94704.
*/
#if !defined(WINNT)
#ident "$Id: vpi_memory.c,v 1.3 1999/12/15 04:15:17 steve Exp $"
#ident "$Id: vpi_memory.c,v 1.4 2000/02/13 19:18:28 steve Exp $"
#endif
# include "vpi_priv.h"
@ -82,6 +82,23 @@ static vpiHandle memory_iterate(int code, vpiHandle ref)
}
}
static vpiHandle memory_index(vpiHandle ref, int index)
{
struct __vpiMemory*rfp = (struct __vpiMemory*)ref;
assert(ref->vpi_type->type_code==vpiMemory);
if (rfp->args == 0) {
unsigned idx;
rfp->args = calloc(rfp->size, sizeof(vpiHandle));
for (idx = 0 ; idx < rfp->size ; idx += 1)
rfp->args[idx] = &rfp->words[idx].base;
}
if (index > rfp->size) return 0;
if (index < 0) return 0;
return &(rfp->words[index].base);
}
static int memory_word_get(int code, vpiHandle ref)
{
struct __vpiMemoryWord*rfp = (struct __vpiMemoryWord*)ref;
@ -128,6 +145,15 @@ static vpiHandle memory_word_put(vpiHandle ref, p_vpi_value val,
return 0;
}
static void memory_word_get_value(vpiHandle ref, s_vpi_value*vp)
{
struct __vpiMemoryWord*rfp = (struct __vpiMemorWord*)ref;
assert(ref->vpi_type->type_code==vpiMemoryWord);
vpip_bits_get_value(rfp->mem->bits+rfp->index*rfp->mem->width,
rfp->mem->width, vp);
}
static const struct __vpirt vpip_memory_rt = {
vpiMemory,
memory_get,
@ -135,16 +161,18 @@ static const struct __vpirt vpip_memory_rt = {
0,
0,
0,
memory_iterate
memory_iterate,
memory_index
};
static const struct __vpirt vpip_memory_word_rt = {
vpiMemoryWord,
memory_word_get,
0,
0,
memory_word_get_value,
memory_word_put,
0,
0,
0
};
@ -171,6 +199,9 @@ vpiHandle vpip_make_memory(struct __vpiMemory*ref, const char*name,
}
/*
* $Log: vpi_memory.c,v $
* Revision 1.4 2000/02/13 19:18:28 steve
* Accept memory words as parameter to $display.
*
* Revision 1.3 1999/12/15 04:15:17 steve
* Implement vpi_put_value for memory words.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_priv.c,v 1.3 2000/01/20 06:04:55 steve Exp $"
#ident "$Id: vpi_priv.c,v 1.4 2000/02/13 19:18:28 steve Exp $"
#endif
# include "vpi_priv.h"
@ -145,6 +145,12 @@ vpiHandle vpi_iterate(int type, vpiHandle ref)
return (ref->vpi_type->iterate_)(type, ref);
}
vpiHandle vpi_handle_by_index(vpiHandle ref, int idx)
{
assert(ref->vpi_type->index_);
return (ref->vpi_type->index_)(ref, idx);
}
void vpi_printf(const char*fmt, ...)
{
va_list ap;
@ -168,6 +174,9 @@ void vpi_register_systf(const struct t_vpi_systf_data*systf)
/*
* $Log: vpi_priv.c,v $
* Revision 1.4 2000/02/13 19:18:28 steve
* Accept memory words as parameter to $display.
*
* Revision 1.3 2000/01/20 06:04:55 steve
* $dumpall checkpointing in VCD dump.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_priv.h,v 1.9 1999/12/15 04:01:14 steve Exp $"
#ident "$Id: vpi_priv.h,v 1.10 2000/02/13 19:18:28 steve Exp $"
#endif
/*
@ -66,6 +66,7 @@ struct __vpirt {
/* These methods follow references. */
vpiHandle (*handle_)(int, vpiHandle);
vpiHandle (*iterate_)(int, vpiHandle);
vpiHandle (*index_)(vpiHandle, int);
};
/*
@ -284,6 +285,9 @@ extern int vpip_finished();
/*
* $Log: vpi_priv.h,v $
* Revision 1.10 2000/02/13 19:18:28 steve
* Accept memory words as parameter to $display.
*
* Revision 1.9 1999/12/15 04:01:14 steve
* Add the VPI implementation of $readmemh.
*