Add scope to threads in vvm, pass that scope

to vpi sysTaskFunc objects, and add vpi calls
 to access that information.

 $display displays scope in %m (PR#1)
This commit is contained in:
steve 2000-10-28 00:51:41 +00:00
parent f915efaf15
commit ad4931e813
14 changed files with 196 additions and 47 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: design_dump.cc,v 1.100 2000/10/07 19:45:42 steve Exp $"
#ident "$Id: design_dump.cc,v 1.101 2000/10/28 00:51:41 steve Exp $"
#endif
/*
@ -421,10 +421,12 @@ void NetProcTop::dump(ostream&o, unsigned ind) const
{
switch (type_) {
case NetProcTop::KINITIAL:
o << "initial /* " << get_line() << " */" << endl;
o << "initial /* " << get_line() << " in "
<< scope_->name() << " */" << endl;
break;
case NetProcTop::KALWAYS:
o << "always /* " << get_line() << " */" << endl;
o << "always /* " << get_line() << " in "
<< scope_->name() << " */" << endl;
break;
}
@ -973,6 +975,13 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
* Revision 1.101 2000/10/28 00:51:41 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.100 2000/10/07 19:45:42 steve
* Put logic devices into scopes.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elaborate.cc,v 1.194 2000/10/26 17:09:46 steve Exp $"
#ident "$Id: elaborate.cc,v 1.195 2000/10/28 00:51:42 steve Exp $"
#endif
/*
@ -2198,10 +2198,10 @@ bool Module::elaborate(Design*des, NetScope*scope) const
NetProcTop*top;
switch ((*st)->type()) {
case PProcess::PR_INITIAL:
top = new NetProcTop(NetProcTop::KINITIAL, cur);
top = new NetProcTop(scope, NetProcTop::KINITIAL, cur);
break;
case PProcess::PR_ALWAYS:
top = new NetProcTop(NetProcTop::KALWAYS, cur);
top = new NetProcTop(scope, NetProcTop::KALWAYS, cur);
break;
}
@ -2283,6 +2283,13 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $Log: elaborate.cc,v $
* Revision 1.195 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.194 2000/10/26 17:09:46 steve
* Fix handling of errors in behavioral lvalues. (PR#28)
*

View File

@ -53,3 +53,10 @@
[-tnull]
<ivl>%B/ivl %?s-s%s; %?N-N%N; %?T-T%T; -tnull -- -
# -- (not supported yet)
# The <ivl> string for the vvm target is the ivl command that takes as
# standard input the output from the preprocessor and writes the result
# into a .cc file named after the output file.
[-tvvm]
<ivl>%B/ivl %?s-s%s; %?N-N%N; %?T-T%T; -tvvm -Fcprop -Fnodangle -fVPI_MODULE_PATH=%B -- -

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.cc,v 1.142 2000/10/07 19:45:43 steve Exp $"
#ident "$Id: netlist.cc,v 1.143 2000/10/28 00:51:42 steve Exp $"
#endif
# include <cassert>
@ -423,8 +423,8 @@ NetProc::~NetProc()
{
}
NetProcTop::NetProcTop(Type t, NetProc*st)
: type_(t), statement_(st)
NetProcTop::NetProcTop(NetScope*s, Type t, NetProc*st)
: type_(t), statement_(st), scope_(s)
{
}
@ -443,6 +443,11 @@ const NetProc* NetProcTop::statement() const
return statement_;
}
const NetScope* NetProcTop::scope() const
{
return scope_;
}
/*
* The NetFF class represents an LPM_FF device. The pinout is assigned
* like so:
@ -2441,6 +2446,13 @@ bool NetUDP::sequ_glob_(string input, char output)
/*
* $Log: netlist.cc,v $
* Revision 1.143 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.142 2000/10/07 19:45:43 steve
* Put logic devices into scopes.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.h,v 1.174 2000/10/18 20:04:39 steve Exp $"
#ident "$Id: netlist.h,v 1.175 2000/10/28 00:51:42 steve Exp $"
#endif
/*
@ -1999,13 +1999,15 @@ class NetProcTop : public LineInfo {
public:
enum Type { KINITIAL, KALWAYS };
NetProcTop(Type t, class NetProc*st);
NetProcTop(NetScope*s, Type t, class NetProc*st);
~NetProcTop();
Type type() const { return type_; }
NetProc*statement();
const NetProc*statement() const;
const NetScope*scope() const;
void dump(ostream&, unsigned ind) const;
bool emit(struct target_t*tgt) const;
@ -2013,6 +2015,7 @@ class NetProcTop : public LineInfo {
const Type type_;
NetProc*const statement_;
NetScope*scope_;
friend class Design;
NetProcTop*next_;
};
@ -2807,6 +2810,13 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.175 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.174 2000/10/18 20:04:39 steve
* Add ivl_lval_t and support for assignment l-values.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-vvm.cc,v 1.180 2000/10/26 00:29:10 steve Exp $"
#ident "$Id: t-vvm.cc,v 1.181 2000/10/28 00:51:42 steve Exp $"
#endif
# include <iostream>
@ -2180,7 +2180,8 @@ void target_vvm::start_process(ostream&os, const NetProcTop*proc)
init_code << " " << thread_class_ << ".step_ = &"
<< thread_class_ << "_step_0_;" << endl;
init_code << " " << thread_class_ << ".scope = &"
<< mangle(proc->scope()->name()) << "_scope;" << endl;
init_code << " " << thread_class_ << ".thread_yield();" << endl;
@ -3162,7 +3163,7 @@ void target_vvm::proc_stask(const NetSTask*net)
parameters. we don't need a parameter array for this. */
if (net->nparms() == 0) {
defn << " vpip_calltask(\"" << net->name()
defn << " vpip_calltask(thr->scope, \"" << net->name()
<< "\", 0, 0);" << endl;
defn << " if (vpip_finished()) return false;" << endl;
return;
@ -3185,8 +3186,8 @@ void target_vvm::proc_stask(const NetSTask*net)
<< endl;
}
defn << " vpip_calltask(\"" << net->name() << "\", " <<
net->nparms() << ", " << ptmp << ");" << endl;
defn << " vpip_calltask(thr->scope, \"" << net->name() << "\", "
<< net->nparms() << ", " << ptmp << ");" << endl;
defn << " if (vpip_finished()) return false;" << endl;
}
@ -3393,6 +3394,13 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
* Revision 1.181 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.180 2000/10/26 00:29:10 steve
* Put signals into a signal_table
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: sys_display.c,v 1.17 2000/08/20 17:49:05 steve Exp $"
#ident "$Id: sys_display.c,v 1.18 2000/10/28 00:51:42 steve Exp $"
#endif
# include "vpi_user.h"
@ -55,7 +55,8 @@ static void array_from_iterator(struct strobe_cb_info*info, vpiHandle argv)
* well so that I can look for arguments as I move forward through the
* string.
*/
static int format_str(unsigned int mcd, char*fmt, int argc, vpiHandle*argv)
static int format_str(vpiHandle scope, unsigned int mcd,
char*fmt, int argc, vpiHandle*argv)
{
s_vpi_value value;
char buf[256];
@ -114,8 +115,8 @@ static int format_str(unsigned int mcd, char*fmt, int argc, vpiHandle*argv)
cp += 1;
break;
case 'm':
vpi_mcd_printf(mcd, "%s", vpi_get_str(vpiFullName, argv[idx]));
idx += 1;
assert(scope);
vpi_mcd_printf(mcd, "%s", vpi_get_str(vpiFullName, scope));
cp += 1;
break;
case 'o':
@ -162,7 +163,8 @@ static int format_str(unsigned int mcd, char*fmt, int argc, vpiHandle*argv)
return idx;
}
static void do_display(unsigned int mcd, struct strobe_cb_info*info)
static void do_display(vpiHandle scope, unsigned int mcd,
struct strobe_cb_info*info)
{
s_vpi_value value;
int idx;
@ -180,7 +182,7 @@ static void do_display(unsigned int mcd, struct strobe_cb_info*info)
if (vpi_get(vpiConstType, item) == vpiStringConst) {
value.format = vpiStringVal;
vpi_get_value(item, &value);
idx += format_str(mcd, value.value.str,
idx += format_str(scope, mcd, value.value.str,
info->nitems-idx-1,
info->items+idx+1);
} else {
@ -215,12 +217,15 @@ static int sys_display_calltf(char *name)
{
struct strobe_cb_info info;
vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
vpiHandle scope = vpi_handle(vpiScope, sys);
vpiHandle argv = vpi_iterate(vpiArgument, sys);
assert(scope);
array_from_iterator(&info, argv);
do_display(1, &info);
do_display(scope, 1, &info);
free(info.items);
@ -242,7 +247,7 @@ static int strobe_cb(p_cb_data cb)
{
struct strobe_cb_info*info = (struct strobe_cb_info*)cb->user_data;
do_display(1, info);
do_display(0, 1, info);
vpi_printf("\n");
@ -294,7 +299,7 @@ static vpiHandle *monitor_callbacks = 0;
static int monitor_cb_2(p_cb_data cb)
{
do_display(1, &monitor_info);
do_display(0, 1, &monitor_info);
vpi_printf("\n");
monitor_scheduled = 0;
return 0;
@ -460,7 +465,7 @@ static int sys_fdisplay_calltf(char *name)
mcd = value.value.integer;
array_from_iterator(&info, argv);
do_display(mcd, &info);
do_display(0, mcd, &info);
free(info.items);
if (strcmp(name,"$fdisplay") == 0)
@ -576,6 +581,13 @@ void sys_display_register()
/*
* $Log: sys_display.c,v $
* Revision 1.18 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.17 2000/08/20 17:49:05 steve
* Clean up warnings and portability issues.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_user.h,v 1.23 2000/10/04 02:37:44 steve Exp $"
#ident "$Id: vpi_user.h,v 1.24 2000/10/28 00:51:42 steve Exp $"
#endif
@ -137,6 +137,7 @@ typedef struct t_vpi_value {
#define vpiSysTaskCall 57
#define vpiTask 59
#define vpiTimeVar 63
#define vpiScope 84
#define vpiSysTfCall 85
#define vpiArgument 89
#define vpiInternalScope 92
@ -264,6 +265,13 @@ extern DLLEXPORT void (*vlog_startup_routines[])();
/*
* $Log: vpi_user.h,v $
* Revision 1.24 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.23 2000/10/04 02:37:44 steve
* Use .def file instead of _dllexport.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_priv.c,v 1.10 2000/10/06 23:11:39 steve Exp $"
#ident "$Id: vpi_priv.c,v 1.11 2000/10/28 00:51:42 steve Exp $"
#endif
# include "vpi_priv.h"
@ -44,11 +44,13 @@ static struct systf_entry*systf_task_list = 0;
/* This is the handle of the task currently being called. */
static struct __vpiSysTaskCall*vpip_cur_task;
void vpip_calltask(const char*fname, unsigned nparms, vpiHandle*parms)
void vpip_calltask(struct __vpiScope*scope, const char*fname,
unsigned nparms, vpiHandle*parms)
{
struct systf_entry*idx;
struct __vpiSysTaskCall cur_task;
cur_task.base.vpi_type = vpip_get_systask_rt();
cur_task.scope = scope;
cur_task.args = parms;
cur_task.nargs = nparms;
cur_task.res = 0;
@ -233,6 +235,13 @@ void vpi_register_systf(const struct t_vpi_systf_data*systf)
/*
* $Log: vpi_priv.c,v $
* Revision 1.11 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.10 2000/10/06 23:11:39 steve
* Replace data references with function calls. (Venkat)
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_priv.h,v 1.28 2000/10/06 23:11:39 steve Exp $"
#ident "$Id: vpi_priv.h,v 1.29 2000/10/28 00:51:42 steve Exp $"
#endif
/*
@ -247,6 +247,8 @@ extern const struct __vpirt *vpip_get_sysfunc_rt(void);
struct __vpiSysTaskCall {
struct __vpiHandle base;
struct __vpiScope*scope;
s_vpi_systf_data*info;
vpiHandle*args;
unsigned nargs;
@ -313,7 +315,8 @@ extern vpiHandle vpip_make_time_var(struct __vpiTimeVar*ref,
const char*val);
/* Use this function to call a registered task. */
extern void vpip_calltask(const char*name, unsigned nparms, vpiHandle*parms);
extern void vpip_calltask(struct __vpiScope*scope, const char*name,
unsigned nparms, vpiHandle*parms);
/*
* This calls a system function with a given name. The return value is
@ -389,6 +392,13 @@ extern int vpip_finished();
/*
* $Log: vpi_priv.h,v $
* Revision 1.29 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.28 2000/10/06 23:11:39 steve
* Replace data references with function calls. (Venkat)
*

View File

@ -17,13 +17,30 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_scope.c,v 1.7 2000/05/03 05:03:26 steve Exp $"
#ident "$Id: vpi_scope.c,v 1.8 2000/10/28 00:51:42 steve Exp $"
#endif
# include "vpi_priv.h"
# include <stdlib.h>
# include <assert.h>
static char* scope_get_str(int code, vpiHandle obj)
{
struct __vpiScope*ref = (struct __vpiScope*)obj;
assert((obj->vpi_type->type_code == vpiModule)
|| (obj->vpi_type->type_code == vpiNamedBegin));
switch (code) {
case vpiFullName:
return ref->name;
default:
assert(0);
return 0;
}
}
static vpiHandle module_iter(int code, vpiHandle obj)
{
struct __vpiScope*ref = (struct __vpiScope*)obj;
@ -40,7 +57,7 @@ static vpiHandle module_iter(int code, vpiHandle obj)
static const struct __vpirt vpip_module_rt = {
vpiModule,
0,
0,
scope_get_str,
0,
0,
0,
@ -50,7 +67,7 @@ static const struct __vpirt vpip_module_rt = {
static const struct __vpirt vpip_task_rt = {
vpiTask,
0,
0,
scope_get_str,
0,
0,
0,
@ -60,7 +77,7 @@ static const struct __vpirt vpip_task_rt = {
static const struct __vpirt vpip_function_rt = {
vpiFunction,
0,
0,
scope_get_str,
0,
0,
0,
@ -70,7 +87,7 @@ static const struct __vpirt vpip_function_rt = {
static const struct __vpirt vpip_named_begin_rt = {
vpiNamedBegin,
0,
0,
scope_get_str,
0,
0,
0,
@ -91,6 +108,7 @@ vpiHandle vpip_make_scope(struct __vpiScope*ref, int type, const char*name)
{
ref->intern = 0;
ref->nintern = 0;
ref->name = name;
switch (type) {
case vpiModule:
@ -129,6 +147,13 @@ void vpip_attach_to_scope(struct __vpiScope*ref, vpiHandle obj)
/*
* $Log: vpi_scope.c,v $
* Revision 1.8 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.7 2000/05/03 05:03:26 steve
* Support named for in VPI.
*

View File

@ -17,13 +17,28 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_systask.c,v 1.7 2000/10/06 23:11:39 steve Exp $"
#ident "$Id: vpi_systask.c,v 1.8 2000/10/28 00:51:42 steve Exp $"
#endif
# include "vpi_priv.h"
# include <stdlib.h>
# include <assert.h>
static vpiHandle systask_handle(int type, vpiHandle ref)
{
struct __vpiSysTaskCall*rfp = (struct __vpiSysTaskCall*)ref;
assert((ref->vpi_type->type_code == vpiSysTaskCall)
|| (ref->vpi_type->type_code == vpiSysFuncCall));
switch (type) {
case vpiScope:
return &rfp->scope->base;
default:
assert(0);
return 0;
}
}
/*
* the iter function only supports getting an iterator of the
* arguments. This works equally well for tasks and functions.
@ -46,7 +61,7 @@ static const struct __vpirt vpip_systask_rt = {
0,
0,
0,
0,
systask_handle,
systask_iter
};
@ -108,6 +123,13 @@ DECLARE_CYGWIN_DLL(DllMain);
/*
* $Log: vpi_systask.c,v $
* Revision 1.8 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.7 2000/10/06 23:11:39 steve
* Replace data references with function calls. (Venkat)
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_thread.cc,v 1.6 2000/04/14 23:31:53 steve Exp $"
#ident "$Id: vvm_thread.cc,v 1.7 2000/10/28 00:51:42 steve Exp $"
#endif
# include "vvm.h"
@ -30,7 +30,7 @@ class delay_event : public vvm_event {
delay_event(vvm_thread*thr) : thr_(thr) { }
void event_function()
{
while (thr_->go())
while (thr_->step_(thr_))
/* empty */;
}
private:
@ -55,14 +55,16 @@ void vvm_thread::thread_yield(unsigned long delay)
ev -> schedule(delay);
}
bool vvm_thread::go()
{
return (step_)(this);
}
/*
* $Log: vvm_thread.cc,v $
* Revision 1.7 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.6 2000/04/14 23:31:53 steve
* No more class derivation from vvm_thread.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_thread.h,v 1.9 2000/04/15 19:51:30 steve Exp $"
#ident "$Id: vvm_thread.h,v 1.10 2000/10/28 00:51:42 steve Exp $"
#endif
# include "vvm.h"
@ -80,7 +80,6 @@ class vvm_thread {
// This method executes a setp of the thread. The engine will
// continue to call go as long as it returns true. The thread
// will return false if it is ready to give up the CPU.
bool go();
bool (*step_)(vvm_thread*);
// These members are used to handle task invocations.
@ -91,10 +90,19 @@ class vvm_thread {
// The sync class uses this to list all the threads blocked on it.
vvm_sync*sync_back_;
vvm_thread*sync_next_;
struct __vpiScope*scope;
};
/*
* $Log: vvm_thread.h,v $
* Revision 1.10 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls
* to access that information.
*
* $display displays scope in %m (PR#1)
*
* Revision 1.9 2000/04/15 19:51:30 steve
* fork-join support in vvm.
*