Support $deposit to a wire or reg.

This commit is contained in:
steve 2001-04-26 00:01:33 +00:00
parent aec5841c7f
commit 8b5f62a5e5
4 changed files with 107 additions and 4 deletions

View File

@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: Makefile.in,v 1.24 2001/03/31 19:29:23 steve Exp $"
#ident "$Id: Makefile.in,v 1.25 2001/04/26 00:01:33 steve Exp $"
#
#
SHELL = /bin/sh
@ -53,7 +53,7 @@ all: system.vpi
$(CC) -Wall -I$(srcdir) -I$(srcdir)/.. $(CPPFLAGS) $(CFLAGS) -MD -c $< -o $*.o
mv $*.d dep
O = sys_table.o sys_display.o sys_finish.o sys_random.o \
O = sys_table.o sys_deposit.o sys_display.o sys_finish.o sys_random.o \
sys_readmem.o sys_readmem_lex.o sys_time.o sys_vcd.o \
mt19937int.o

84
vpi/sys_deposit.c Normal file
View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 1999 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000 Stephan Boettcher <stephan@nevis.columbia.edu>
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: sys_deposit.c,v 1.1 2001/04/26 00:01:33 steve Exp $"
#endif
# include "vpi_user.h"
# include <assert.h>
static int sys_deposit_calltf(char *name)
{
vpiHandle sys, argv, target, value;
s_vpi_value val;
sys = vpi_handle(vpiSysTfCall, 0);
assert(sys);
argv = vpi_iterate(vpiArgument, sys);
if (!argv)
{
vpi_printf("ERROR: %s requires parameters "
"(target, value)\n", name);
return 0;
}
target = vpi_scan(argv);
assert(target);
value = vpi_scan(argv);
assert(value);
vpi_free_object(argv);
val.format = vpiIntVal;
vpi_get_value(value, &val);
switch (vpi_get(vpiType, target))
{
default:
vpi_printf("ERROR: %s invalid target parameter\n", name);
break;
case vpiNet:
case vpiReg:
vpi_put_value(target, &val, 0, vpiNoDelay);
break;
}
return 0;
}
void sys_deposit_register()
{
s_vpi_systf_data tf_data;
tf_data.type = vpiSysTask;
tf_data.tfname = "$deposit";
tf_data.calltf = sys_deposit_calltf;
tf_data.compiletf = 0;
tf_data.sizetf = 0;
tf_data.user_data = "$deposit";
vpi_register_systf(&tf_data);
}
/*
* $Log: sys_deposit.c,v $
* Revision 1.1 2001/04/26 00:01:33 steve
* Support $deposit to a wire or reg.
*
*/

View File

@ -17,11 +17,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: sys_table.c,v 1.8 2000/12/14 23:36:34 steve Exp $"
#ident "$Id: sys_table.c,v 1.9 2001/04/26 00:01:33 steve Exp $"
#endif
#include "vpi_user.h"
extern void sys_finish_register();
extern void sys_deposit_register();
extern void sys_display_register();
extern void sys_random_register();
extern void sys_readmem_register();
@ -30,6 +31,7 @@ extern void sys_vcd_register();
void (*vlog_startup_routines[])() = {
sys_finish_register,
sys_deposit_register,
sys_display_register,
sys_random_register,
sys_readmem_register,
@ -45,6 +47,9 @@ DECLARE_CYGWIN_DLL(DllMain);
/*
* $Log: sys_table.c,v $
* Revision 1.9 2001/04/26 00:01:33 steve
* Support $deposit to a wire or reg.
*
* Revision 1.8 2000/12/14 23:36:34 steve
* include vpi_user.h.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_signal.cc,v 1.8 2001/04/25 04:45:52 steve Exp $"
#ident "$Id: vpi_signal.cc,v 1.9 2001/04/26 00:01:33 steve Exp $"
#endif
/*
@ -262,6 +262,17 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
switch (vp->format) {
case vpiIntVal: {
assert(wid <= sizeof(long));
long val = vp->value.integer;
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
functor_set(ipoint_index(rfp->bits,idx), val&1, true);
val >>= 1;
}
break;
}
case vpiScalarVal:
switch (vp->value.scalar) {
case vpi0:
@ -383,6 +394,9 @@ vpiHandle vpip_make_net(char*name, int msb, int lsb, bool signed_flag,
/*
* $Log: vpi_signal.cc,v $
* Revision 1.9 2001/04/26 00:01:33 steve
* Support $deposit to a wire or reg.
*
* Revision 1.8 2001/04/25 04:45:52 steve
* Implement vpi_put_value for signals.
*