save the thread class name so that behaviors in tasks have it.
This commit is contained in:
parent
a964e0479b
commit
9f30615a91
113
t-vvm.cc
113
t-vvm.cc
|
|
@ -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: t-vvm.cc,v 1.48 1999/09/28 01:53:37 steve Exp $"
|
#ident "$Id: t-vvm.cc,v 1.49 1999/09/28 03:11:09 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
|
|
@ -76,6 +76,10 @@ class target_vvm : public target_t {
|
||||||
private:
|
private:
|
||||||
void emit_gate_outputfun_(const NetNode*);
|
void emit_gate_outputfun_(const NetNode*);
|
||||||
|
|
||||||
|
// This is the name of the thread (process or task) that is
|
||||||
|
// being generated.
|
||||||
|
string thread_class_;
|
||||||
|
|
||||||
ostrstream delayed;
|
ostrstream delayed;
|
||||||
ostrstream init_code;
|
ostrstream init_code;
|
||||||
ostrstream start_code;
|
ostrstream start_code;
|
||||||
|
|
@ -597,6 +601,9 @@ void target_vvm::task_def(ostream&os, const NetTaskDef*def)
|
||||||
{
|
{
|
||||||
thread_step_ = 0;
|
thread_step_ = 0;
|
||||||
const string name = mangle(def->name());
|
const string name = mangle(def->name());
|
||||||
|
const string save_thread_class = thread_class_;
|
||||||
|
thread_class_ = name;
|
||||||
|
|
||||||
os << "class " << name << " : public vvm_thread {" << endl;
|
os << "class " << name << " : public vvm_thread {" << endl;
|
||||||
os << " public:" << endl;
|
os << " public:" << endl;
|
||||||
os << " " << name << "(vvm_simulation*sim, vvm_thread*th)" << endl;
|
os << " " << name << "(vvm_simulation*sim, vvm_thread*th)" << endl;
|
||||||
|
|
@ -613,6 +620,8 @@ void target_vvm::task_def(ostream&os, const NetTaskDef*def)
|
||||||
os << " return false;" << endl;
|
os << " return false;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
os << "};" << endl;
|
os << "};" << endl;
|
||||||
|
|
||||||
|
thread_class_ = save_thread_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1013,23 +1022,24 @@ void target_vvm::net_event(ostream&os, const NetNEvent*gate)
|
||||||
void target_vvm::start_process(ostream&os, const NetProcTop*proc)
|
void target_vvm::start_process(ostream&os, const NetProcTop*proc)
|
||||||
{
|
{
|
||||||
process_counter += 1;
|
process_counter += 1;
|
||||||
|
{ ostrstream ts;
|
||||||
|
ts << "thread" << process_counter << "_t" << ends;
|
||||||
|
thread_class_ = ts.str();
|
||||||
|
}
|
||||||
thread_step_ = 0;
|
thread_step_ = 0;
|
||||||
|
|
||||||
os << "class thread" << process_counter <<
|
os << "class " << thread_class_ << " : public vvm_thread {" << endl;
|
||||||
"_t : public vvm_thread {" << endl;
|
|
||||||
|
|
||||||
os << " public:" << endl;
|
os << " public:" << endl;
|
||||||
os << " thread" << process_counter <<
|
os << " " << thread_class_ << "(vvm_simulation*sim)" << endl;
|
||||||
"_t(vvm_simulation*sim)" << endl;
|
os << " : vvm_thread(sim), step_(&" << thread_class_ <<
|
||||||
os << " : vvm_thread(sim), step_(&thread" <<
|
"::step_0_)" << endl;
|
||||||
process_counter << "_t::step_0_)" << endl;
|
|
||||||
os << " { }" << endl;
|
os << " { }" << endl;
|
||||||
os << " ~thread" << process_counter << "_t() { }" << endl;
|
os << " ~" << thread_class_ << "() { }" << endl;
|
||||||
os << endl;
|
os << endl;
|
||||||
os << " bool go() { return (this->*step_)(); }" << endl;
|
os << " bool go() { return (this->*step_)(); }" << endl;
|
||||||
os << " private:" << endl;
|
os << " private:" << endl;
|
||||||
os << " bool (thread" << process_counter <<
|
os << " bool (" << thread_class_ << "::*step_)();" << endl;
|
||||||
"_t::*step_)();" << endl;
|
|
||||||
os << " vvm_thread*callee_;" << endl;
|
os << " vvm_thread*callee_;" << endl;
|
||||||
os << " bool step_0_() {" << endl;
|
os << " bool step_0_() {" << endl;
|
||||||
}
|
}
|
||||||
|
|
@ -1163,8 +1173,8 @@ void target_vvm::proc_case(ostream&os, const NetCase*net)
|
||||||
|
|
||||||
os << " if (" << expr << ".eequal(" << guard <<
|
os << " if (" << expr << ".eequal(" << guard <<
|
||||||
")) {" << endl;
|
")) {" << endl;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ <<
|
||||||
"_t::step_" << thread_step_ << "_;" << endl;
|
"::step_" << thread_step_ << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
|
|
||||||
|
|
@ -1172,8 +1182,8 @@ void target_vvm::proc_case(ostream&os, const NetCase*net)
|
||||||
sc << " {" << endl;
|
sc << " {" << endl;
|
||||||
if (net->stat(idx))
|
if (net->stat(idx))
|
||||||
net->stat(idx)->emit_proc(sc, this);
|
net->stat(idx)->emit_proc(sc, this);
|
||||||
sc << " step_ = &thread" << process_counter <<
|
sc << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << exit_step << "_;" << endl;
|
exit_step << "_;" << endl;
|
||||||
sc << " return true;" << endl;
|
sc << " return true;" << endl;
|
||||||
sc << " }" << endl;
|
sc << " }" << endl;
|
||||||
}
|
}
|
||||||
|
|
@ -1188,15 +1198,15 @@ void target_vvm::proc_case(ostream&os, const NetCase*net)
|
||||||
sc << " {" << endl;
|
sc << " {" << endl;
|
||||||
if (net->stat(default_idx))
|
if (net->stat(default_idx))
|
||||||
net->stat(default_idx)->emit_proc(sc, this);
|
net->stat(default_idx)->emit_proc(sc, this);
|
||||||
sc << " step_ = &thread" << process_counter <<
|
sc << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << exit_step << "_;" << endl;
|
exit_step << "_;" << endl;
|
||||||
sc << " return true;" << endl;
|
sc << " return true;" << endl;
|
||||||
sc << " }" << endl;
|
sc << " }" << endl;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
os << " /* no default ... fall out of case. */" << endl;
|
os << " /* no default ... fall out of case. */" << endl;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << exit_step << "_;" << endl;
|
exit_step << "_;" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
os << " /* endcase */" << endl;
|
os << " /* endcase */" << endl;
|
||||||
|
|
@ -1216,27 +1226,27 @@ void target_vvm::proc_condit(ostream&os, const NetCondit*net)
|
||||||
unsigned out_step = ++thread_step_;
|
unsigned out_step = ++thread_step_;
|
||||||
|
|
||||||
os << " if (" << expr << "[0] == V1)" << endl;
|
os << " if (" << expr << "[0] == V1)" << endl;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << if_step << "_;" << endl;
|
if_step << "_;" << endl;
|
||||||
os << " else" << endl;
|
os << " else" << endl;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << else_step << "_;" << endl;
|
else_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " };" << endl;
|
os << " };" << endl;
|
||||||
|
|
||||||
os << " bool step_" << if_step << "_()" << endl;
|
os << " bool step_" << if_step << "_()" << endl;
|
||||||
os << " {" << endl;
|
os << " {" << endl;
|
||||||
net->emit_recurse_if(os, this);
|
net->emit_recurse_if(os, this);
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << out_step << "_;" << endl;
|
out_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
|
|
||||||
os << " bool step_" << else_step << "_()" << endl;
|
os << " bool step_" << else_step << "_()" << endl;
|
||||||
os << " {" << endl;
|
os << " {" << endl;
|
||||||
net->emit_recurse_else(os, this);
|
net->emit_recurse_else(os, this);
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << out_step << "_;" << endl;
|
out_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
|
|
||||||
|
|
@ -1253,15 +1263,15 @@ void target_vvm::proc_forever(ostream&os, const NetForever*net)
|
||||||
unsigned top_step = ++thread_step_;
|
unsigned top_step = ++thread_step_;
|
||||||
unsigned out_step = ++thread_step_;
|
unsigned out_step = ++thread_step_;
|
||||||
|
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << top_step << "_;" << endl;
|
top_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
os << " bool step_" << top_step << "_()" << endl;
|
os << " bool step_" << top_step << "_()" << endl;
|
||||||
os << " {" << endl;
|
os << " {" << endl;
|
||||||
net->emit_recurse(os, this);
|
net->emit_recurse(os, this);
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << top_step << "_;" << endl;
|
top_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
|
|
||||||
|
|
@ -1277,8 +1287,8 @@ void target_vvm::proc_repeat(ostream&os, const NetRepeat*net)
|
||||||
|
|
||||||
os << " step_" << top_step << "_idx_ = " << expr <<
|
os << " step_" << top_step << "_idx_ = " << expr <<
|
||||||
".as_unsigned();" << endl;
|
".as_unsigned();" << endl;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << top_step << "_;" << endl;
|
top_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
|
|
||||||
|
|
@ -1287,16 +1297,16 @@ void target_vvm::proc_repeat(ostream&os, const NetRepeat*net)
|
||||||
os << " bool step_" << top_step << "_()" << endl;
|
os << " bool step_" << top_step << "_()" << endl;
|
||||||
os << " {" << endl;
|
os << " {" << endl;
|
||||||
os << " if (step_" << top_step << "_idx_ == 0) {" << endl;
|
os << " if (step_" << top_step << "_idx_ == 0) {" << endl;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << out_step << "_;" << endl;
|
out_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
os << " step_" << top_step << "_idx_ -= 1;" << endl;
|
os << " step_" << top_step << "_idx_ -= 1;" << endl;
|
||||||
|
|
||||||
net->emit_recurse(os,this);
|
net->emit_recurse(os,this);
|
||||||
|
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << top_step << "_;" << endl;
|
top_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
|
|
||||||
|
|
@ -1341,8 +1351,8 @@ void target_vvm::proc_utask(ostream&os, const NetUTask*net)
|
||||||
unsigned out_step = ++thread_step_;
|
unsigned out_step = ++thread_step_;
|
||||||
const string name = mangle(net->name());
|
const string name = mangle(net->name());
|
||||||
os << " callee_ = new " << name << "(sim_, this);" << endl;
|
os << " callee_ = new " << name << "(sim_, this);" << endl;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << out_step << "_;" << endl;
|
out_step << "_;" << endl;
|
||||||
os << " return false;" << endl;
|
os << " return false;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
os << " bool step_" << out_step << "_()" << endl;
|
os << " bool step_" << out_step << "_()" << endl;
|
||||||
|
|
@ -1368,8 +1378,8 @@ void target_vvm::proc_while(ostream&os, const NetWhile*net)
|
||||||
unsigned head_step = ++thread_step_;
|
unsigned head_step = ++thread_step_;
|
||||||
unsigned out_step = ++thread_step_;
|
unsigned out_step = ++thread_step_;
|
||||||
|
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << head_step << "_;" << endl;
|
head_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
|
|
||||||
|
|
@ -1382,8 +1392,8 @@ void target_vvm::proc_while(ostream&os, const NetWhile*net)
|
||||||
os << " // " << net->expr()->get_line() <<
|
os << " // " << net->expr()->get_line() <<
|
||||||
": test while condition." << endl;
|
": test while condition." << endl;
|
||||||
os << " if (" << expr << "[0] != V1) {" << endl;
|
os << " if (" << expr << "[0] != V1) {" << endl;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << out_step << "_;" << endl;
|
out_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
|
|
||||||
|
|
@ -1391,8 +1401,8 @@ void target_vvm::proc_while(ostream&os, const NetWhile*net)
|
||||||
|
|
||||||
os << " // " << net->expr()->get_line() <<
|
os << " // " << net->expr()->get_line() <<
|
||||||
": end of while loop." << endl;
|
": end of while loop." << endl;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << head_step << "_;" << endl;
|
head_step << "_;" << endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
os << " }" << endl;
|
os << " }" << endl;
|
||||||
|
|
||||||
|
|
@ -1407,8 +1417,8 @@ void target_vvm::proc_while(ostream&os, const NetWhile*net)
|
||||||
void target_vvm::proc_event(ostream&os, const NetPEvent*proc)
|
void target_vvm::proc_event(ostream&os, const NetPEvent*proc)
|
||||||
{
|
{
|
||||||
thread_step_ += 1;
|
thread_step_ += 1;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << thread_step_ << "_;" << endl;
|
thread_step_ << "_;" << endl;
|
||||||
|
|
||||||
/* POSITIVE is for the wait construct, and needs to be handled
|
/* POSITIVE is for the wait construct, and needs to be handled
|
||||||
specially. The structure of the generated code is:
|
specially. The structure of the generated code is:
|
||||||
|
|
@ -1464,8 +1474,8 @@ void target_vvm::proc_event(ostream&os, const NetPEvent*proc)
|
||||||
void target_vvm::proc_delay(ostream&os, const NetPDelay*proc)
|
void target_vvm::proc_delay(ostream&os, const NetPDelay*proc)
|
||||||
{
|
{
|
||||||
thread_step_ += 1;
|
thread_step_ += 1;
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_" <<
|
||||||
"_t::step_" << thread_step_ << "_;" << endl;
|
thread_step_ << "_;" << endl;
|
||||||
os << " sim_->thread_delay(" << proc->delay() << ", this);"
|
os << " sim_->thread_delay(" << proc->delay() << ", this);"
|
||||||
<< endl;
|
<< endl;
|
||||||
os << " return false;" << endl;
|
os << " return false;" << endl;
|
||||||
|
|
@ -1479,8 +1489,8 @@ void target_vvm::proc_delay(ostream&os, const NetPDelay*proc)
|
||||||
void target_vvm::end_process(ostream&os, const NetProcTop*proc)
|
void target_vvm::end_process(ostream&os, const NetProcTop*proc)
|
||||||
{
|
{
|
||||||
if (proc->type() == NetProcTop::KALWAYS) {
|
if (proc->type() == NetProcTop::KALWAYS) {
|
||||||
os << " step_ = &thread" << process_counter <<
|
os << " step_ = &" << thread_class_ << "::step_0_;"
|
||||||
"_t::step_0_;" << endl;
|
<< endl;
|
||||||
os << " return true;" << endl;
|
os << " return true;" << endl;
|
||||||
} else {
|
} else {
|
||||||
os << " step_ = 0;" << endl;
|
os << " step_ = 0;" << endl;
|
||||||
|
|
@ -1500,6 +1510,9 @@ extern const struct target tgt_vvm = {
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
* $Log: t-vvm.cc,v $
|
* $Log: t-vvm.cc,v $
|
||||||
|
* Revision 1.49 1999/09/28 03:11:09 steve
|
||||||
|
* save the thread class name so that behaviors in tasks have it.
|
||||||
|
*
|
||||||
* Revision 1.48 1999/09/28 01:53:37 steve
|
* Revision 1.48 1999/09/28 01:53:37 steve
|
||||||
* Generate code for repeat concatenations.
|
* Generate code for repeat concatenations.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue