Generate vvp code for functions with ports.

This commit is contained in:
steve 2001-04-06 02:28:02 +00:00
parent 82947a9343
commit 0550287658
16 changed files with 285 additions and 33 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elab_expr.cc,v 1.36 2001/02/10 20:29:39 steve Exp $" #ident "$Id: elab_expr.cc,v 1.37 2001/04/06 02:28:02 steve Exp $"
#endif #endif
@ -281,7 +281,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope) const
assert(res); assert(res);
NetESignal*eres = new NetESignal(res); NetESignal*eres = new NetESignal(res);
assert(eres); assert(eres);
NetEUFunc*func = new NetEUFunc(def, eres, parms); NetEUFunc*func = new NetEUFunc(dscope, eres, parms);
return func; return func;
} }
@ -611,6 +611,9 @@ NetEUnary* PEUnary::elaborate_expr(Design*des, NetScope*scope) const
/* /*
* $Log: elab_expr.cc,v $ * $Log: elab_expr.cc,v $
* Revision 1.37 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.36 2001/02/10 20:29:39 steve * Revision 1.36 2001/02/10 20:29:39 steve
* In the context of range declarations, use elab_and_eval instead * In the context of range declarations, use elab_and_eval instead
* of the less robust eval_const methods. * of the less robust eval_const methods.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: emit.cc,v 1.57 2001/04/02 02:28:12 steve Exp $" #ident "$Id: emit.cc,v 1.58 2001/04/06 02:28:02 steve Exp $"
#endif #endif
/* /*
@ -354,7 +354,7 @@ void NetScope::emit_defs(struct target_t*tgt) const
break; break;
case FUNC: case FUNC:
tgt->func_def(this->func_def()); tgt->func_def(this);
break; break;
case TASK: case TASK:
tgt->task_def(this); tgt->task_def(this);
@ -478,6 +478,9 @@ bool emit(const Design*des, const char*type)
/* /*
* $Log: emit.cc,v $ * $Log: emit.cc,v $
* Revision 1.58 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.57 2001/04/02 02:28:12 steve * Revision 1.57 2001/04/02 02:28:12 steve
* Generate code for task calls. * Generate code for task calls.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: ivl_target.h,v 1.49 2001/04/05 03:20:57 steve Exp $" #ident "$Id: ivl_target.h,v 1.50 2001/04/06 02:28:02 steve Exp $"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
@ -160,6 +160,7 @@ typedef enum ivl_expr_type_e {
IVL_EX_SIGNAL, IVL_EX_SIGNAL,
IVL_EX_STRING, IVL_EX_STRING,
IVL_EX_SUBSIG, IVL_EX_SUBSIG,
IVL_EX_UFUNC,
IVL_EX_UNARY IVL_EX_UNARY
} ivl_expr_type_t; } ivl_expr_type_t;
@ -361,6 +362,8 @@ extern ivl_expr_type_t ivl_expr_type(ivl_expr_t net);
/* IVL_EX_NUMBER */ /* IVL_EX_NUMBER */
extern const char* ivl_expr_bits(ivl_expr_t net); extern const char* ivl_expr_bits(ivl_expr_t net);
/* IVL_EX_UFUNC */
extern ivl_scope_t ivl_expr_def(ivl_expr_t net);
/* IVL_EX_SIGNAL, IVL_EX_SFUNC */ /* IVL_EX_SIGNAL, IVL_EX_SFUNC */
extern const char* ivl_expr_name(ivl_expr_t net); extern const char* ivl_expr_name(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_UNARY */ /* IVL_EX_BINARY IVL_EX_UNARY */
@ -371,9 +374,9 @@ extern ivl_expr_t ivl_expr_oper1(ivl_expr_t net);
extern ivl_expr_t ivl_expr_oper2(ivl_expr_t net); extern ivl_expr_t ivl_expr_oper2(ivl_expr_t net);
/* */ /* */
extern ivl_expr_t ivl_expr_oper3(ivl_expr_t net); extern ivl_expr_t ivl_expr_oper3(ivl_expr_t net);
/* IVL_EX_CONCAT */ /* IVL_EX_CONCAT IVL_EX_UFUNC */
extern ivl_expr_t ivl_expr_parm(ivl_expr_t net, unsigned idx); extern ivl_expr_t ivl_expr_parm(ivl_expr_t net, unsigned idx);
/* IVL_EX_CONCAT */ /* IVL_EX_CONCAT IVL_EX_UFUNC */
extern unsigned ivl_expr_parms(ivl_expr_t net); extern unsigned ivl_expr_parms(ivl_expr_t net);
/* IVL_EX_CONCAT */ /* IVL_EX_CONCAT */
extern unsigned ivl_expr_repeat(ivl_expr_t net); extern unsigned ivl_expr_repeat(ivl_expr_t net);
@ -561,6 +564,15 @@ extern ivl_signal_t ivl_nexus_ptr_sig(ivl_nexus_ptr_t net);
* Every scope has a hierarchical name. This name is also a prefix * Every scope has a hierarchical name. This name is also a prefix
* of all the names of objects contained within the scope. * of all the names of objects contained within the scope.
* *
* ivl_scope_port
* ivl_scope_ports
* Scopes that are functions or tasks have ports defined by
* signals. These methods access the ports by name.
*
* If this scope represents a function, then the ports list
* includes the return value, as port 0. The remaining ports are
* the input ports in order.
*
* ivl_scope_sig * ivl_scope_sig
* ivl_scope_sigs * ivl_scope_sigs
* Scopes have 0 or more signals in them. These signals are * Scopes have 0 or more signals in them. These signals are
@ -587,6 +599,8 @@ extern ivl_net_logic_t ivl_scope_log(ivl_scope_t net, unsigned idx);
extern unsigned ivl_scope_lpms(ivl_scope_t net); extern unsigned ivl_scope_lpms(ivl_scope_t net);
extern ivl_lpm_t ivl_scope_lpm(ivl_scope_t, unsigned idx); extern ivl_lpm_t ivl_scope_lpm(ivl_scope_t, unsigned idx);
extern const char* ivl_scope_name(ivl_scope_t net); extern const char* ivl_scope_name(ivl_scope_t net);
extern unsigned ivl_scope_ports(ivl_scope_t net);
extern const char* ivl_scope_port(ivl_scope_t net, unsigned idx);
extern unsigned ivl_scope_sigs(ivl_scope_t net); extern unsigned ivl_scope_sigs(ivl_scope_t net);
extern ivl_signal_t ivl_scope_sig(ivl_scope_t net, unsigned idx); extern ivl_signal_t ivl_scope_sig(ivl_scope_t net, unsigned idx);
extern ivl_scope_type_t ivl_scope_type(ivl_scope_t net); extern ivl_scope_type_t ivl_scope_type(ivl_scope_t net);
@ -745,6 +759,9 @@ _END_DECL
/* /*
* $Log: ivl_target.h,v $ * $Log: ivl_target.h,v $
* Revision 1.50 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.49 2001/04/05 03:20:57 steve * Revision 1.49 2001/04/05 03:20:57 steve
* Generate vvp code for the repeat statement. * Generate vvp code for the repeat statement.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.cc,v 1.158 2001/04/02 02:28:12 steve Exp $" #ident "$Id: netlist.cc,v 1.159 2001/04/06 02:28:02 steve Exp $"
#endif #endif
# include <cassert> # include <cassert>
@ -1708,7 +1708,7 @@ const NetExpr* NetSTask::parm(unsigned idx) const
return parms_[idx]; return parms_[idx];
} }
NetEUFunc::NetEUFunc(NetFuncDef*def, NetESignal*res, svector<NetExpr*>&p) NetEUFunc::NetEUFunc(NetScope*def, NetESignal*res, svector<NetExpr*>&p)
: func_(def), result_(res), parms_(p) : func_(def), result_(res), parms_(p)
{ {
expr_width(result_->expr_width()); expr_width(result_->expr_width());
@ -1741,7 +1741,7 @@ const NetExpr* NetEUFunc::parm(unsigned idx) const
return parms_[idx]; return parms_[idx];
} }
const NetFuncDef* NetEUFunc::definition() const const NetScope* NetEUFunc::func() const
{ {
return func_; return func_;
} }
@ -1761,7 +1761,7 @@ NetUTask::~NetUTask()
{ {
} }
const string& NetUTask::name() const const string NetUTask::name() const
{ {
return task_->name(); return task_->name();
} }
@ -2470,6 +2470,9 @@ bool NetUDP::sequ_glob_(string input, char output)
/* /*
* $Log: netlist.cc,v $ * $Log: netlist.cc,v $
* Revision 1.159 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.158 2001/04/02 02:28:12 steve * Revision 1.158 2001/04/02 02:28:12 steve
* Generate code for task calls. * Generate code for task calls.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.h,v 1.201 2001/04/02 02:28:12 steve Exp $" #ident "$Id: netlist.h,v 1.202 2001/04/06 02:28:02 steve Exp $"
#endif #endif
/* /*
@ -1944,7 +1944,7 @@ class NetTaskDef {
class NetEUFunc : public NetExpr { class NetEUFunc : public NetExpr {
public: public:
NetEUFunc(NetFuncDef*, NetESignal*, svector<NetExpr*>&); NetEUFunc(NetScope*, NetESignal*, svector<NetExpr*>&);
~NetEUFunc(); ~NetEUFunc();
const string name() const; const string name() const;
@ -1953,7 +1953,7 @@ class NetEUFunc : public NetExpr {
unsigned parm_count() const; unsigned parm_count() const;
const NetExpr* parm(unsigned idx) const; const NetExpr* parm(unsigned idx) const;
const NetFuncDef* definition() const; const NetScope* func() const;
virtual bool set_width(unsigned); virtual bool set_width(unsigned);
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
@ -1962,7 +1962,7 @@ class NetEUFunc : public NetExpr {
virtual NetEUFunc*dup_expr() const; virtual NetEUFunc*dup_expr() const;
private: private:
NetFuncDef*func_; NetScope*func_;
NetESignal*result_; NetESignal*result_;
svector<NetExpr*> parms_; svector<NetExpr*> parms_;
@ -1982,7 +1982,7 @@ class NetUTask : public NetProc {
NetUTask(NetScope*); NetUTask(NetScope*);
~NetUTask(); ~NetUTask();
const string& name() const; const string name() const;
const NetScope* task() const; const NetScope* task() const;
@ -2872,6 +2872,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.202 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.201 2001/04/02 02:28:12 steve * Revision 1.201 2001/04/02 02:28:12 steve
* Generate code for task calls. * Generate code for task calls.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll-api.cc,v 1.36 2001/04/05 03:20:57 steve Exp $" #ident "$Id: t-dll-api.cc,v 1.37 2001/04/06 02:28:02 steve Exp $"
#endif #endif
# include "t-dll.h" # include "t-dll.h"
@ -145,6 +145,22 @@ extern "C" const char* ivl_expr_bits(ivl_expr_t net)
return net->u_.number_.bits_; return net->u_.number_.bits_;
} }
extern "C" ivl_scope_t ivl_expr_def(ivl_expr_t net)
{
assert(net);
switch (net->type_) {
case IVL_EX_UFUNC:
return net->u_.ufunc_.def;
default:
assert(0);
}
return 0;
}
extern "C" const char* ivl_expr_name(ivl_expr_t net) extern "C" const char* ivl_expr_name(ivl_expr_t net)
{ {
switch (net->type_) { switch (net->type_) {
@ -218,9 +234,15 @@ extern "C" ivl_expr_t ivl_expr_parm(ivl_expr_t net, unsigned idx)
{ {
assert(net); assert(net);
switch (net->type_) { switch (net->type_) {
case IVL_EX_CONCAT: case IVL_EX_CONCAT:
assert(idx < net->u_.concat_.parms); assert(idx < net->u_.concat_.parms);
return net->u_.concat_.parm[idx]; return net->u_.concat_.parm[idx];
case IVL_EX_UFUNC:
assert(idx < net->u_.ufunc_.parms);
return net->u_.ufunc_.parm[idx];
default: default:
assert(0); assert(0);
return 0; return 0;
@ -231,9 +253,13 @@ extern "C" unsigned ivl_expr_parms(ivl_expr_t net)
{ {
assert(net); assert(net);
switch (net->type_) { switch (net->type_) {
case IVL_EX_CONCAT: case IVL_EX_CONCAT:
return net->u_.concat_.parms; return net->u_.concat_.parms;
case IVL_EX_UFUNC:
return net->u_.ufunc_.parms;
default: default:
assert(0); assert(0);
return 0; return 0;
@ -502,6 +528,21 @@ extern "C" const char* ivl_scope_name(ivl_scope_t net)
return net->name_; return net->name_;
} }
extern "C" unsigned ivl_scope_ports(ivl_scope_t net)
{
assert(net);
assert(net->type_ == IVL_SCT_FUNCTION);
return net->ports;
}
extern "C" const char* ivl_scope_port(ivl_scope_t net, unsigned idx)
{
assert(net);
assert(net->type_ == IVL_SCT_FUNCTION);
assert(idx < net->ports);
return net->port[idx];
}
extern "C" unsigned ivl_scope_sigs(ivl_scope_t net) extern "C" unsigned ivl_scope_sigs(ivl_scope_t net)
{ {
assert(net); assert(net);
@ -843,6 +884,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
/* /*
* $Log: t-dll-api.cc,v $ * $Log: t-dll-api.cc,v $
* Revision 1.37 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.36 2001/04/05 03:20:57 steve * Revision 1.36 2001/04/05 03:20:57 steve
* Generate vvp code for the repeat statement. * Generate vvp code for the repeat statement.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) & !defined(macintosh) #if !defined(WINNT) & !defined(macintosh)
#ident "$Id: t-dll-expr.cc,v 1.10 2001/04/05 01:12:28 steve Exp $" #ident "$Id: t-dll-expr.cc,v 1.11 2001/04/06 02:28:02 steve Exp $"
#endif #endif
# include "t-dll.h" # include "t-dll.h"
@ -157,6 +157,35 @@ void dll_target::expr_signal(const NetESignal*net)
expr_->u_.subsig_.name_ = strdup(net->name().c_str()); expr_->u_.subsig_.name_ = strdup(net->name().c_str());
} }
void dll_target::expr_ufunc(const NetEUFunc*net)
{
assert(expr_ == 0);
ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
assert(expr);
expr->type_ = IVL_EX_UFUNC;
expr->width_= net->expr_width();
expr->signed_ = net->has_sign()? 1 : 0;
expr->u_.ufunc_.def = lookup_scope_(net->func());
assert(expr->u_.ufunc_.def->type_ == IVL_SCT_FUNCTION);
unsigned cnt = net->parm_count();
expr->u_.ufunc_.parms = cnt;
expr->u_.ufunc_.parm = new ivl_expr_t[cnt];
/* make up the parameter expressions. */
for (unsigned idx = 0 ; idx < cnt ; idx += 1) {
net->parm(idx)->expr_scan(this);
assert(expr_);
expr->u_.ufunc_.parm[idx] = expr_;
expr_ = 0;
}
expr_ = expr;
}
void dll_target::expr_unary(const NetEUnary*net) void dll_target::expr_unary(const NetEUnary*net)
{ {
assert(expr_ == 0); assert(expr_ == 0);
@ -175,6 +204,9 @@ void dll_target::expr_unary(const NetEUnary*net)
/* /*
* $Log: t-dll-expr.cc,v $ * $Log: t-dll-expr.cc,v $
* Revision 1.11 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.10 2001/04/05 01:12:28 steve * Revision 1.10 2001/04/05 01:12:28 steve
* Get signed compares working correctly in vvp. * Get signed compares working correctly in vvp.
* *

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll-proc.cc,v 1.23 2001/04/05 03:20:57 steve Exp $" #ident "$Id: t-dll-proc.cc,v 1.24 2001/04/06 02:28:02 steve Exp $"
#endif #endif
# include "target.h" # include "target.h"
@ -90,6 +90,28 @@ void dll_target::task_def(const NetScope*net)
} }
void dll_target::func_def(const NetScope*net)
{
ivl_scope_t scope = lookup_scope_(net);
const NetFuncDef*def = net->func_def();
assert(stmt_cur_ == 0);
stmt_cur_ = (struct ivl_statement_s*)calloc(1, sizeof*stmt_cur_);
assert(stmt_cur_);
def->proc()->emit_proc(this);
assert(stmt_cur_);
scope->def = stmt_cur_;
stmt_cur_ = 0;
scope->ports = def->port_count();
if (scope->ports > 0) {
scope->port = new char*[scope->ports];
for (unsigned idx = 0 ; idx < scope->ports ; idx += 1)
scope->port[idx] = strdup(def->port(idx)->name());
}
}
/* /*
*/ */
void dll_target::proc_assign(const NetAssign*net) void dll_target::proc_assign(const NetAssign*net)
@ -554,6 +576,9 @@ void dll_target::proc_while(const NetWhile*net)
/* /*
* $Log: t-dll-proc.cc,v $ * $Log: t-dll-proc.cc,v $
* Revision 1.24 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.23 2001/04/05 03:20:57 steve * Revision 1.23 2001/04/05 03:20:57 steve
* Generate vvp code for the repeat statement. * Generate vvp code for the repeat statement.
* *

18
t-dll.h
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll.h,v 1.35 2001/04/05 03:20:58 steve Exp $" #ident "$Id: t-dll.h,v 1.36 2001/04/06 02:28:02 steve Exp $"
#endif #endif
# include "target.h" # include "target.h"
@ -91,6 +91,7 @@ struct dll_target : public target_t, public expr_scan_t {
bool proc_wait(const NetEvWait*); bool proc_wait(const NetEvWait*);
void proc_while(const NetWhile*); void proc_while(const NetWhile*);
void func_def(const NetScope*);
void task_def(const NetScope*); void task_def(const NetScope*);
struct ivl_expr_s*expr_; struct ivl_expr_s*expr_;
@ -99,6 +100,7 @@ struct dll_target : public target_t, public expr_scan_t {
void expr_const(const NetEConst*); void expr_const(const NetEConst*);
void expr_scope(const NetEScope*); void expr_scope(const NetEScope*);
void expr_sfunc(const NetESFunc*); void expr_sfunc(const NetESFunc*);
void expr_ufunc(const NetEUFunc*);
void expr_unary(const NetEUnary*); void expr_unary(const NetEUnary*);
void expr_signal(const NetESignal*); void expr_signal(const NetESignal*);
@ -163,6 +165,12 @@ struct ivl_expr_s {
ivl_expr_t lsb_; ivl_expr_t lsb_;
} subsig_; } subsig_;
struct {
ivl_scope_t def;
ivl_expr_t *parm;
unsigned short parms;
} ufunc_;
struct { struct {
char op_; char op_;
ivl_expr_t sub_; ivl_expr_t sub_;
@ -311,8 +319,11 @@ struct ivl_scope_s {
unsigned nlpm_; unsigned nlpm_;
ivl_lpm_t* lpm_; ivl_lpm_t* lpm_;
/* Scopes that are tasks have a definition. */ /* Scopes that are tasks/functions have a definition. */
ivl_statement_t def; ivl_statement_t def;
unsigned ports;
char **port;
}; };
/* /*
@ -416,6 +427,9 @@ struct ivl_statement_s {
/* /*
* $Log: t-dll.h,v $ * $Log: t-dll.h,v $
* Revision 1.36 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.35 2001/04/05 03:20:58 steve * Revision 1.35 2001/04/05 03:20:58 steve
* Generate vvp code for the repeat statement. * Generate vvp code for the repeat statement.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-vvm.cc,v 1.204 2001/04/02 02:28:12 steve Exp $" #ident "$Id: t-vvm.cc,v 1.205 2001/04/06 02:28:02 steve Exp $"
#endif #endif
# include <iostream> # include <iostream>
@ -151,7 +151,7 @@ class target_vvm : public target_t {
virtual void signal(const NetNet*); virtual void signal(const NetNet*);
virtual void memory(const NetMemory*); virtual void memory(const NetMemory*);
virtual void task_def(const NetScope*); virtual void task_def(const NetScope*);
virtual void func_def(const NetFuncDef*); virtual void func_def(const NetScope*);
virtual void lpm_add_sub(const NetAddSub*); virtual void lpm_add_sub(const NetAddSub*);
virtual void lpm_clshift(const NetCLShift*); virtual void lpm_clshift(const NetCLShift*);
@ -586,7 +586,7 @@ void vvm_proc_rval::expr_ternary(const NetETernary*expr)
*/ */
void vvm_proc_rval::expr_ufunc(const NetEUFunc*expr) void vvm_proc_rval::expr_ufunc(const NetEUFunc*expr)
{ {
const NetFuncDef*def = expr->definition(); const NetFuncDef*def = expr->func()->func_def();
const unsigned pcnt = expr->parm_count(); const unsigned pcnt = expr->parm_count();
assert(pcnt == (def->port_count()-1)); assert(pcnt == (def->port_count()-1));
@ -1387,8 +1387,9 @@ void target_vvm::task_def(const NetScope*scope)
* writes the result) then the caller copies the result out of the * writes the result) then the caller copies the result out of the
* magic result register. * magic result register.
*/ */
void target_vvm::func_def(const NetFuncDef*def) void target_vvm::func_def(const NetScope*scope)
{ {
const NetFuncDef*def = scope->func_def();
thread_step_ = 0; thread_step_ = 0;
const string name = mangle(def->name()); const string name = mangle(def->name());
@ -3638,6 +3639,9 @@ extern const struct target tgt_vvm = {
}; };
/* /*
* $Log: t-vvm.cc,v $ * $Log: t-vvm.cc,v $
* Revision 1.205 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.204 2001/04/02 02:28:12 steve * Revision 1.204 2001/04/02 02:28:12 steve
* Generate code for task calls. * Generate code for task calls.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: target.cc,v 1.51 2001/04/02 02:28:13 steve Exp $" #ident "$Id: target.cc,v 1.52 2001/04/06 02:28:02 steve Exp $"
#endif #endif
# include "target.h" # include "target.h"
@ -43,7 +43,7 @@ void target_t::memory(const NetMemory*)
"Unhandled memory." << endl; "Unhandled memory." << endl;
} }
void target_t::func_def(const NetFuncDef*) void target_t::func_def(const NetScope*)
{ {
cerr << "target (" << typeid(*this).name() << "): " cerr << "target (" << typeid(*this).name() << "): "
"Unhandled function definition." << endl; "Unhandled function definition." << endl;
@ -389,6 +389,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex)
/* /*
* $Log: target.cc,v $ * $Log: target.cc,v $
* Revision 1.52 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.51 2001/04/02 02:28:13 steve * Revision 1.51 2001/04/02 02:28:13 steve
* Generate code for task calls. * Generate code for task calls.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: target.h,v 1.50 2001/04/02 02:28:13 steve Exp $" #ident "$Id: target.h,v 1.51 2001/04/06 02:28:02 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -70,7 +70,7 @@ struct target_t {
/* Output a defined task. */ /* Output a defined task. */
virtual void task_def(const NetScope*); virtual void task_def(const NetScope*);
virtual void func_def(const NetFuncDef*); virtual void func_def(const NetScope*);
/* LPM style components are handled here. */ /* LPM style components are handled here. */
virtual void lpm_add_sub(const NetAddSub*); virtual void lpm_add_sub(const NetAddSub*);
@ -160,6 +160,9 @@ extern const struct target *target_table[];
/* /*
* $Log: target.h,v $ * $Log: target.h,v $
* Revision 1.51 2001/04/06 02:28:02 steve
* Generate vvp code for functions with ports.
*
* Revision 1.50 2001/04/02 02:28:13 steve * Revision 1.50 2001/04/02 02:28:13 steve
* Generate code for task calls. * Generate code for task calls.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: eval_expr.c,v 1.13 2001/04/05 01:12:28 steve Exp $" #ident "$Id: eval_expr.c,v 1.14 2001/04/06 02:28:03 steve Exp $"
#endif #endif
# include "vvp_priv.h" # include "vvp_priv.h"
@ -485,6 +485,69 @@ static struct vector_info draw_signal_expr(ivl_expr_t exp, unsigned wid)
return res; return res;
} }
/*
* A call to a user defined function generates a result that is the
* result of this expression.
*
* The result of the function is placed by the function execution into
* a signal within the scope of the function that also has a basename
* the same as the function. The ivl_target API handled the result
* mapping already, and we get the name of the result signal as
* parameter 0 of the function definition.
*/
static struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid)
{
unsigned idx;
unsigned swid = ivl_expr_width(exp);
ivl_scope_t def = ivl_expr_def(exp);
const char*name = ivl_scope_port(def, 0);
struct vector_info res;
/* evaluate the expressions and send the results to the
function ports. */
assert(ivl_expr_parms(exp) == (ivl_scope_ports(def)-1));
for (idx = 0 ; idx < ivl_expr_parms(exp) ; idx += 1) {
const char*port = ivl_scope_port(def, idx+1);
unsigned pin, bit;
res = draw_eval_expr(ivl_expr_parm(exp, idx));
bit = res.base;
for (pin = 0 ; pin < res.wid ; pin += 1) {
fprintf(vvp_out, " %%set V_%s[%u], %u;\n",
port, pin, bit);
if (bit >= 4)
bit += 1;
}
clr_vector(res);
}
/* Call the function */
fprintf(vvp_out, " %%fork TD_%s;\n", ivl_scope_name(def));
fprintf(vvp_out, " %%join;\n");
/* The return value is in a signal that has the name of the
expression. Load that into the thread and return the
vector result. */
res.base = allocate_vector(wid);
res.wid = wid;
for (idx = 0 ; idx < swid ; idx += 1)
fprintf(vvp_out, " %%load %u, V_%s[%u];\n",
res.base+idx, name, idx);
/* Pad the signal value with zeros. */
if (swid < wid)
fprintf(vvp_out, " %%mov %u, 0, %u;\n",
res.base+swid, wid-swid);
return res;
}
static struct vector_info draw_unary_expr(ivl_expr_t exp, unsigned wid) static struct vector_info draw_unary_expr(ivl_expr_t exp, unsigned wid)
{ {
struct vector_info res; struct vector_info res;
@ -555,6 +618,10 @@ struct vector_info draw_eval_expr_wid(ivl_expr_t exp, unsigned wid)
res = draw_signal_expr(exp, wid); res = draw_signal_expr(exp, wid);
break; break;
case IVL_EX_UFUNC:
res = draw_ufunc_expr(exp, wid);
break;
case IVL_EX_UNARY: case IVL_EX_UNARY:
res = draw_unary_expr(exp, wid); res = draw_unary_expr(exp, wid);
break; break;
@ -570,6 +637,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
/* /*
* $Log: eval_expr.c,v $ * $Log: eval_expr.c,v $
* Revision 1.14 2001/04/06 02:28:03 steve
* Generate vvp code for functions with ports.
*
* Revision 1.13 2001/04/05 01:12:28 steve * Revision 1.13 2001/04/05 01:12:28 steve
* Get signed compares working correctly in vvp. * Get signed compares working correctly in vvp.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: vvp_priv.h,v 1.7 2001/04/02 02:28:13 steve Exp $" #ident "$Id: vvp_priv.h,v 1.8 2001/04/06 02:28:03 steve Exp $"
#endif #endif
# include "ivl_target.h" # include "ivl_target.h"
@ -39,6 +39,7 @@ extern FILE* vvp_out;
extern int draw_process(ivl_process_t net, void*x); extern int draw_process(ivl_process_t net, void*x);
extern int draw_task_definition(ivl_scope_t scope); extern int draw_task_definition(ivl_scope_t scope);
extern int draw_func_definition(ivl_scope_t scope);
extern int draw_scope(ivl_scope_t scope, ivl_scope_t parent); extern int draw_scope(ivl_scope_t scope, ivl_scope_t parent);
@ -73,6 +74,9 @@ extern void clr_vector(struct vector_info vec);
/* /*
* $Log: vvp_priv.h,v $ * $Log: vvp_priv.h,v $
* Revision 1.8 2001/04/06 02:28:03 steve
* Generate vvp code for functions with ports.
*
* Revision 1.7 2001/04/02 02:28:13 steve * Revision 1.7 2001/04/02 02:28:13 steve
* Generate code for task calls. * Generate code for task calls.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: vvp_process.c,v 1.25 2001/04/05 03:20:58 steve Exp $" #ident "$Id: vvp_process.c,v 1.26 2001/04/06 02:28:03 steve Exp $"
#endif #endif
# include "vvp_priv.h" # include "vvp_priv.h"
@ -699,8 +699,27 @@ int draw_task_definition(ivl_scope_t scope)
return rc; return rc;
} }
int draw_func_definition(ivl_scope_t scope)
{
int rc = 0;
ivl_statement_t def = ivl_scope_def(scope);
fprintf(vvp_out, "TD_%s ;\n", ivl_scope_name(scope));
assert(def);
rc += show_statement(def);
fprintf(vvp_out, " %%end;\n");
thread_count += 1;
return rc;
}
/* /*
* $Log: vvp_process.c,v $ * $Log: vvp_process.c,v $
* Revision 1.26 2001/04/06 02:28:03 steve
* Generate vvp code for functions with ports.
*
* Revision 1.25 2001/04/05 03:20:58 steve * Revision 1.25 2001/04/05 03:20:58 steve
* Generate vvp code for the repeat statement. * Generate vvp code for the repeat statement.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: vvp_scope.c,v 1.13 2001/04/05 01:38:24 steve Exp $" #ident "$Id: vvp_scope.c,v 1.14 2001/04/06 02:28:03 steve Exp $"
#endif #endif
# include "vvp_priv.h" # include "vvp_priv.h"
@ -264,6 +264,8 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
if (ivl_scope_type(net) == IVL_SCT_TASK) if (ivl_scope_type(net) == IVL_SCT_TASK)
draw_task_definition(net); draw_task_definition(net);
if (ivl_scope_type(net) == IVL_SCT_FUNCTION)
draw_func_definition(net);
ivl_scope_children(net, (ivl_scope_f*) draw_scope, net); ivl_scope_children(net, (ivl_scope_f*) draw_scope, net);
return 0; return 0;
@ -271,6 +273,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
/* /*
* $Log: vvp_scope.c,v $ * $Log: vvp_scope.c,v $
* Revision 1.14 2001/04/06 02:28:03 steve
* Generate vvp code for functions with ports.
*
* Revision 1.13 2001/04/05 01:38:24 steve * Revision 1.13 2001/04/05 01:38:24 steve
* Generate signed .net and .var statements. * Generate signed .net and .var statements.
* *