Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Elaborate and emit to vvm procedural functions.
  • Loading branch information
steve committed Aug 31, 1999
1 parent 1c11c86 commit e69345b
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 26 deletions.
6 changes: 5 additions & 1 deletion PExpr.h
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: PExpr.h,v 1.17 1999/08/01 21:18:55 steve Exp $"
#ident "$Id: PExpr.h,v 1.18 1999/08/31 22:38:29 steve Exp $"
#endif

# include <string>
Expand Down Expand Up @@ -254,6 +254,7 @@ class PECallFunction : public PExpr {
~PECallFunction() {}

virtual void dump(ostream &) const;
virtual NetEUFunc*elaborate_expr(Design*des, const string&path) const;

private:
string name_;
Expand All @@ -262,6 +263,9 @@ class PECallFunction : public PExpr {

/*
* $Log: PExpr.h,v $
* Revision 1.18 1999/08/31 22:38:29 steve
* Elaborate and emit to vvm procedural functions.
*
* Revision 1.17 1999/08/01 21:18:55 steve
* elaborate rise/fall/decay for continuous assign.
*
Expand Down
42 changes: 34 additions & 8 deletions design_dump.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: design_dump.cc,v 1.35 1999/08/25 22:22:41 steve Exp $"
#ident "$Id: design_dump.cc,v 1.36 1999/08/31 22:38:29 steve Exp $"
#endif

/*
Expand Down Expand Up @@ -123,24 +123,25 @@ void NetObj::dump_obj_attr(ostream&o, unsigned ind) const

void NetAssign::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "Procedural assign: " << *rval_ << endl;
o << setw(ind) << "" << "Procedural assign (NetAssign): " <<
*rval_ << endl;
dump_node_pins(o, ind+4);
}

void NetAssignNB::dump_node(ostream&o, unsigned ind) const
{
if (bmux_)
o << setw(ind) << "" << "Procedural NB assign: " << name()
<< "[" << *bmux_ << "] <= " << *rval_ << endl;
o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): "
<< name() << "[" << *bmux_ << "] <= " << *rval_ << endl;
else
o << setw(ind) << "" << "Procedural NB assign: " << name()
<< " <= " << *rval_ << endl;
o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): "
<< name() << " <= " << *rval_ << endl;
dump_node_pins(o, ind+4);
}

void NetBUFZ::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "BUFZ: " << name() << endl;
o << setw(ind) << "" << "NetBUFZ: " << name() << endl;
dump_node_pins(o, ind+4);
}

Expand Down Expand Up @@ -616,7 +617,8 @@ void NetEMemory::dump(ostream&o) const

void NetESignal::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "Expression Node: " << name() << endl;
o << setw(ind) << "" << "Expression Node (NetESignal): " <<
name() << endl;

dump_node_pins(o, ind+4);
}
Expand All @@ -627,6 +629,18 @@ void NetETernary::dump(ostream&o) const
false_val_ << ")";
}

void NetEUFunc::dump(ostream&o) const
{
o << name() << "(";
assert(parms_.count() > 0);
parms_[0]->dump(o);
for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) {
o << ", ";
parms_[idx]->dump(o);
}
o << ")";
}

void NetEUnary::dump(ostream&o) const
{
o << op_ << "(";
Expand Down Expand Up @@ -666,6 +680,15 @@ void Design::dump(ostream&o) const
}
}

o << "ELABORATED FUNCTION DEFINITIONS:" << endl;
{
map<string,NetFuncDef*>::const_iterator pp;
for (pp = funcs_.begin()
; pp != funcs_.end() ; pp ++) {
(*pp).second->dump(o, 0);
}
}

o << "ELABORATED TASK DEFINITIONS:" << endl;
{
map<string,NetTaskDef*>::const_iterator pp;
Expand Down Expand Up @@ -696,6 +719,9 @@ void Design::dump(ostream&o) const

/*
* $Log: design_dump.cc,v $
* Revision 1.36 1999/08/31 22:38:29 steve
* Elaborate and emit to vvm procedural functions.
*
* Revision 1.35 1999/08/25 22:22:41 steve
* elaborate some aspects of functions.
*
Expand Down
53 changes: 47 additions & 6 deletions elaborate.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: elaborate.cc,v 1.73 1999/08/25 22:22:41 steve Exp $"
#ident "$Id: elaborate.cc,v 1.74 1999/08/31 22:38:29 steve Exp $"
#endif

/*
Expand Down Expand Up @@ -733,6 +733,27 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
return osig;
}

NetEUFunc* PECallFunction::elaborate_expr(Design*des, const string&path) const
{
string myname = path+"."+name_;
NetFuncDef*def = des->find_function(myname);
assert(def);
svector<NetExpr*> parms (parms_.count());

for (unsigned idx = 0 ; idx < parms.count() ; idx += 1) {
NetExpr*tmp = parms_[idx]->elaborate_expr(des, myname);
parms[idx] = tmp;
}

NetNet*res = des->find_signal(myname, name_);
assert(res);
NetESignal*eres = new NetESignal(res);
assert(eres);
des->add_node(eres);
NetEUFunc*func = new NetEUFunc(def, eres, parms);
return func;
}

/*
* The concatenation operator, as a net, is a wide signal that is
* connected to all the pins of the elaborated expression nets.
Expand Down Expand Up @@ -1869,12 +1890,29 @@ NetProc* PForStatement::elaborate(Design*des, const string&path) const
void PFunction::elaborate(Design*des, const string&path) const
{
NetProc*st = statement_->elaborate(des, path);
NetFuncDef*def = new NetFuncDef(path, st);
des->add_function(path, def);
if (st == 0) {
cerr << statement_->get_line() << ": Unable to elaborate "
"statement in function " << path << " at " << get_line()
<< "." << endl;
return;
}

cerr << get_line() << ": Sorry, unable to elaborate "
"function definitions." << endl;
des->errors += 1;
/* Translate the wires that are ports to NetNet pointers by
presuming that the name is already elaborated, and look it
up in the design. Then save that pointer for later use by
calls to the task. (Remember, the task itself does not need
these ports.) */
svector<NetNet*>ports (ports_? ports_->count()+1 : 1);
ports[0] = des->find_signal(path, path);
for (unsigned idx = 0 ; idx < ports_->count() ; idx += 1) {
NetNet*tmp = des->find_signal(path, (*ports_)[idx]->name());

ports[idx+1] = tmp;
}


NetFuncDef*def = new NetFuncDef(path, st, ports);
des->add_function(path, def);
}

NetProc* PRepeat::elaborate(Design*des, const string&path) const
Expand Down Expand Up @@ -2089,6 +2127,9 @@ Design* elaborate(const map<string,Module*>&modules,

/*
* $Log: elaborate.cc,v $
* Revision 1.74 1999/08/31 22:38:29 steve
* Elaborate and emit to vvm procedural functions.
*
* Revision 1.73 1999/08/25 22:22:41 steve
* elaborate some aspects of functions.
*
Expand Down
18 changes: 17 additions & 1 deletion emit.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: emit.cc,v 1.18 1999/07/17 19:50:59 steve Exp $"
#ident "$Id: emit.cc,v 1.19 1999/08/31 22:38:29 steve Exp $"
#endif

/*
Expand Down Expand Up @@ -229,6 +229,14 @@ void Design::emit(ostream&o, struct target_t*tgt) const
}


// emit function definitions
{
map<string,NetFuncDef*>::const_iterator ta;
for (ta = funcs_.begin() ; ta != funcs_.end() ; ta ++) {
tgt->func_def(o, (*ta).second);
}
}

// emit task definitions
{
map<string,NetTaskDef*>::const_iterator ta;
Expand Down Expand Up @@ -269,6 +277,11 @@ void NetEMemory::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_memory(this);
}

void NetEUFunc::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_ufunc(this);
}

void NetESignal::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_signal(this);
Expand Down Expand Up @@ -308,6 +321,9 @@ void emit(ostream&o, const Design*des, const char*type)

/*
* $Log: emit.cc,v $
* Revision 1.19 1999/08/31 22:38:29 steve
* Elaborate and emit to vvm procedural functions.
*
* Revision 1.18 1999/07/17 19:50:59 steve
* netlist support for ternary operator.
*
Expand Down
66 changes: 63 additions & 3 deletions netlist.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: netlist.cc,v 1.53 1999/08/25 22:22:41 steve Exp $"
#ident "$Id: netlist.cc,v 1.54 1999/08/31 22:38:29 steve Exp $"
#endif

# include <cassert>
Expand Down Expand Up @@ -482,15 +482,25 @@ NetProc* NetCondit::else_clause()
return else_;
}

NetFuncDef::NetFuncDef(const string&n, NetProc*st)
: name_(n), statement_(st)
NetFuncDef::NetFuncDef(const string&n, NetProc*st, const svector<NetNet*>&po)
: name_(n), statement_(st), ports_(po)
{
}

NetFuncDef::~NetFuncDef()
{
}

const string& NetFuncDef::name() const
{
return name_;
}

const NetProc* NetFuncDef::proc() const
{
return statement_;
}

NetNEvent::NetNEvent(const string&ev, unsigned wid, Type e, NetPEvent*pe)
: NetNode(ev, wid), sref<NetPEvent,NetNEvent>(pe), edge_(e)
{
Expand Down Expand Up @@ -547,6 +557,44 @@ const NetExpr* NetSTask::parm(unsigned idx) const
return parms_[idx];
}

NetEUFunc::NetEUFunc(NetFuncDef*def, NetESignal*res, svector<NetExpr*>&p)
: func_(def), result_(res), parms_(p)
{
}

NetEUFunc::~NetEUFunc()
{
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
delete parms_[idx];
}

const string& NetEUFunc::name() const
{
return func_->name();
}

const NetESignal*NetEUFunc::result() const
{
return result_;
}

/*
* XXXX FIX ME: For now, just take whatever the caller says as my
* width. What I really need to do is note the width of the output
* parameter of the function definition and take that into account.
*/
bool NetEUFunc::set_width(unsigned wid)
{
expr_width(wid);
return true;
}

NetEUFunc* NetEUFunc::dup_expr() const
{
assert(0);
return 0;
}

NetUTask::NetUTask(NetTaskDef*def)
: task_(def)
{
Expand Down Expand Up @@ -1453,6 +1501,15 @@ void Design::add_function(const string&key, NetFuncDef*def)
funcs_[key] = def;
}

NetFuncDef* Design::find_function(const string&key)
{
map<string,NetFuncDef*>::const_iterator cur = funcs_.find(key);
if (cur == funcs_.end())
return 0;

return (*cur).second;
}

void Design::add_task(const string&key, NetTaskDef*def)
{
tasks_[key] = def;
Expand Down Expand Up @@ -1585,6 +1642,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))

/*
* $Log: netlist.cc,v $
* Revision 1.54 1999/08/31 22:38:29 steve
* Elaborate and emit to vvm procedural functions.
*
* Revision 1.53 1999/08/25 22:22:41 steve
* elaborate some aspects of functions.
*
Expand Down

0 comments on commit e69345b

Please sign in to comment.