Skip to content

Commit

Permalink
Emit vvm for user defined tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Jul 7, 1999
1 parent 63159ab commit e58844f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 12 deletions.
21 changes: 12 additions & 9 deletions 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.15 1999/07/03 02:12:51 steve Exp $"
#ident "$Id: emit.cc,v 1.16 1999/07/07 04:20:57 steve Exp $"
#endif

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


// emit task definitions
{
map<string,NetTaskDef*>::const_iterator ta;
for (ta = tasks_.begin() ; ta != tasks_.end() ; ta ++) {
tgt->task_def(o, (*ta).second);
}
}

// emit nodes
if (nodes_) {
NetNode*cur = nodes_->node_next_;
Expand All @@ -242,6 +234,14 @@ void Design::emit(ostream&o, struct target_t*tgt) const
}


// emit task definitions
{
map<string,NetTaskDef*>::const_iterator ta;
for (ta = tasks_.begin() ; ta != tasks_.end() ; ta ++) {
tgt->task_def(o, (*ta).second);
}
}

// emit the processes
for (const NetProcTop*idx = procs_ ; idx ; idx = idx->next_)
idx->emit(o, tgt);
Expand Down Expand Up @@ -308,6 +308,9 @@ void emit(ostream&o, const Design*des, const char*type)

/*
* $Log: emit.cc,v $
* Revision 1.16 1999/07/07 04:20:57 steve
* Emit vvm for user defined tasks.
*
* Revision 1.15 1999/07/03 02:12:51 steve
* Elaborate user defined tasks.
*
Expand Down
7 changes: 6 additions & 1 deletion netlist.h
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: netlist.h,v 1.43 1999/07/03 02:12:51 steve Exp $"
#ident "$Id: netlist.h,v 1.44 1999/07/07 04:20:57 steve Exp $"
#endif

/*
Expand Down Expand Up @@ -877,6 +877,7 @@ class NetTaskDef {
~NetTaskDef();

const string& name() const { return name_; }
const NetProc*proc() const { return proc_; }

void dump(ostream&, unsigned) const;

Expand All @@ -899,6 +900,7 @@ class NetUTask : public NetProc {
NetUTask(NetTaskDef*, const svector<NetExpr*>&);
~NetUTask();

const string& name() const { return task_->name(); }
unsigned nparms() const { return parms_.count(); }

const NetExpr* parm(unsigned idx) const;
Expand Down Expand Up @@ -1336,6 +1338,9 @@ extern ostream& operator << (ostream&, NetNet::Type);

/*
* $Log: netlist.h,v $
* Revision 1.44 1999/07/07 04:20:57 steve
* Emit vvm for user defined tasks.
*
* Revision 1.43 1999/07/03 02:12:51 steve
* Elaborate user defined tasks.
*
Expand Down
44 changes: 42 additions & 2 deletions t-vvm.cc
Expand Up @@ -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.27 1999/07/03 02:12:52 steve Exp $"
#ident "$Id: t-vvm.cc,v 1.28 1999/07/07 04:20:57 steve Exp $"
#endif

# include <iostream>
Expand All @@ -42,6 +42,7 @@ class target_vvm : public target_t {
virtual void start_design(ostream&os, const Design*);
virtual void signal(ostream&os, const NetNet*);
virtual void memory(ostream&os, const NetMemory*);
virtual void task_def(ostream&os, const NetTaskDef*);
virtual void logic(ostream&os, const NetLogic*);
virtual void bufz(ostream&os, const NetBUFZ*);
virtual void udp(ostream&os, const NetUDP*);
Expand All @@ -59,6 +60,7 @@ class target_vvm : public target_t {
virtual void proc_forever(ostream&os, const NetForever*);
virtual void proc_repeat(ostream&os, const NetRepeat*);
virtual void proc_stask(ostream&os, const NetSTask*);
virtual void proc_utask(ostream&os, const NetUTask*);
virtual void proc_while(ostream&os, const NetWhile*);
virtual void proc_event(ostream&os, const NetPEvent*);
virtual void proc_delay(ostream&os, const NetPDelay*);
Expand Down Expand Up @@ -422,6 +424,28 @@ void target_vvm::memory(ostream&os, const NetMemory*mem)
"/* " << mem->name() << " */" << endl;
}

void target_vvm::task_def(ostream&os, const NetTaskDef*def)
{
thread_step_ = 0;
const string name = mangle(def->name());
os << "class " << name << " : public vvm_thread {" << endl;
os << " public:" << endl;
os << " " << name << "(vvm_simulation*sim, vvm_thread*th)" << endl;
os << " : vvm_thread(sim), back_(th), step_(&step_0_)" << endl;
os << " { }" << endl;
os << " ~" << name << "() { }" << endl;
os << " bool go() { return (this->*step_)(); }" << endl;
os << " private:" << endl;
os << " vvm_thread*back_;" << endl;
os << " bool (" << name << "::*step_)();" << endl;
os << " bool step_0_() {" << endl;
def->proc()->emit_proc(os, this);
os << " sim_->thread_active(back_);" << endl;
os << " return false;" << endl;
os << " }" << endl;
os << "};" << endl;
}

/*
* This method handles writing output functions for gates that have a
* single output (at pin 0). This writes the output_fun method into
Expand Down Expand Up @@ -793,7 +817,7 @@ void target_vvm::start_process(ostream&os, const NetProcTop*proc)
os << " private:" << endl;
os << " bool (thread" << process_counter <<
"_t::*step_)();" << endl;

os << " vvm_thread*callee_;" << endl;
os << " bool step_0_() {" << endl;
}

Expand Down Expand Up @@ -1058,6 +1082,19 @@ void target_vvm::proc_stask(ostream&os, const NetSTask*net)
net->nparms() << ", " << ptmp << ");" << endl;
}

void target_vvm::proc_utask(ostream&os, const NetUTask*net)
{
unsigned out_step = ++thread_step_;
const string name = mangle(net->name());
os << " callee_ = new " << name << "(sim_, this);" << endl;
os << " step_ = &step_" << out_step << "_;" << endl;
os << " return false;" << endl;
os << " }" << endl;
os << " bool step_" << out_step << "_()" << endl;
os << " {" << endl;
os << " delete callee_;" << endl;
}

/*
* The while loop is implemented by making each iteration one [or
* more] basic block and letting the loop condition skip to the block
Expand Down Expand Up @@ -1202,6 +1239,9 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
* Revision 1.28 1999/07/07 04:20:57 steve
* Emit vvm for user defined tasks.
*
* Revision 1.27 1999/07/03 02:12:52 steve
* Elaborate user defined tasks.
*
Expand Down

0 comments on commit e58844f

Please sign in to comment.