From d58533fd7b93f33cbf5964441b6634f8e6427821 Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 8 Aug 2000 01:50:42 +0000 Subject: [PATCH] target methods need not take a file stream. --- emit.cc | 231 ++++++++++++++-------------- netlist.h | 109 ++++++------- t-null.cc | 40 ++--- t-verilog.cc | 123 +++++++++------ t-vvm.cc | 420 ++++++++++++++++++++++++++------------------------- t-xnf.cc | 185 ++++++++++++----------- target.cc | 101 +++++++------ target.h | 102 +++++++------ 8 files changed, 681 insertions(+), 630 deletions(-) diff --git a/emit.cc b/emit.cc index d73722a0d..e089b6b62 100644 --- a/emit.cc +++ b/emit.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: emit.cc,v 1.48 2000/07/30 18:25:43 steve Exp $" +#ident "$Id: emit.cc,v 1.49 2000/08/08 01:50:42 steve Exp $" #endif /* @@ -30,220 +30,220 @@ # include # include -void NetNode::emit_node(ostream&o, struct target_t*tgt) const +void NetNode::emit_node(struct target_t*tgt) const { cerr << "EMIT: Gate type? " << typeid(*this).name() << endl; } -void NetLogic::emit_node(ostream&o, struct target_t*tgt) const +void NetLogic::emit_node(struct target_t*tgt) const { - tgt->logic(o, this); + tgt->logic(this); } -void NetUDP_COMB::emit_node(ostream&o, struct target_t*tgt) const +void NetUDP_COMB::emit_node(struct target_t*tgt) const { - tgt->udp_comb(o, this); + tgt->udp_comb(this); } -void NetUDP::emit_node(ostream&o, struct target_t*tgt) const +void NetUDP::emit_node(struct target_t*tgt) const { - tgt->udp(o, this); + tgt->udp(this); } -void NetAddSub::emit_node(ostream&o, struct target_t*tgt) const +void NetAddSub::emit_node(struct target_t*tgt) const { - tgt->lpm_add_sub(o, this); + tgt->lpm_add_sub(this); } -void NetAssign::emit_node(ostream&o, struct target_t*tgt) const +void NetAssign::emit_node(struct target_t*tgt) const { - tgt->net_assign(o, this); + tgt->net_assign(this); } -void NetAssignNB::emit_node(ostream&o, struct target_t*tgt) const +void NetAssignNB::emit_node(struct target_t*tgt) const { - tgt->net_assign_nb(o, this); + tgt->net_assign_nb(this); } -void NetCaseCmp::emit_node(ostream&o, struct target_t*tgt) const +void NetCaseCmp::emit_node(struct target_t*tgt) const { - tgt->net_case_cmp(o, this); + tgt->net_case_cmp(this); } -void NetCAssign::emit_node(ostream&o, struct target_t*tgt) const +void NetCAssign::emit_node(struct target_t*tgt) const { - tgt->net_cassign(o, this); + tgt->net_cassign(this); } -void NetCLShift::emit_node(ostream&o, struct target_t*tgt) const +void NetCLShift::emit_node(struct target_t*tgt) const { - tgt->lpm_clshift(o, this); + tgt->lpm_clshift(this); } -void NetCompare::emit_node(ostream&o, struct target_t*tgt) const +void NetCompare::emit_node(struct target_t*tgt) const { - tgt->lpm_compare(o, this); + tgt->lpm_compare(this); } -void NetConst::emit_node(ostream&o, struct target_t*tgt) const +void NetConst::emit_node(struct target_t*tgt) const { - tgt->net_const(o, this); + tgt->net_const(this); } -void NetDivide::emit_node(ostream&o, struct target_t*tgt) const +void NetDivide::emit_node(struct target_t*tgt) const { - tgt->lpm_divide(o, this); + tgt->lpm_divide(this); } -void NetFF::emit_node(ostream&o, struct target_t*tgt) const +void NetFF::emit_node(struct target_t*tgt) const { - tgt->lpm_ff(o, this); + tgt->lpm_ff(this); } -void NetForce::emit_node(ostream&o, struct target_t*tgt) const +void NetForce::emit_node(struct target_t*tgt) const { - tgt->net_force(o, this); + tgt->net_force(this); } -void NetMult::emit_node(ostream&o, struct target_t*tgt) const +void NetMult::emit_node(struct target_t*tgt) const { - tgt->lpm_mult(o, this); + tgt->lpm_mult(this); } -void NetMux::emit_node(ostream&o, struct target_t*tgt) const +void NetMux::emit_node(struct target_t*tgt) const { - tgt->lpm_mux(o, this); + tgt->lpm_mux(this); } -void NetRamDq::emit_node(ostream&o, struct target_t*tgt) const +void NetRamDq::emit_node(struct target_t*tgt) const { - tgt->lpm_ram_dq(o, this); + tgt->lpm_ram_dq(this); } -void NetBUFZ::emit_node(ostream&o, struct target_t*tgt) const +void NetBUFZ::emit_node(struct target_t*tgt) const { - tgt->bufz(o, this); + tgt->bufz(this); } -bool NetProcTop::emit(ostream&o, struct target_t*tgt) const +bool NetProcTop::emit(struct target_t*tgt) const { - return tgt->process(o, this); + return tgt->process(this); } -bool NetProc::emit_proc(ostream&o, struct target_t*tgt) const +bool NetProc::emit_proc(struct target_t*tgt) const { cerr << "EMIT: Proc type? " << typeid(*this).name() << endl; return false; } -bool NetAssign::emit_proc(ostream&o, struct target_t*tgt) const +bool NetAssign::emit_proc(struct target_t*tgt) const { - tgt->proc_assign(o, this); + tgt->proc_assign(this); return true; } -bool NetAssignNB::emit_proc(ostream&o, struct target_t*tgt) const +bool NetAssignNB::emit_proc(struct target_t*tgt) const { - tgt->proc_assign_nb(o, this); + tgt->proc_assign_nb(this); return true; } -bool NetAssignMem::emit_proc(ostream&o, struct target_t*tgt) const +bool NetAssignMem::emit_proc(struct target_t*tgt) const { - tgt->proc_assign_mem(o, this); + tgt->proc_assign_mem(this); return true; } -bool NetAssignMemNB::emit_proc(ostream&o, struct target_t*tgt) const +bool NetAssignMemNB::emit_proc(struct target_t*tgt) const { - tgt->proc_assign_mem_nb(o, this); + tgt->proc_assign_mem_nb(this); return true; } -bool NetBlock::emit_proc(ostream&o, struct target_t*tgt) const +bool NetBlock::emit_proc(struct target_t*tgt) const { - return tgt->proc_block(o, this); + return tgt->proc_block(this); } -bool NetCase::emit_proc(ostream&o, struct target_t*tgt) const +bool NetCase::emit_proc(struct target_t*tgt) const { - tgt->proc_case(o, this); + tgt->proc_case(this); return true; } -bool NetCAssign::emit_proc(ostream&o, struct target_t*tgt) const +bool NetCAssign::emit_proc(struct target_t*tgt) const { - return tgt->proc_cassign(o, this); + return tgt->proc_cassign(this); } -bool NetCondit::emit_proc(ostream&o, struct target_t*tgt) const +bool NetCondit::emit_proc(struct target_t*tgt) const { - tgt->proc_condit(o, this); + tgt->proc_condit(this); return true; } -bool NetDeassign::emit_proc(ostream&o, struct target_t*tgt) const +bool NetDeassign::emit_proc(struct target_t*tgt) const { - return tgt->proc_deassign(o, this); + return tgt->proc_deassign(this); } -bool NetDisable::emit_proc(ostream&o, struct target_t*tgt) const +bool NetDisable::emit_proc(struct target_t*tgt) const { - return tgt->proc_disable(o, this); + return tgt->proc_disable(this); } -bool NetForce::emit_proc(ostream&o, struct target_t*tgt) const +bool NetForce::emit_proc(struct target_t*tgt) const { - return tgt->proc_force(o, this); + return tgt->proc_force(this); } -bool NetForever::emit_proc(ostream&o, struct target_t*tgt) const +bool NetForever::emit_proc(struct target_t*tgt) const { - tgt->proc_forever(o, this); + tgt->proc_forever(this); return true; } -bool NetPDelay::emit_proc(ostream&o, struct target_t*tgt) const +bool NetPDelay::emit_proc(struct target_t*tgt) const { - return tgt->proc_delay(o, this); + return tgt->proc_delay(this); } -bool NetPDelay::emit_proc_recurse(ostream&o, struct target_t*tgt) const +bool NetPDelay::emit_proc_recurse(struct target_t*tgt) const { - if (statement_) return statement_->emit_proc(o, tgt); + if (statement_) return statement_->emit_proc(tgt); return true; } -bool NetRelease::emit_proc(ostream&o, struct target_t*tgt) const +bool NetRelease::emit_proc(struct target_t*tgt) const { - return tgt->proc_release(o, this); + return tgt->proc_release(this); } -bool NetRepeat::emit_proc(ostream&o, struct target_t*tgt) const +bool NetRepeat::emit_proc(struct target_t*tgt) const { - tgt->proc_repeat(o, this); + tgt->proc_repeat(this); return true; } -bool NetSTask::emit_proc(ostream&o, struct target_t*tgt) const +bool NetSTask::emit_proc(struct target_t*tgt) const { - tgt->proc_stask(o, this); + tgt->proc_stask(this); return true; } -bool NetUTask::emit_proc(ostream&o, struct target_t*tgt) const +bool NetUTask::emit_proc(struct target_t*tgt) const { - tgt->proc_utask(o, this); + tgt->proc_utask(this); return true; } -bool NetWhile::emit_proc(ostream&o, struct target_t*tgt) const +bool NetWhile::emit_proc(struct target_t*tgt) const { - tgt->proc_while(o, this); + tgt->proc_while(this); return true; } -void NetBlock::emit_recurse(ostream&o, struct target_t*tgt) const +void NetBlock::emit_recurse(struct target_t*tgt) const { if (last_ == 0) return; @@ -251,69 +251,69 @@ void NetBlock::emit_recurse(ostream&o, struct target_t*tgt) const NetProc*cur = last_; do { cur = cur->next_; - cur->emit_proc(o, tgt); + cur->emit_proc(tgt); } while (cur != last_); } -void NetCondit::emit_recurse_if(ostream&o, struct target_t*tgt) const +void NetCondit::emit_recurse_if(struct target_t*tgt) const { if (if_) - if_->emit_proc(o, tgt); + if_->emit_proc(tgt); } -void NetCondit::emit_recurse_else(ostream&o, struct target_t*tgt) const +void NetCondit::emit_recurse_else(struct target_t*tgt) const { if (else_) - else_->emit_proc(o, tgt); + else_->emit_proc(tgt); } -void NetEvProbe::emit_node(ostream&o, struct target_t*tgt) const +void NetEvProbe::emit_node(struct target_t*tgt) const { - tgt->net_probe(o, this); + tgt->net_probe(this); } -bool NetEvTrig::emit_proc(ostream&o, struct target_t*tgt) const +bool NetEvTrig::emit_proc(struct target_t*tgt) const { - return tgt->proc_trigger(o, this); + return tgt->proc_trigger(this); } -bool NetEvWait::emit_proc(ostream&o, struct target_t*tgt) const +bool NetEvWait::emit_proc(struct target_t*tgt) const { - return tgt->proc_wait(o, this); + return tgt->proc_wait(this); } -bool NetEvWait::emit_recurse(ostream&o, struct target_t*tgt) const +bool NetEvWait::emit_recurse(struct target_t*tgt) const { if (!statement_) return true; - return statement_->emit_proc(o, tgt); + return statement_->emit_proc(tgt); } -void NetForever::emit_recurse(ostream&o, struct target_t*tgt) const +void NetForever::emit_recurse(struct target_t*tgt) const { if (statement_) - statement_->emit_proc(o, tgt); + statement_->emit_proc(tgt); } -void NetRepeat::emit_recurse(ostream&o, struct target_t*tgt) const +void NetRepeat::emit_recurse(struct target_t*tgt) const { if (statement_) - statement_->emit_proc(o, tgt); + statement_->emit_proc(tgt); } -void NetScope::emit_scope(ostream&o, struct target_t*tgt) const +void NetScope::emit_scope(struct target_t*tgt) const { - tgt->scope(o, this); + tgt->scope(this); for (NetEvent*cur = events_ ; cur ; cur = cur->snext_) - tgt->event(o, cur); + tgt->event(cur); for (NetScope*cur = sub_ ; cur ; cur = cur->sib_) - cur->emit_scope(o, tgt); + cur->emit_scope(tgt); if (signals_) { NetNet*cur = signals_->sig_next_; do { - tgt->signal(o, cur); + tgt->signal(cur); cur = cur->sig_next_; } while (cur != signals_->sig_next_); } @@ -321,34 +321,34 @@ void NetScope::emit_scope(ostream&o, struct target_t*tgt) const if (memories_) { NetMemory*cur = memories_->snext_; do { - tgt->memory(o, cur); + tgt->memory(cur); cur = cur->snext_; } while (cur != memories_->snext_); } } -void NetScope::emit_defs(ostream&o, struct target_t*tgt) const +void NetScope::emit_defs(struct target_t*tgt) const { switch (type_) { case MODULE: for (NetScope*cur = sub_ ; cur ; cur = cur->sib_) - cur->emit_defs(o, tgt); + cur->emit_defs(tgt); break; case FUNC: - tgt->func_def(o, this->func_def()); + tgt->func_def(this->func_def()); break; case TASK: - tgt->task_def(o, this->task_def()); + tgt->task_def(this->task_def()); break; } } -void NetWhile::emit_proc_recurse(ostream&o, struct target_t*tgt) const +void NetWhile::emit_proc_recurse(struct target_t*tgt) const { - proc_->emit_proc(o, tgt); + proc_->emit_proc(tgt); } bool Design::emit(ostream&o, struct target_t*tgt) const @@ -357,28 +357,28 @@ bool Design::emit(ostream&o, struct target_t*tgt) const tgt->start_design(o, this); // enumerate the scopes - root_scope_->emit_scope(o, tgt); + root_scope_->emit_scope(tgt); // emit nodes if (nodes_) { NetNode*cur = nodes_->node_next_; do { - cur->emit_node(o, tgt); + cur->emit_node(tgt); cur = cur->node_next_; } while (cur != nodes_->node_next_); } // emit task and function definitions - root_scope_->emit_defs(o, tgt); + root_scope_->emit_defs(tgt); // emit the processes for (const NetProcTop*idx = procs_ ; idx ; idx = idx->next_) - rc = rc && idx->emit(o, tgt); + rc = rc && idx->emit(tgt); - tgt->end_design(o, this); + tgt->end_design(this); return rc; } @@ -461,6 +461,9 @@ bool emit(ostream&o, const Design*des, const char*type) /* * $Log: emit.cc,v $ + * Revision 1.49 2000/08/08 01:50:42 steve + * target methods need not take a file stream. + * * Revision 1.48 2000/07/30 18:25:43 steve * Rearrange task and function elaboration so that the * NetTaskDef and NetFuncDef functions are created during diff --git a/netlist.h b/netlist.h index c65203489..588f61a85 100644 --- a/netlist.h +++ b/netlist.h @@ -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.153 2000/08/02 14:48:15 steve Exp $" +#ident "$Id: netlist.h,v 1.154 2000/08/08 01:50:42 steve Exp $" #endif /* @@ -263,7 +263,7 @@ class NetNode : public NetObj { // connected to the same of my own pins. NetNode*next_node(); - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual void dump_node(ostream&, unsigned) const; // This is used to scan a modifiable netlist, one node at a time. @@ -388,7 +388,7 @@ class NetAddSub : public NetNode { const Link& pin_Result(unsigned idx) const; virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual void functor_node(Design*des, functor_t*fun); }; @@ -419,7 +419,7 @@ class NetCLShift : public NetNode { const Link& pin_Distance(unsigned idx) const; virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; private: unsigned width_; @@ -467,7 +467,7 @@ class NetCompare : public NetNode { virtual void functor_node(Design*, functor_t*); virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; private: unsigned width_; @@ -502,7 +502,7 @@ class NetDivide : public NetNode { const Link& pin_Result(unsigned idx) const; virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual void functor_node(Design*des, functor_t*fun); private: @@ -541,7 +541,7 @@ class NetFF : public NetNode { const Link& pin_Q(unsigned) const; virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual void functor_node(Design*des, functor_t*fun); }; @@ -638,7 +638,7 @@ class NetMult : public NetNode { const Link& pin_Sum(unsigned idx) const; virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual void functor_node(Design*des, functor_t*fun); private: @@ -684,7 +684,7 @@ class NetMux : public NetNode { const Link& pin_Sel(unsigned) const; virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual void functor_node(Design*des, functor_t*fun); private: @@ -727,7 +727,7 @@ class NetRamDq : public NetNode { const Link& pin_Q(unsigned idx) const; virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; // Use this method to absorb other NetRamDq objects that are // connected to the same memory, and have compatible pin @@ -849,7 +849,7 @@ class NetBUFZ : public NetNode { ~NetBUFZ(); virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; }; /* @@ -870,7 +870,7 @@ class NetCaseCmp : public NetNode { ~NetCaseCmp(); virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; }; /* @@ -890,7 +890,7 @@ class NetConst : public NetNode { verinum::V value(unsigned idx) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual void functor_node(Design*, functor_t*); virtual void dump_node(ostream&, unsigned ind) const; @@ -919,7 +919,7 @@ class NetLogic : public NetNode { TYPE type() const { return type_; } virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual void functor_node(Design*, functor_t*); private: @@ -985,7 +985,7 @@ class NetUDP : public NetNode { public: explicit NetUDP(const string&n, unsigned pins, bool sequ =false); - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node( struct target_t*) const; virtual void dump_node(ostream&, unsigned ind) const; /* return false if the entry conflicts with an existing @@ -1045,7 +1045,7 @@ class NetUDP_COMB : public NetNode { public: explicit NetUDP_COMB(const string&n, unsigned pins); - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual void dump_node(ostream&, unsigned ind) const; /* append a new truth table row. */ @@ -1088,7 +1088,7 @@ class NetProc : public LineInfo { // This method is called to emit the statement to the // target. The target returns true if OK, false for errors. - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; // This method is called by functors that want to scan a // process in search of matchable patterns. @@ -1152,8 +1152,8 @@ class NetAssign : public NetAssign_ { NetExpr*mux, NetExpr*rv); ~NetAssign(); - virtual bool emit_proc(ostream&, struct target_t*) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual int match_proc(struct proc_match_t*); virtual void dump(ostream&, unsigned ind) const; virtual void dump_node(ostream&, unsigned ind) const; @@ -1172,8 +1172,8 @@ class NetAssignNB : public NetAssign_ { ~NetAssignNB(); - virtual bool emit_proc(ostream&, struct target_t*) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual int match_proc(struct proc_match_t*); virtual void dump(ostream&, unsigned ind) const; virtual void dump_node(ostream&, unsigned ind) const; @@ -1214,7 +1214,7 @@ class NetAssignMem : public NetAssignMem_ { ~NetAssignMem(); virtual int match_proc(struct proc_match_t*); - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1227,7 +1227,7 @@ class NetAssignMemNB : public NetAssignMem_ { ~NetAssignMemNB(); virtual int match_proc(struct proc_match_t*); - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1259,9 +1259,9 @@ class NetBlock : public NetProc { // This version of emit_recurse scans all the statements of // the begin-end block sequentially. It is typically of use // for sequential blocks. - void emit_recurse(ostream&, struct target_t*) const; + void emit_recurse(struct target_t*) const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual int match_proc(struct proc_match_t*); virtual void dump(ostream&, unsigned ind) const; @@ -1298,7 +1298,7 @@ class NetCase : public NetProc { const NetExpr*expr(unsigned idx) const { return items_[idx].guard;} const NetProc*stat(unsigned idx) const { return items_[idx].statement; } - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1334,9 +1334,9 @@ class NetCAssign : public NetProc, public NetNode { const Link& lval_pin(unsigned) const; virtual void dump(ostream&, unsigned ind) const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; private: NetNet*lval_; @@ -1364,10 +1364,10 @@ class NetCondit : public NetProc { // Replace the condition expression. void set_expr(NetExpr*ex); - void emit_recurse_if(ostream&, struct target_t*) const; - void emit_recurse_else(ostream&, struct target_t*) const; + void emit_recurse_if(struct target_t*) const; + void emit_recurse_else(struct target_t*) const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual int match_proc(struct proc_match_t*); virtual void dump(ostream&, unsigned ind) const; @@ -1391,7 +1391,7 @@ class NetDeassign : public NetProc { const NetNet*lval() const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1419,7 +1419,7 @@ class NetDisable : public NetProc { const NetScope*target() const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1529,7 +1529,7 @@ class NetEvTrig : public NetProc { const NetEvent*event() const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1553,8 +1553,8 @@ class NetEvWait : public NetProc { NetProc*statement(); - virtual bool emit_proc(ostream&, struct target_t*) const; - bool emit_recurse(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; + bool emit_recurse(struct target_t*) const; virtual int match_proc(struct proc_match_t*); virtual void dump(ostream&, unsigned ind) const; @@ -1580,7 +1580,7 @@ class NetEvProbe : public NetNode { NetEvent* event(); const NetEvent* event() const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; virtual void dump_node(ostream&, unsigned ind) const; private: @@ -1609,9 +1609,9 @@ class NetForce : public NetProc, public NetNode { const Link& lval_pin(unsigned) const; virtual void dump(ostream&, unsigned ind) const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump_node(ostream&, unsigned ind) const; - virtual void emit_node(ostream&, struct target_t*) const; + virtual void emit_node(struct target_t*) const; private: NetNet*lval_; @@ -1627,9 +1627,9 @@ class NetForever : public NetProc { explicit NetForever(NetProc*s); ~NetForever(); - void emit_recurse(ostream&, struct target_t*) const; + void emit_recurse(struct target_t*) const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1689,10 +1689,10 @@ class NetPDelay : public NetProc { unsigned long delay() const; const NetExpr*expr() const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; - bool emit_proc_recurse(ostream&, struct target_t*) const; + bool emit_proc_recurse(struct target_t*) const; private: unsigned long delay_; @@ -1710,9 +1710,9 @@ class NetRepeat : public NetProc { ~NetRepeat(); const NetExpr*expr() const; - void emit_recurse(ostream&, struct target_t*) const; + void emit_recurse(struct target_t*) const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1734,7 +1734,7 @@ class NetRelease : public NetProc { const NetNet*lval() const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1760,7 +1760,7 @@ class NetSTask : public NetProc { const NetExpr* parm(unsigned idx) const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1858,7 +1858,7 @@ class NetUTask : public NetProc { const string& name() const { return task_->name(); } - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1878,9 +1878,9 @@ class NetWhile : public NetProc { const NetExpr*expr() const { return cond_; } - void emit_proc_recurse(ostream&, struct target_t*) const; + void emit_proc_recurse(struct target_t*) const; - virtual bool emit_proc(ostream&, struct target_t*) const; + virtual bool emit_proc(struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; private: @@ -1907,7 +1907,7 @@ class NetProcTop : public LineInfo { const NetProc*statement() const; void dump(ostream&, unsigned ind) const; - bool emit(ostream&, struct target_t*tgt) const; + bool emit(struct target_t*tgt) const; private: const Type type_; @@ -2522,8 +2522,8 @@ class NetScope { string local_symbol(); void dump(ostream&) const; - void emit_scope(ostream&o, struct target_t*tgt) const; - void emit_defs(ostream&o, struct target_t*tgt) const; + void emit_scope(struct target_t*tgt) const; + void emit_defs(struct target_t*tgt) const; /* This method runs the functor on me. Recurse through the children of this node as well. */ @@ -2722,6 +2722,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.154 2000/08/08 01:50:42 steve + * target methods need not take a file stream. + * * Revision 1.153 2000/08/02 14:48:15 steve * cleanup. * diff --git a/t-null.cc b/t-null.cc index 97ca0eb07..8cffecc6c 100644 --- a/t-null.cc +++ b/t-null.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-null.cc,v 1.13 2000/07/29 16:21:08 steve Exp $" +#ident "$Id: t-null.cc,v 1.14 2000/08/08 01:50:42 steve Exp $" #endif # include "netlist.h" @@ -30,30 +30,32 @@ static class target_null_t : public target_t { public: - void bufz(ostream&os, const NetBUFZ*) { } - void event(ostream&, const NetEvent*) { } - void func_def(ostream&, const NetFuncDef*) { } - void memory(ostream&, const NetMemory*) { } - void task_def(ostream&, const NetTaskDef*) { } - void net_assign(ostream&os, const NetAssign*) { } - void net_assign_nb(ostream&os, const NetAssignNB*) { } - void net_const(ostream&, const NetConst*) { } - void net_esignal(ostream&, const NetESignal*) { } - void net_probe(ostream&, const NetEvProbe*) { } - bool proc_block(ostream&, const NetBlock*) { return true; } - void proc_condit(ostream&, const NetCondit*) { } - bool proc_delay(ostream&, const NetPDelay*) { return true; } - void proc_forever(ostream&, const NetForever*) { } - void proc_repeat(ostream&, const NetRepeat*) { } - void proc_stask(ostream&, const NetSTask*) { } - void proc_utask(ostream&os, const NetUTask*) { } - bool proc_wait(ostream&os, const NetEvWait*) { return true; } + void bufz(const NetBUFZ*) { } + void event(const NetEvent*) { } + void func_def(const NetFuncDef*) { } + void memory(const NetMemory*) { } + void task_def(const NetTaskDef*) { } + void net_assign(const NetAssign*) { } + void net_assign_nb(const NetAssignNB*) { } + void net_const(const NetConst*) { } + void net_probe(const NetEvProbe*) { } + bool proc_block(const NetBlock*) { return true; } + void proc_condit(const NetCondit*) { } + bool proc_delay(const NetPDelay*) { return true; } + void proc_forever(const NetForever*) { } + void proc_repeat(const NetRepeat*) { } + void proc_stask(const NetSTask*) { } + void proc_utask(const NetUTask*) { } + bool proc_wait(const NetEvWait*) { return true; } } target_null_obj; extern const struct target tgt_null = { "null", &target_null_obj }; /* * $Log: t-null.cc,v $ + * Revision 1.14 2000/08/08 01:50:42 steve + * target methods need not take a file stream. + * * Revision 1.13 2000/07/29 16:21:08 steve * Report code generation errors through proc_delay. * diff --git a/t-verilog.cc b/t-verilog.cc index c3272093d..0d50ce6fe 100644 --- a/t-verilog.cc +++ b/t-verilog.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-verilog.cc,v 1.11 2000/07/29 16:21:08 steve Exp $" +#ident "$Id: t-verilog.cc,v 1.12 2000/08/08 01:50:42 steve Exp $" #endif /* @@ -39,17 +39,24 @@ extern const struct target tgt_verilog; class target_verilog : public target_t { public: virtual void start_design(ostream&os, const Design*); - virtual void signal(ostream&os, const NetNet*); - virtual void logic(ostream&os, const NetLogic*); - virtual void bufz(ostream&os, const NetBUFZ*); - virtual void start_process(ostream&os, const NetProcTop*); - virtual bool proc_block(ostream&os, const NetBlock*); - virtual bool proc_delay(ostream&os, const NetPDelay*); - virtual void proc_stask(ostream&os, const NetSTask*); - virtual void end_design(ostream&os, const Design*); + virtual void signal(const NetNet*); + virtual void logic(const NetLogic*); + virtual void bufz(const NetBUFZ*); + + virtual bool process(const NetProcTop*); + virtual bool proc_block(const NetBlock*); + virtual bool proc_delay(const NetPDelay*); + virtual void proc_stask(const NetSTask*); + virtual void end_design(const Design*); + private: + void start_process(const NetProcTop*); + void end_process(const NetProcTop*); unsigned indent_; + ostream*out_; +# define OS (*out_) + void emit_expr_(ostream&os, const NetExpr*); }; @@ -64,6 +71,7 @@ void target_verilog::start_design(ostream&os, const Design*) { indent_ = 0; os << "module " << "main" << ";" << endl; + out_ = &os; } /* @@ -71,85 +79,97 @@ void target_verilog::start_design(ostream&os, const Design*) * chance to declare signal variables before the network is assembled * or behaviors are written. */ -void target_verilog::signal(ostream&os, const NetNet*net) +void target_verilog::signal(const NetNet*net) { - os << " " << net->type(); + OS << " " << net->type(); if (net->pin_count() > 1) - os << " [" << net->msb() << ":" << net->lsb() << "]"; + OS << " [" << net->msb() << ":" << net->lsb() << "]"; if (net->rise_time()) - os << " #" << net->rise_time(); + OS << " #" << net->rise_time(); - os << " " << mangle(net->name()) << ";" << endl; + OS << " " << mangle(net->name()) << ";" << endl; } -void target_verilog::logic(ostream&os, const NetLogic*net) +void target_verilog::logic(const NetLogic*net) { switch (net->type()) { case NetLogic::AND: - os << " and"; + OS << " and"; break; case NetLogic::NAND: - os << " nand"; + OS << " nand"; break; case NetLogic::NOR: - os << " nor"; + OS << " nor"; break; case NetLogic::NOT: - os << " not"; + OS << " not"; break; case NetLogic::OR: - os << " or"; + OS << " or"; break; case NetLogic::XNOR: - os << " xnor"; + OS << " xnor"; break; case NetLogic::XOR: - os << " xor"; + OS << " xor"; break; } - os << " #" << net->rise_time() << " " << mangle(net->name()) << "("; + OS << " #" << net->rise_time() << " " << mangle(net->name()) << "("; unsigned sidx; const NetNet*sig = find_link_signal(net, 0, sidx); - os << mangle(sig->name()) << "[" << sidx << "]"; + OS << mangle(sig->name()) << "[" << sidx << "]"; for (unsigned idx = 1 ; idx < net->pin_count() ; idx += 1) { sig = find_link_signal(net, idx, sidx); assert(sig); - os << ", " << mangle(sig->name()) << "[" << sidx << "]"; + OS << ", " << mangle(sig->name()) << "[" << sidx << "]"; } - os << ");" << endl; + OS << ");" << endl; } -void target_verilog::bufz(ostream&os, const NetBUFZ*net) +void target_verilog::bufz(const NetBUFZ*net) { assert( net->pin_count() == 2 ); - os << " assign "; + OS << " assign "; unsigned sidx; const NetNet*sig = find_link_signal(net, 0, sidx); - os << mangle(sig->name()) << "[" << sidx << "] = "; + OS << mangle(sig->name()) << "[" << sidx << "] = "; sig = find_link_signal(net, 1, sidx); - os << mangle(sig->name()) << "[" << sidx << "];" << endl; + OS << mangle(sig->name()) << "[" << sidx << "];" << endl; } -void target_verilog::start_process(ostream&os, const NetProcTop*proc) +bool target_verilog::process(const NetProcTop*top) +{ + start_process(top); + bool rc = top->statement()->emit_proc(this); + end_process(top); + return rc; +} + +void target_verilog::start_process(const NetProcTop*proc) { switch (proc->type()) { case NetProcTop::KINITIAL: - os << " initial" << endl; + OS << " initial" << endl; break; case NetProcTop::KALWAYS: - os << " always" << endl; + OS << " always" << endl; break; } indent_ = 6; } +void target_verilog::end_process(const NetProcTop*) +{ +} + void target_verilog::emit_expr_(ostream&os, const NetExpr*expr) { @@ -172,22 +192,22 @@ void target_verilog::emit_expr_(ostream&os, const NetExpr*expr) } } -bool target_verilog::proc_block(ostream&os, const NetBlock*net) +bool target_verilog::proc_block(const NetBlock*net) { - os << setw(indent_) << "" << "begin" << endl; + OS << setw(indent_) << "" << "begin" << endl; indent_ += 4; - net->emit_recurse(os, this); + net->emit_recurse(this); indent_ -= 4; - os << setw(indent_) << "" << "end" << endl; + OS << setw(indent_) << "" << "end" << endl; return true; } -bool target_verilog::proc_delay(ostream&os, const NetPDelay*net) +bool target_verilog::proc_delay(const NetPDelay*net) { - os << setw(indent_) << "" << "#" << net->delay() << endl; + OS << setw(indent_) << "" << "#" << net->delay() << endl; indent_ += 4; - bool flag = net->emit_proc_recurse(os, this); + bool flag = net->emit_proc_recurse(this); indent_ -= 4; return flag; } @@ -208,20 +228,20 @@ static void vtask_parm(ostream&os, const NetExpr*ex) } } -void target_verilog::proc_stask(ostream&os, const NetSTask*net) +void target_verilog::proc_stask(const NetSTask*net) { - os << setw(indent_) << "" << net->name(); + OS << setw(indent_) << "" << net->name(); if (net->nparms() > 0) { - os << "("; - vtask_parm(os, net->parm(0)); + OS << "("; + vtask_parm(OS, net->parm(0)); for (unsigned idx = 1 ; idx < net->nparms() ; idx += 1) { - os << ", "; - vtask_parm(os, net->parm(idx)); + OS << ", "; + vtask_parm(OS, net->parm(idx)); } - os << ")"; + OS << ")"; } - os << ";" << endl; + OS << ";" << endl; } @@ -229,9 +249,9 @@ void target_verilog::proc_stask(ostream&os, const NetSTask*net) * All done with the design. Flush any output that I've been holding * off, and write the footers for the target. */ -void target_verilog::end_design(ostream&os, const Design*) +void target_verilog::end_design(const Design*) { - os << "endmodule" << endl; + OS << "endmodule" << endl; } static target_verilog tgt_verilog_obj; @@ -243,6 +263,9 @@ const struct target tgt_verilog = { /* * $Log: t-verilog.cc,v $ + * Revision 1.12 2000/08/08 01:50:42 steve + * target methods need not take a file stream. + * * Revision 1.11 2000/07/29 16:21:08 steve * Report code generation errors through proc_delay. * diff --git a/t-vvm.cc b/t-vvm.cc index 5f8abef36..5be4d5ebd 100644 --- a/t-vvm.cc +++ b/t-vvm.cc @@ -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.165 2000/08/02 00:57:02 steve Exp $" +#ident "$Id: t-vvm.cc,v 1.166 2000/08/08 01:50:42 steve Exp $" #endif # include @@ -145,56 +145,56 @@ class target_vvm : public target_t { ~target_vvm(); virtual void start_design(ostream&os, const Design*); - virtual void scope(ostream&os, const NetScope*); - virtual void event(ostream&os, const NetEvent*); - virtual void signal(ostream&os, const NetNet*); - virtual void memory(ostream&os, const NetMemory*); - virtual void task_def(ostream&os, const NetTaskDef*); - virtual void func_def(ostream&os, const NetFuncDef*); + virtual void scope(const NetScope*); + virtual void event(const NetEvent*); + virtual void signal(const NetNet*); + virtual void memory(const NetMemory*); + virtual void task_def(const NetTaskDef*); + virtual void func_def(const NetFuncDef*); - virtual void lpm_add_sub(ostream&os, const NetAddSub*); - virtual void lpm_clshift(ostream&os, const NetCLShift*); - virtual void lpm_compare(ostream&os, const NetCompare*); - virtual void lpm_divide(ostream&os, const NetDivide*); - virtual void lpm_ff(ostream&os, const NetFF*); - virtual void lpm_mult(ostream&os, const NetMult*); - virtual void lpm_mux(ostream&os, const NetMux*); - virtual void lpm_ram_dq(ostream&os, const NetRamDq*); + virtual void lpm_add_sub(const NetAddSub*); + virtual void lpm_clshift(const NetCLShift*); + virtual void lpm_compare(const NetCompare*); + virtual void lpm_divide(const NetDivide*); + virtual void lpm_ff(const NetFF*); + virtual void lpm_mult(const NetMult*); + virtual void lpm_mux(const NetMux*); + virtual void lpm_ram_dq(const NetRamDq*); - virtual void logic(ostream&os, const NetLogic*); - virtual void bufz(ostream&os, const NetBUFZ*); - virtual void udp(ostream&os, const NetUDP*); - virtual void udp_comb(ostream&os, const NetUDP_COMB*); + virtual void logic(const NetLogic*); + virtual void bufz(const NetBUFZ*); + virtual void udp(const NetUDP*); + virtual void udp_comb(const NetUDP_COMB*); void udp_sequ_(ostream&os, const NetUDP*); - virtual void net_assign_nb(ostream&os, const NetAssignNB*); - virtual void net_case_cmp(ostream&os, const NetCaseCmp*); - virtual bool net_cassign(ostream&os, const NetCAssign*); - virtual void net_const(ostream&os, const NetConst*); - virtual bool net_force(ostream&os, const NetForce*); - virtual void net_probe(ostream&os, const NetEvProbe*); - virtual bool process(ostream&os, const NetProcTop*); - virtual void proc_assign(ostream&os, const NetAssign*); - virtual void proc_assign_mem(ostream&os, const NetAssignMem*); - virtual void proc_assign_nb(ostream&os, const NetAssignNB*); - virtual void proc_assign_mem_nb(ostream&os, const NetAssignMemNB*); - virtual bool proc_block(ostream&os, const NetBlock*); - virtual void proc_case(ostream&os, const NetCase*net); + virtual void net_assign_nb(const NetAssignNB*); + virtual void net_case_cmp(const NetCaseCmp*); + virtual bool net_cassign(const NetCAssign*); + virtual void net_const(const NetConst*); + virtual bool net_force(const NetForce*); + virtual void net_probe(const NetEvProbe*); + virtual bool process(const NetProcTop*); + virtual void proc_assign(const NetAssign*); + virtual void proc_assign_mem(const NetAssignMem*); + virtual void proc_assign_nb(const NetAssignNB*); + virtual void proc_assign_mem_nb(const NetAssignMemNB*); + virtual bool proc_block(const NetBlock*); + virtual void proc_case(const NetCase*net); void proc_case_fun(ostream&os, const NetCase*net); - virtual bool proc_cassign(ostream&os, const NetCAssign*); - virtual void proc_condit(ostream&os, const NetCondit*); + virtual bool proc_cassign(const NetCAssign*); + virtual void proc_condit(const NetCondit*); void proc_condit_fun(ostream&os, const NetCondit*); - virtual bool proc_deassign(ostream&os, const NetDeassign*); - virtual bool proc_force(ostream&os, const NetForce*); - virtual void proc_forever(ostream&os, const NetForever*); - virtual bool proc_release(ostream&os, const NetRelease*); - virtual void proc_repeat(ostream&os, const NetRepeat*); - virtual void proc_stask(ostream&os, const NetSTask*); - virtual bool proc_trigger(ostream&os, const NetEvTrig*); - virtual void proc_utask(ostream&os, const NetUTask*); - virtual bool proc_wait(ostream&os, const NetEvWait*); - virtual void proc_while(ostream&os, const NetWhile*); - virtual bool proc_delay(ostream&os, const NetPDelay*); - virtual void end_design(ostream&os, const Design*); + virtual bool proc_deassign(const NetDeassign*); + virtual bool proc_delay(const NetPDelay*); + virtual bool proc_force(const NetForce*); + virtual void proc_forever(const NetForever*); + virtual bool proc_release(const NetRelease*); + virtual void proc_repeat(const NetRepeat*); + virtual void proc_stask(const NetSTask*); + virtual bool proc_trigger(const NetEvTrig*); + virtual void proc_utask( const NetUTask*); + virtual bool proc_wait( const NetEvWait*); + virtual void proc_while(const NetWhile*); + virtual void end_design(const Design*); void start_process(ostream&os, const NetProcTop*); void end_process(ostream&os, const NetProcTop*); @@ -202,6 +202,9 @@ class target_vvm : public target_t { NumberTable bits_table; + ostream*out_; +# define OS (*out_) + // Method definitions go into this file. char*defn_name; ofstream defn; @@ -892,6 +895,8 @@ static string emit_parm_rval(target_vvm*tgt, const NetExpr*expr) void target_vvm::start_design(ostream&os, const Design*mod) { + out_ = &os; + defn_name = tempnam(0, "ivldf"); defn.open(defn_name, ios::in | ios::out | ios::trunc); @@ -928,11 +933,11 @@ void target_vvm::start_design(ostream&os, const Design*mod) start_code << "{" << endl; } -void target_vvm::scope(ostream&os, const NetScope*scope) +void target_vvm::scope(const NetScope*scope) { string hname = mangle(scope->name()) + "_scope"; - os << "// SCOPE: " << scope->name() << endl; - os << "static struct __vpiScope " << hname << ";" << endl; + OS << "// SCOPE: " << scope->name() << endl; + OS << "static struct __vpiScope " << hname << ";" << endl; string type_code; switch (scope->type()) { @@ -963,96 +968,96 @@ void target_vvm::scope(ostream&os, const NetScope*scope) } } -void target_vvm::event(ostream&os, const NetEvent*event) +void target_vvm::event(const NetEvent*event) { string mname = mangle(event->full_name()); - os << "static vvm_sync " << mname << "; // " + OS << "static vvm_sync " << mname << "; // " << event->get_line() << ": event " << event->full_name() << endl; } -void target_vvm::end_design(ostream&os, const Design*mod) +void target_vvm::end_design(const Design*mod) { if (string_counter > 0) - os << "static struct __vpiStringConst string_table[" << + OS << "static struct __vpiStringConst string_table[" << string_counter+1 << "];" << endl; if (number_counter > 0) - os << "static struct __vpiNumberConst number_table[" << + OS << "static struct __vpiNumberConst number_table[" << number_counter+1 << "];" << endl; if (nexus_wire_counter > 0) - os << "static vvm_nexus nexus_wire_table[" << + OS << "static vvm_nexus nexus_wire_table[" << nexus_wire_counter << "];" << endl; if (signal_bit_counter > 0) - os << "static vpip_bit_t signal_bit_table[" << + OS << "static vpip_bit_t signal_bit_table[" << signal_bit_counter << "];" << endl; if (bits_table.count() > 0) { - os << "static vpip_bit_t const_bits_table[" << bits_table.count() + OS << "static vpip_bit_t const_bits_table[" << bits_table.count() << "] = {"; for (unsigned idx = 0 ; idx < bits_table.count() ; idx += 1) { - if (idx%16 == 0) os << endl; + if (idx%16 == 0) OS << endl; switch (bits_table.bit(idx)) { case verinum::V0: - os << " St0,"; + OS << " St0,"; break; case verinum::V1: - os << " St1,"; + OS << " St1,"; break; case verinum::Vx: - os << " StX,"; + OS << " StX,"; break; case verinum::Vz: - os << " HiZ,"; + OS << " HiZ,"; break; default: - os << " ,"; + OS << " ,"; break; } } - os << endl << "};" << endl; + OS << endl << "};" << endl; } defn.close(); - os << "// **** Definition code" << endl; + OS << "// **** Definition code" << endl; { ifstream rdefn (defn_name); - os << rdefn.rdbuf(); + OS << rdefn.rdbuf(); } unlink(defn_name); free(defn_name); defn_name = 0; - os << "// **** end definition code" << endl; + OS << "// **** end definition code" << endl; - os << "// **** init_code" << endl; + OS << "// **** init_code" << endl; init_code << "}" << endl; init_code.close(); { ifstream rinit_code (init_code_name); - os << rinit_code.rdbuf(); + OS << rinit_code.rdbuf(); } unlink(init_code_name); free(init_code_name); init_code_name = 0; - os << "// **** end init_code" << endl; + OS << "// **** end init_code" << endl; - os << "// **** start_code" << endl; + OS << "// **** start_code" << endl; start_code << "}" << endl; start_code.close(); { ifstream rstart_code (start_code_name); - os << rstart_code.rdbuf(); + OS << rstart_code.rdbuf(); } unlink(start_code_name); free(start_code_name); start_code_name = 0; - os << "// **** end start_code" << endl; + OS << "// **** end start_code" << endl; - os << "main()" << endl << "{" << endl; + OS << "main()" << endl << "{" << endl; string vpi_module_path = mod->get_flag("VPI_MODULE_PATH"); if (vpi_module_path.length() > 0) - os << " vvm_set_module_path(\"" << vpi_module_path << + OS << " vvm_set_module_path(\"" << vpi_module_path << "\");" << endl; string vpi_module_list = mod->get_flag("VPI_MODULE_LIST"); @@ -1066,23 +1071,23 @@ void target_vvm::end_design(ostream&os, const Design*mod) name = vpi_module_list; vpi_module_list = ""; } - os << " vvm_load_vpi_module(\"" << name << ".vpi\");" << endl; + OS << " vvm_load_vpi_module(\"" << name << ".vpi\");" << endl; } - os << " design_init();" << endl; - os << " design_start();" << endl; - os << " vpip_simulation_run();" << endl; - os << "}" << endl; + OS << " design_init();" << endl; + OS << " design_start();" << endl; + OS << " vpip_simulation_run();" << endl; + OS << "}" << endl; } -bool target_vvm::process(ostream&os, const NetProcTop*top) +bool target_vvm::process(const NetProcTop*top) { - start_process(os, top); - bool rc = top->statement()->emit_proc(os, this); - end_process(os, top); + start_process(OS, top); + bool rc = top->statement()->emit_proc(this); + end_process(OS, top); return rc; } -void target_vvm::signal(ostream&os, const NetNet*sig) +void target_vvm::signal(const NetNet*sig) { string net_name = mangle(sig->name()); @@ -1125,7 +1130,7 @@ void target_vvm::signal(ostream&os, const NetNet*sig) } } - os << "static vvm_signal_t " << net_name << ";" << endl; + OS << "static vvm_signal_t " << net_name << ";" << endl; init_code << " vpip_make_reg(&" << net_name << ", \"" << sig->name() << "\", signal_bit_table+" @@ -1169,10 +1174,10 @@ void target_vvm::signal(ostream&os, const NetNet*sig) } } -void target_vvm::memory(ostream&os, const NetMemory*mem) +void target_vvm::memory(const NetMemory*mem) { const string mname = mangle(mem->name()); - os << "static vvm_memory_t<" << mem->width() << ", " << + OS << "static vvm_memory_t<" << mem->width() << ", " << mem->count() << "> " << mname << ";" " /* " << mem->name() << " */" << endl; init_code << " vpip_make_memory(&" << mname << ", \"" << @@ -1180,18 +1185,18 @@ void target_vvm::memory(ostream&os, const NetMemory*mem) mem->count() << ");" << endl; } -void target_vvm::task_def(ostream&os, const NetTaskDef*def) +void target_vvm::task_def(const NetTaskDef*def) { thread_step_ = 0; const string name = mangle(def->name()); const string save_thread_class = thread_class_; thread_class_ = name; - os << "static bool " << name << "_step_0_(vvm_thread*thr);" << endl; + OS << "static bool " << name << "_step_0_(vvm_thread*thr);" << endl; defn << "static bool " << name << "_step_0_(vvm_thread*thr) {" << endl; - def->proc()->emit_proc(os, this); + def->proc()->emit_proc(this); defn << " thr->back_ -> thread_yield();" << endl; defn << " return false;" << endl; @@ -1208,7 +1213,7 @@ void target_vvm::task_def(ostream&os, const NetTaskDef*def) * writes the result) then the caller copies the result out of the * magic result register. */ -void target_vvm::func_def(ostream&os, const NetFuncDef*def) +void target_vvm::func_def(const NetFuncDef*def) { thread_step_ = 0; const string name = mangle(def->name()); @@ -1218,13 +1223,13 @@ void target_vvm::func_def(ostream&os, const NetFuncDef*def) assert(! function_def_flag_); function_def_flag_ = true; - os << "// Function " << def->name() << endl; - os << "static void " << name << "();" << endl; + OS << "// Function " << def->name() << endl; + OS << "static void " << name << "();" << endl; defn << "// Function " << def->name() << endl; defn << "static void " << name << "()" << endl; defn << "{" << endl; - def->proc()->emit_proc(os, this); + def->proc()->emit_proc(this); defn << "}" << endl; assert(function_def_flag_); @@ -1299,9 +1304,9 @@ void target_vvm::emit_gate_outputfun_(const NetNode*gate, unsigned gpin) assert(0); } -void target_vvm::lpm_add_sub(ostream&os, const NetAddSub*gate) +void target_vvm::lpm_add_sub(const NetAddSub*gate) { - os << "static vvm_add_sub " << + OS << "static vvm_add_sub " << mangle(gate->name()) << "(" << gate->width() << ");" << endl; /* Connect the DataA inputs. */ @@ -1369,11 +1374,11 @@ void target_vvm::lpm_add_sub(ostream&os, const NetAddSub*gate) start_code << " " << mangle(gate->name()) << ".start();" << endl; } -void target_vvm::lpm_clshift(ostream&os, const NetCLShift*gate) +void target_vvm::lpm_clshift(const NetCLShift*gate) { string mname = mangle(gate->name()); - os << "static vvm_clshift " << mname << "(" << + OS << "static vvm_clshift " << mname << "(" << gate->width() << "," << gate->width_dist() << ");" << endl; @@ -1417,11 +1422,11 @@ void target_vvm::lpm_clshift(ostream&os, const NetCLShift*gate) } } -void target_vvm::lpm_compare(ostream&os, const NetCompare*gate) +void target_vvm::lpm_compare(const NetCompare*gate) { string mname = mangle(gate->name()); - os << "static vvm_compare " << mname << "(" << gate->width() << + OS << "static vvm_compare " << mname << "(" << gate->width() << ");" << endl; /* Connect DataA inputs... */ @@ -1478,11 +1483,11 @@ void target_vvm::lpm_compare(ostream&os, const NetCompare*gate) } } -void target_vvm::lpm_divide(ostream&os, const NetDivide*mul) +void target_vvm::lpm_divide(const NetDivide*mul) { string mname = mangle(mul->name()); - os << "static vvm_idiv " << mname << "(" << mul->width_r() << + OS << "static vvm_idiv " << mname << "(" << mul->width_r() << "," << mul->width_a() << "," << mul->width_b() << ");" << endl; @@ -1516,13 +1521,13 @@ void target_vvm::lpm_divide(ostream&os, const NetDivide*mul) } } -void target_vvm::lpm_ff(ostream&os, const NetFF*gate) +void target_vvm::lpm_ff( const NetFF*gate) { string nexus; unsigned ncode; string mname = mangle(gate->name()); - os << "static vvm_ff " << mname << "(" << gate->width() << ");" << endl; + OS << "static vvm_ff " << mname << "(" << gate->width() << ");" << endl; /* Connect the clock input... */ @@ -1555,11 +1560,11 @@ void target_vvm::lpm_ff(ostream&os, const NetFF*gate) } } -void target_vvm::lpm_mult(ostream&os, const NetMult*mul) +void target_vvm::lpm_mult(const NetMult*mul) { string mname = mangle(mul->name()); - os << "static vvm_mult " << mname << "(" << mul->width_r() << + OS << "static vvm_mult " << mname << "(" << mul->width_r() << "," << mul->width_a() << "," << mul->width_b() << "," << mul->width_s() << ");" << endl; @@ -1594,11 +1599,11 @@ void target_vvm::lpm_mult(ostream&os, const NetMult*mul) } } -void target_vvm::lpm_mux(ostream&os, const NetMux*mux) +void target_vvm::lpm_mux(const NetMux*mux) { string mname = mangle(mux->name()); - os << "static vvm_mux " << mname << "(" << mux->width() << "," + OS << "static vvm_mux " << mname << "(" << mux->width() << "," << mux->size() << "," << mux->sel_width() << ");" << endl; /* Connect the select inputs... */ @@ -1634,11 +1639,11 @@ void target_vvm::lpm_mux(ostream&os, const NetMux*mux) } } -void target_vvm::lpm_ram_dq(ostream&os, const NetRamDq*ram) +void target_vvm::lpm_ram_dq(const NetRamDq*ram) { string mname = mangle(ram->name()); - os << "static vvm_ram_dq<" << ram->width() << "," << + OS << "static vvm_ram_dq<" << ram->width() << "," << ram->awidth() << "," << ram->size() << "> " << mname << "(&" << mangle(ram->mem()->name()) << ");" << endl; @@ -1700,7 +1705,7 @@ void target_vvm::lpm_ram_dq(ostream&os, const NetRamDq*ram) } -void target_vvm::logic(ostream&os, const NetLogic*gate) +void target_vvm::logic(const NetLogic*gate) { const string mname = mangle(gate->name()); @@ -1711,46 +1716,46 @@ void target_vvm::logic(ostream&os, const NetLogic*gate) switch (gate->type()) { case NetLogic::AND: if ((gate->pin_count()-1) == 2) - os << "static vvm_and2 "; + OS << "static vvm_and2 "; else - os << "static vvm_and" << "<" << gate->pin_count()-1 << "> "; + OS << "static vvm_and" << "<" << gate->pin_count()-1 << "> "; break; case NetLogic::BUF: - os << "static vvm_buf "; + OS << "static vvm_buf "; break; case NetLogic::BUFIF0: - os << "static vvm_bufif0 "; + OS << "static vvm_bufif0 "; break; case NetLogic::BUFIF1: - os << "static vvm_bufif1 "; + OS << "static vvm_bufif1 "; break; case NetLogic::NAND: - os << "static vvm_nand" << "<" << gate->pin_count()-1 << "> "; + OS << "static vvm_nand" << "<" << gate->pin_count()-1 << "> "; break; case NetLogic::NOR: if ((gate->pin_count()-1) == 2) - os << "static vvm_nor2 "; + OS << "static vvm_nor2 "; else - os << "static vvm_nor" << "<" << gate->pin_count()-1 << "> "; + OS << "static vvm_nor" << "<" << gate->pin_count()-1 << "> "; break; case NetLogic::NOT: - os << "static vvm_not "; + OS << "static vvm_not "; break; case NetLogic::OR: - os << "static vvm_or" << "<" << gate->pin_count()-1 << "> "; + OS << "static vvm_or" << "<" << gate->pin_count()-1 << "> "; break; case NetLogic::XNOR: - os << "static vvm_xnor" << "<" << gate->pin_count()-1 << "> "; + OS << "static vvm_xnor" << "<" << gate->pin_count()-1 << "> "; break; case NetLogic::XOR: - os << "static vvm_xor" << "<" << gate->pin_count()-1 << "> "; + OS << "static vvm_xor" << "<" << gate->pin_count()-1 << "> "; break; default: - os << "#error \"internal ivl error:bad gate type for " << + OS << "#error \"internal ivl error:bad gate type for " << gate->name() << "\"" << endl; } - os << mname << " (" << gate->rise_time() << ");" << endl; + OS << mname << " (" << gate->rise_time() << ");" << endl; /* Write the code to invoke startup for this object. */ @@ -1800,13 +1805,13 @@ void target_vvm::logic(ostream&os, const NetLogic*gate) } } -void target_vvm::bufz(ostream&os, const NetBUFZ*gate) +void target_vvm::bufz(const NetBUFZ*gate) { string mname = mangle(gate->name()); string nexus; unsigned ncode; - os << "static vvm_bufz " << mname << ";" << endl; + OS << "static vvm_bufz " << mname << ";" << endl; nexus = gate->pin(0).nexus()->name(); ncode = nexus_wire_map[nexus]; @@ -1843,25 +1848,25 @@ void target_vvm::bufz(ostream&os, const NetBUFZ*gate) } -void target_vvm::udp_comb(ostream&os, const NetUDP_COMB*gate) +void target_vvm::udp_comb(const NetUDP_COMB*gate) { string mname = mangle(gate->name()); string nexus; unsigned ncode; - os << "static const char*" << mname << "_ctab =" << endl; + OS << "static const char*" << mname << "_ctab =" << endl; string inp; - char out; - for (bool rc = gate->first(inp, out) - ; rc ; rc = gate->next(inp,out)) { + char outc; + for (bool rc = gate->first(inp, outc) + ; rc ; rc = gate->next(inp,outc)) { - os << " \"" << inp << out << "\"" << endl; + OS << " \"" << inp << outc << "\"" << endl; } - os << " ;" << endl; + OS << " ;" << endl; - os << "static vvm_udp_comb " << mname << "(" + OS << "static vvm_udp_comb " << mname << "(" << (gate->pin_count()-1) << ", " << mname<<"_ctab);" << endl; /* Connect the output of the device... */ @@ -1897,10 +1902,10 @@ static string state_to_string(unsigned state, unsigned npins) return res; } -void target_vvm::udp(ostream&os, const NetUDP*gate) +void target_vvm::udp(const NetUDP*gate) { assert(gate->is_sequential()); - udp_sequ_(os, gate); + udp_sequ_(OS, gate); } void target_vvm::udp_sequ_(ostream&os, const NetUDP*gate) @@ -1961,18 +1966,18 @@ void target_vvm::udp_sequ_(ostream&os, const NetUDP*gate) } -void target_vvm::net_assign_nb(ostream&os, const NetAssignNB*net) +void target_vvm::net_assign_nb(const NetAssignNB*net) { } -void target_vvm::net_case_cmp(ostream&os, const NetCaseCmp*gate) +void target_vvm::net_case_cmp(const NetCaseCmp*gate) { string mname = mangle(gate->name()); string nexus; unsigned ncode; assert(gate->pin_count() == 3); - os << "static vvm_eeq " << mname << "(" << + OS << "static vvm_eeq " << mname << "(" << gate->rise_time() << ");" << endl; /* Connect the output pin */ @@ -2002,11 +2007,11 @@ void target_vvm::net_case_cmp(ostream&os, const NetCaseCmp*gate) * so similar. I'll be using different methods to tickle this device, * but it receives values the same as force. */ -bool target_vvm::net_cassign(ostream&os, const NetCAssign*dev) +bool target_vvm::net_cassign(const NetCAssign*dev) { string mname = mangle(dev->name()); - os << "static vvm_force " << mname << "(" << dev->pin_count() + OS << "static vvm_force " << mname << "(" << dev->pin_count() << ");" << endl; for (unsigned idx = 0 ; idx < dev->pin_count() ; idx += 1) { @@ -2026,11 +2031,11 @@ bool target_vvm::net_cassign(ostream&os, const NetCAssign*dev) * has its input connected to nothing but is initialized to the * desired constant value. */ -void target_vvm::net_const(ostream&os, const NetConst*gate) +void target_vvm::net_const(const NetConst*gate) { const string mname = mangle(gate->name()); - os << "static vvm_nexus::drive_t " << mname + OS << "static vvm_nexus::drive_t " << mname << "[" << gate->pin_count() << "];" << endl; for (unsigned idx = 0 ; idx < gate->pin_count() ; idx += 1) { @@ -2050,11 +2055,11 @@ void target_vvm::net_const(ostream&os, const NetConst*gate) } -bool target_vvm::net_force(ostream&os, const NetForce*dev) +bool target_vvm::net_force(const NetForce*dev) { string mname = mangle(dev->name()); - os << "static vvm_force " << mname << "(" << dev->pin_count() + OS << "static vvm_force " << mname << "(" << dev->pin_count() << ");" << endl; for (unsigned idx = 0 ; idx < dev->pin_count() ; idx += 1) { @@ -2068,7 +2073,7 @@ bool target_vvm::net_force(ostream&os, const NetForce*dev) return true; } -void target_vvm::net_probe(ostream&os, const NetEvProbe*net) +void target_vvm::net_probe(const NetEvProbe*net) { string mname = mangle(net->name()); string mevent = mangle(net->event()->full_name()); @@ -2076,19 +2081,19 @@ void target_vvm::net_probe(ostream&os, const NetEvProbe*net) switch (net->edge()) { case NetEvProbe::POSEDGE: assert(net->pin_count() == 1); - os << "static vvm_posedge " << mname + OS << "static vvm_posedge " << mname << "(&" << mevent << ");" << endl; break; case NetEvProbe::NEGEDGE: assert(net->pin_count() == 1); - os << "static vvm_negedge " << mname + OS << "static vvm_negedge " << mname << "(&" << mevent << ");" << endl; break; case NetEvProbe::ANYEDGE: - os << "static vvm_anyedge " << mname + OS << "static vvm_anyedge " << mname << "(&" << mevent << ", " << net->pin_count() << ");" << endl; break; } @@ -2135,7 +2140,7 @@ void target_vvm::start_process(ostream&os, const NetProcTop*proc) * a signal, but the assignment should generate code to go to all the * connected devices/events. */ -void target_vvm::proc_assign(ostream&os, const NetAssign*net) +void target_vvm::proc_assign(const NetAssign*net) { /* Detect the very special (and very common) case that the @@ -2281,7 +2286,7 @@ void target_vvm::proc_assign(ostream&os, const NetAssign*net) * expression to be evaluated (run-time) and the index used as the * location to store the value. */ -void target_vvm::proc_assign_mem(ostream&os, const NetAssignMem*amem) +void target_vvm::proc_assign_mem(const NetAssignMem*amem) { /* make a temporary to reference the index signal. */ string index = emit_proc_rval(this, amem->index()); @@ -2306,7 +2311,7 @@ void target_vvm::proc_assign_mem(ostream&os, const NetAssignMem*amem) } -void target_vvm::proc_assign_nb(ostream&os, const NetAssignNB*net) +void target_vvm::proc_assign_nb(const NetAssignNB*net) { string rval = emit_proc_rval(this, net->rval()); const unsigned long delay = net->rise_time(); @@ -2347,7 +2352,7 @@ void target_vvm::proc_assign_nb(ostream&os, const NetAssignNB*net) } } -void target_vvm::proc_assign_mem_nb(ostream&os, const NetAssignMemNB*amem) +void target_vvm::proc_assign_mem_nb(const NetAssignMemNB*amem) { /* make a temporary to reference the index signal. */ string index = emit_proc_rval(this, amem->index()); @@ -2368,10 +2373,10 @@ void target_vvm::proc_assign_mem_nb(ostream&os, const NetAssignMemNB*amem) ")) -> schedule();" << endl; } -bool target_vvm::proc_block(ostream&os, const NetBlock*net) +bool target_vvm::proc_block(const NetBlock*net) { if (net->type() == NetBlock::SEQU) { - net->emit_recurse(os, this); + net->emit_recurse(this); return true; } @@ -2385,7 +2390,7 @@ bool target_vvm::proc_block(ostream&os, const NetBlock*net) // Declare the exit step... - os << "static bool " << thread_class_ << "_step_" << exit_step + OS << "static bool " << thread_class_ << "_step_" << exit_step << "_(vvm_thread*thr);" << endl; @@ -2394,7 +2399,7 @@ bool target_vvm::proc_block(ostream&os, const NetBlock*net) for (cur = net->proc_first() ; cur ; cur = net->proc_next(cur)) { cnt += 1; - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << (exit_step+cnt) << "_(vvm_thread*thr);" << endl; } @@ -2428,7 +2433,7 @@ bool target_vvm::proc_block(ostream&os, const NetBlock*net) defn << "static bool " << thread_class_ << "_step_" << (exit_step+idx+1) << "_(vvm_thread*thr) {" << endl; - cur->emit_proc(os, this); + cur->emit_proc(this); defn << " thr->back_->ncallee_ -= 1;" << endl; defn << " if (thr->back_->ncallee_ == 0)" << endl; @@ -2463,10 +2468,10 @@ bool target_vvm::proc_block(ostream&os, const NetBlock*net) * each branch to Z when they finish. X, Y and Z all generate at least * one step. */ -void target_vvm::proc_case(ostream&os, const NetCase*net) +void target_vvm::proc_case(const NetCase*net) { if (function_def_flag_) { - proc_case_fun(os, net); + proc_case_fun(OS, net); return; } @@ -2545,13 +2550,13 @@ void target_vvm::proc_case(ostream&os, const NetCase*net) step_num += 1; - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << step_num << "_(vvm_thread*thr);" << endl; defn << "static bool " << thread_class_ << "_step_" << step_num << "_(vvm_thread*thr) {" << endl; if (net->stat(idx)) - net->stat(idx)->emit_proc(os, this); + net->stat(idx)->emit_proc(this); defn << " thr->step_ = &" << thread_class_ << "_step_" << exit_step << "_;" << endl; defn << " return true;" << endl; @@ -2562,13 +2567,13 @@ void target_vvm::proc_case(ostream&os, const NetCase*net) if (default_idx < net->nitems()) { step_num += 1; - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << step_num << "_(vvm_thread*thr);" << endl; defn << "static bool " << thread_class_ << "_step_" << step_num << "_(vvm_thread*thr) {" << endl; if (net->stat(default_idx)) - net->stat(default_idx)->emit_proc(os, this); + net->stat(default_idx)->emit_proc(this); defn << " thr->step_ = &" << thread_class_ << "_step_" << exit_step << "_;" << endl; defn << " return true;" << endl; @@ -2577,7 +2582,7 @@ void target_vvm::proc_case(ostream&os, const NetCase*net) /* Finally, start the exit step. */ - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << exit_step << "_(vvm_thread*thr);" << endl; defn << "static bool " << thread_class_ << "_step_" @@ -2626,12 +2631,12 @@ void target_vvm::proc_case_fun(ostream&os, const NetCase*net) defn << " if (B_IS1(" << test_func << "(" << guard << "," << expr << "))) {" << endl; if (net->stat(idx)) - net->stat(idx)->emit_proc(os, this); + net->stat(idx)->emit_proc(this); defn << " break; }" << endl; } if ((default_idx < net->nitems()) && net->stat(default_idx)) { - net->stat(default_idx)->emit_proc(os, this); + net->stat(default_idx)->emit_proc(this); } defn << " /* " << net->get_line() << ": end case (" << @@ -2639,7 +2644,7 @@ void target_vvm::proc_case_fun(ostream&os, const NetCase*net) defn << " } while(0);" << endl; } -bool target_vvm::proc_cassign(ostream&os, const NetCAssign*dev) +bool target_vvm::proc_cassign(const NetCAssign*dev) { const string mname = mangle(dev->name()); @@ -2654,10 +2659,10 @@ bool target_vvm::proc_cassign(ostream&os, const NetCAssign*dev) return true; } -void target_vvm::proc_condit(ostream&os, const NetCondit*net) +void target_vvm::proc_condit(const NetCondit*net) { if (function_def_flag_) { - proc_condit_fun(os, net); + proc_condit_fun(OS, net); return; } @@ -2669,13 +2674,13 @@ void target_vvm::proc_condit(ostream&os, const NetCondit*net) /* Declare new steps that I am going to create. */ - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << if_step << "_(vvm_thread*thr);" << endl; - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << else_step << "_(vvm_thread*thr);" << endl; - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << out_step << "_(vvm_thread*thr);" << endl; defn << " if (B_IS1(" << expr << "[0]))" << endl; @@ -2689,7 +2694,7 @@ void target_vvm::proc_condit(ostream&os, const NetCondit*net) defn << "static bool " << thread_class_ << "_step_" << if_step << "_(vvm_thread*thr) {" << endl; - net->emit_recurse_if(os, this); + net->emit_recurse_if(this); defn << " thr->step_ = &" << thread_class_ << "_step_" << out_step << "_;" << endl; defn << " return true;" << endl; @@ -2697,7 +2702,7 @@ void target_vvm::proc_condit(ostream&os, const NetCondit*net) defn << "static bool " << thread_class_ << "_step_" << else_step << "_(vvm_thread*thr) {" << endl; - net->emit_recurse_else(os, this); + net->emit_recurse_else(this); defn << " thr->step_ = &" << thread_class_ << "_step_" << out_step << "_;" << endl; defn << " return true;" << endl; @@ -2714,13 +2719,13 @@ void target_vvm::proc_condit_fun(ostream&os, const NetCondit*net) defn << " // " << net->get_line() << ": conditional (if-else)" << endl; defn << " if (B_IS1(" << expr << "[0])) {" << endl; - net->emit_recurse_if(os, this); + net->emit_recurse_if(this); defn << " } else {" << endl; - net->emit_recurse_else(os, this); + net->emit_recurse_else(this); defn << " }" << endl; } -bool target_vvm::proc_deassign(ostream&os, const NetDeassign*dev) +bool target_vvm::proc_deassign(const NetDeassign*dev) { const NetNet*lval = dev->lval(); for (unsigned idx = 0 ; idx < lval->pin_count() ; idx += 1) { @@ -2734,7 +2739,7 @@ bool target_vvm::proc_deassign(ostream&os, const NetDeassign*dev) return true; } -bool target_vvm::proc_force(ostream&os, const NetForce*dev) +bool target_vvm::proc_force(const NetForce*dev) { const string mname = mangle(dev->name()); @@ -2756,7 +2761,7 @@ bool target_vvm::proc_force(ostream&os, const NetForce*dev) * loop, elaborating the contents of the loop, then returning to the * top step after the loop contents. */ -void target_vvm::proc_forever(ostream&os, const NetForever*net) +void target_vvm::proc_forever(const NetForever*net) { unsigned top_step = ++thread_step_; unsigned out_step = ++thread_step_; @@ -2766,13 +2771,13 @@ void target_vvm::proc_forever(ostream&os, const NetForever*net) defn << " return true;" << endl; defn << "}" << endl; - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << top_step << "_(vvm_thread*thr);" << endl; defn << "static bool " << thread_class_ << "_step_" << top_step << "_(vvm_thread*thr) {" << endl; - net->emit_recurse(os, this); + net->emit_recurse(this); defn << " thr->step_ = &" << thread_class_ << "_step_" << top_step << "_;" << endl; defn << " return true;" << endl; @@ -2781,14 +2786,14 @@ void target_vvm::proc_forever(ostream&os, const NetForever*net) /* Generate a loop out step to catch unreachable stuff afer the loop. */ - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << out_step << "_(vvm_thread*thr);" << endl; defn << "static bool " << thread_class_ << "_step_" << out_step << "_(vvm_thread*thr) {" << endl; } -bool target_vvm::proc_release(ostream&os, const NetRelease*dev) +bool target_vvm::proc_release(const NetRelease*dev) { const NetNet*lval = dev->lval(); for (unsigned idx = 0 ; idx < lval->pin_count() ; idx += 1) { @@ -2802,7 +2807,7 @@ bool target_vvm::proc_release(ostream&os, const NetRelease*dev) return true; } -void target_vvm::proc_repeat(ostream&os, const NetRepeat*net) +void target_vvm::proc_repeat( const NetRepeat*net) { unsigned top_step = ++thread_step_; unsigned out_step = ++thread_step_; @@ -2822,15 +2827,15 @@ void target_vvm::proc_repeat(ostream&os, const NetRepeat*net) } /* Declare a variable to use as a loop index. */ - os << "static unsigned " << thread_class_ << "_step_" + OS << "static unsigned " << thread_class_ << "_step_" << top_step << "_idx_;" << endl; /* Declare the top step. */ - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << top_step << "_(vvm_thread*thr);" << endl; /* Declare the exit step. */ - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << out_step << "_(vvm_thread*thr);" << endl; @@ -2853,7 +2858,7 @@ void target_vvm::proc_repeat(ostream&os, const NetRepeat*net) defn << " " << thread_class_ << "_step_" << top_step << "_idx_ -= 1;" << endl; - net->emit_recurse(os,this); + net->emit_recurse(this); defn << " thr->step_ = &" << thread_class_ << "_step_" << top_step << "_;" << endl; @@ -2870,7 +2875,7 @@ void target_vvm::proc_repeat(ostream&os, const NetRepeat*net) * task and that I need to generate an external call. Calls to user * defined tasks are handled elsewhere. */ -void target_vvm::proc_stask(ostream&os, const NetSTask*net) +void target_vvm::proc_stask(const NetSTask*net) { /* Handle the special case of a system task without any parameters. we don't need a parameter array for this. */ @@ -2904,7 +2909,7 @@ void target_vvm::proc_stask(ostream&os, const NetSTask*net) defn << " if (vpip_finished()) return false;" << endl; } -bool target_vvm::proc_trigger(ostream&os, const NetEvTrig*trig) +bool target_vvm::proc_trigger(const NetEvTrig*trig) { const NetEvent*ev = trig->event(); assert(ev); @@ -2917,12 +2922,12 @@ bool target_vvm::proc_trigger(ostream&os, const NetEvTrig*trig) return true; } -void target_vvm::proc_utask(ostream&os, const NetUTask*net) +void target_vvm::proc_utask(const NetUTask*net) { unsigned out_step = ++thread_step_; const string name = mangle(net->name()); - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << out_step << "_(vvm_thread*thr);" << endl; defn << " assert(thr->callee_ == 0);" << endl; @@ -2941,7 +2946,7 @@ void target_vvm::proc_utask(ostream&os, const NetUTask*net) defn << " thr->callee_ = 0;" << endl; } -bool target_vvm::proc_wait(ostream&os, const NetEvWait*wait) +bool target_vvm::proc_wait(const NetEvWait*wait) { unsigned out_step = ++thread_step_; @@ -2962,7 +2967,7 @@ bool target_vvm::proc_wait(ostream&os, const NetEvWait*wait) source vvm_sync objects. Then, wait on the selector object instead. */ unsigned id = selector_counter++; - os << "static vvm_sync selector_" << id << ";" << endl; + OS << "static vvm_sync selector_" << id << ";" << endl; for (unsigned idx = 0 ; idx < wait->nevents() ; idx+= 1) { const NetEvent*ev = wait->event(idx); @@ -2981,13 +2986,13 @@ bool target_vvm::proc_wait(ostream&os, const NetEvWait*wait) defn << " return false;" << endl; defn << "}" << endl; - os << "static bool " << thread_class_ << "_step_" << out_step + OS << "static bool " << thread_class_ << "_step_" << out_step << "_(vvm_thread*thr);" << endl; defn << "bool " << thread_class_ << "_step_" << out_step << "_(vvm_thread*thr) {" << endl; - return wait->emit_recurse(os, this); + return wait->emit_recurse(this); } /* @@ -3003,15 +3008,15 @@ bool target_vvm::proc_wait(ostream&os, const NetEvWait*wait) * * out_step: */ -void target_vvm::proc_while(ostream&os, const NetWhile*net) +void target_vvm::proc_while(const NetWhile*net) { unsigned head_step = ++thread_step_; unsigned out_step = ++thread_step_; - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << head_step << "_(vvm_thread*thr);" << endl; - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << out_step << "_(vvm_thread*thr);" << endl; defn << " thr->step_ = &" << thread_class_ << "_step_" @@ -3034,7 +3039,7 @@ void target_vvm::proc_while(ostream&os, const NetWhile*net) defn << " return true;" << endl; defn << " }" << endl; - net->emit_proc_recurse(os, this); + net->emit_proc_recurse(this); defn << "// " << net->expr()->get_line() << ": end of while loop." << endl; @@ -3053,7 +3058,7 @@ void target_vvm::proc_while(ostream&os, const NetWhile*net) * is an expression expresion, evaluate it at run time and use the * unsigned interpretation of it as the actual delay. */ -bool target_vvm::proc_delay(ostream&os, const NetPDelay*proc) +bool target_vvm::proc_delay(const NetPDelay*proc) { thread_step_ += 1; @@ -3075,13 +3080,13 @@ bool target_vvm::proc_delay(ostream&os, const NetPDelay*proc) defn << "}" << endl; } - os << "static bool " << thread_class_ << "_step_" + OS << "static bool " << thread_class_ << "_step_" << thread_step_ << "_(vvm_thread*thr);" << endl; defn << "static bool " << thread_class_ << "_step_" << thread_step_ << "_(vvm_thread*thr) {" << endl; - return proc->emit_proc_recurse(os, this); + return proc->emit_proc_recurse(this); } void target_vvm::end_process(ostream&os, const NetProcTop*proc) @@ -3107,6 +3112,9 @@ extern const struct target tgt_vvm = { }; /* * $Log: t-vvm.cc,v $ + * Revision 1.166 2000/08/08 01:50:42 steve + * target methods need not take a file stream. + * * Revision 1.165 2000/08/02 00:57:02 steve * tri01 support in vvm. * diff --git a/t-xnf.cc b/t-xnf.cc index 33e0d920c..3c50dfcac 100644 --- a/t-xnf.cc +++ b/t-xnf.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-xnf.cc,v 1.32 2000/07/14 06:12:58 steve Exp $" +#ident "$Id: t-xnf.cc,v 1.33 2000/08/08 01:50:42 steve Exp $" #endif /* XNF BACKEND @@ -95,23 +95,23 @@ class target_xnf : public target_t { public: void start_design(ostream&os, const Design*); - void end_design(ostream&os, const Design*); - void memory(ostream&os, const NetMemory*); - void signal(ostream&os, const NetNet*); + void end_design(const Design*); + void memory(const NetMemory*); + void signal(const NetNet*); - void lpm_add_sub(ostream&os, const NetAddSub*); - void lpm_compare(ostream&os, const NetCompare*); + void lpm_add_sub(const NetAddSub*); + void lpm_compare(const NetCompare*); void lpm_compare_eq_(ostream&os, const NetCompare*); void lpm_compare_ge_(ostream&os, const NetCompare*); void lpm_compare_le_(ostream&os, const NetCompare*); - void lpm_ff(ostream&os, const NetFF*); - void lpm_mux(ostream&os, const NetMux*); - void lpm_ram_dq(ostream&os, const NetRamDq*); + void lpm_ff(const NetFF*); + void lpm_mux(const NetMux*); + void lpm_ram_dq(const NetRamDq*); - void net_const(ostream&os, const NetConst*); - void logic(ostream&os, const NetLogic*); - void bufz(ostream&os, const NetBUFZ*); - void udp(ostream&os, const NetUDP*); + void net_const(const NetConst*); + void logic(const NetLogic*); + void bufz(const NetBUFZ*); + void udp(const NetUDP*); private: static string mangle(const string&); @@ -125,6 +125,8 @@ class target_xnf : public target_t { static void draw_carry(ostream&os, const NetAddSub*, unsigned idx, enum adder_type); + ostream*out_; +#define OS (*out_) ofstream ncf_; }; @@ -233,9 +235,9 @@ void target_xnf::start_design(ostream&os, const Design*des) } } -void target_xnf::end_design(ostream&os, const Design*) +void target_xnf::end_design(const Design*) { - os << "EOF" << endl; + OS << "EOF" << endl; ncf_.close(); } @@ -282,7 +284,7 @@ void scrape_pad_info(string str, char&dir, unsigned&num) * Memories are handled by the lpm_ram_dq method, so there is nothing * to do here. */ -void target_xnf::memory(ostream&, const NetMemory*) +void target_xnf::memory(const NetMemory*) { } @@ -297,7 +299,7 @@ void target_xnf::memory(ostream&, const NetMemory*) * descriptions, that enumerate the pins from most significant to * least significant. */ -void target_xnf::signal(ostream&os, const NetNet*net) +void target_xnf::signal(const NetNet*net) { /* Look for signals that are ports to the root module. If they @@ -316,11 +318,11 @@ void target_xnf::signal(ostream&os, const NetNet*net) string pname = mname.substr(mname.find('/')+1, mname.length()); if (net->pin_count() == 1) { - os << "SIG, " << mangle(net->name()) << ", PIN=" + OS << "SIG, " << mangle(net->name()) << ", PIN=" << pname << endl; } else for (unsigned idx = 0; idx < net->pin_count(); idx += 1) { - os << "SIG, " << mangle(net->name()) << "<" << idx + OS << "SIG, " << mangle(net->name()) << "<" << idx << ">, PIN=" << pname << idx << endl; } @@ -343,7 +345,7 @@ void target_xnf::signal(ostream&os, const NetNet*net) char dir; unsigned num; scrape_pad_info(pad, dir, num); - os << "EXT, " << mangle(net->name()) << ", " << dir + OS << "EXT, " << mangle(net->name()) << ", " << dir << ", " << num << endl; ncf_ << "# Assignment to pin " << num << " (DIR=" << dir << @@ -469,7 +471,7 @@ void target_xnf::draw_carry(ostream &os, const NetAddSub*gate, unsigned idx, * Application note XAPP013 * Xilinx Libraries Guide, Chapter 12 */ -void target_xnf::lpm_add_sub(ostream&os, const NetAddSub*gate) +void target_xnf::lpm_add_sub(const NetAddSub*gate) { unsigned width = gate->width(); @@ -477,13 +479,13 @@ void target_xnf::lpm_add_sub(ostream&os, const NetAddSub*gate) bits of the carry chain. Label this with the width instead of the bit position so that symbols don't clash. */ - draw_carry(os, gate, width+1, FORCE0); + draw_carry(OS, gate, width+1, FORCE0); /* Now make the 2 bit adders that chain from the cin initializer and up. Save the tail bits for later. */ for (unsigned idx = 0 ; idx < width-2 ; idx += 2) - draw_carry(os, gate, idx, DOUBLE); + draw_carry(OS, gate, idx, DOUBLE); /* Always have one or two tail bits. The situation gets a little tricky if we want the carry output, so handle that @@ -507,23 +509,23 @@ void target_xnf::lpm_add_sub(ostream&os, const NetAddSub*gate) if (gate->pin_Cout().is_linked()) { if (width%2 == 0) { - draw_carry(os, gate, width-2, DOUBLE); - draw_carry(os, gate, width, EXAMINE_CI); + draw_carry(OS, gate, width-2, DOUBLE); + draw_carry(OS, gate, width, EXAMINE_CI); } else { - draw_carry(os, gate, width-1, LOWER_W_CO); + draw_carry(OS, gate, width-1, LOWER_W_CO); } } else { if (width%2 == 0) - draw_carry(os, gate, width-2, LOWER); + draw_carry(OS, gate, width-2, LOWER); else - draw_carry(os, gate, width-1, LOWER); + draw_carry(OS, gate, width-1, LOWER); } /* Now draw all the single bit (plus carry in) adders from XOR gates. This puts the F and G units to use. */ for (unsigned idx = 0 ; idx < width ; idx += 1) - draw_xor(os, gate, idx); + draw_xor(OS, gate, idx); } @@ -532,20 +534,20 @@ void target_xnf::lpm_add_sub(ostream&os, const NetAddSub*gate) * comparator being implemented. So, here we dispatch to the correct * code generator. */ -void target_xnf::lpm_compare(ostream&os, const NetCompare*dev) +void target_xnf::lpm_compare(const NetCompare*dev) { if (dev->pin_AEB().is_linked()) { - lpm_compare_eq_(os, dev); + lpm_compare_eq_(OS, dev); return; } if (dev->pin_AGEB().is_linked()) { - lpm_compare_ge_(os, dev); + lpm_compare_ge_(OS, dev); return; } if (dev->pin_ALEB().is_linked()) { - lpm_compare_le_(os, dev); + lpm_compare_le_(OS, dev); return; } @@ -639,7 +641,7 @@ void target_xnf::lpm_compare_le_(ostream&os, const NetCompare*dev) cerr << "XXXX LE not supported yet" << endl; } -void target_xnf::lpm_ff(ostream&os, const NetFF*net) +void target_xnf::lpm_ff(const NetFF*net) { string type = net->attribute("LPM_FFType"); if (type == "") type = "DFF"; @@ -649,7 +651,7 @@ void target_xnf::lpm_ff(ostream&os, const NetFF*net) string lcaname = net->attribute("XNF-LCA"); if (lcaname != "") { - draw_sym_with_lcaname(os, lcaname, net); + draw_sym_with_lcaname(OS, lcaname, net); return; } @@ -665,30 +667,30 @@ void target_xnf::lpm_ff(ostream&os, const NetFF*net) verinum::V ival = link_get_ival(net->pin_Q(idx)); - os << "SYM, " << mangle(net->name()) << "<" << idx << ">, DFF, "; + OS << "SYM, " << mangle(net->name()) << "<" << idx << ">, DFF, "; switch (ival) { case verinum::V0: - os << "INIT=R, "; + OS << "INIT=R, "; break; case verinum::V1: - os << "INIT=S, "; + OS << "INIT=S, "; break; } - os << "LIBVER=2.0.0" << endl; - draw_pin(os, "Q", net->pin_Q(idx)); - draw_pin(os, "D", net->pin_Data(idx)); + OS << "LIBVER=2.0.0" << endl; + draw_pin(OS, "Q", net->pin_Q(idx)); + draw_pin(OS, "D", net->pin_Data(idx)); if (net->attribute("Clock:LPM_Polarity") == "INVERT") - draw_pin(os, "~C", net->pin_Clock()); + draw_pin(OS, "~C", net->pin_Clock()); else - draw_pin(os, "C", net->pin_Clock()); + draw_pin(OS, "C", net->pin_Clock()); if (count_outputs(net->pin_Enable()) > 0) - draw_pin(os, "CE", net->pin_Enable()); + draw_pin(OS, "CE", net->pin_Enable()); - os << "END" << endl; + OS << "END" << endl; } } @@ -699,51 +701,51 @@ void target_xnf::lpm_ff(ostream&os, const NetFF*net) * devices that have a single select input. These are typically * generated from ?: expressions. */ -void target_xnf::lpm_mux(ostream&os, const NetMux*net) +void target_xnf::lpm_mux(const NetMux*net) { assert(net->sel_width() == 1); assert(net->size() == 2); for (unsigned idx = 0 ; idx < net->width() ; idx += 1) { - os << "SYM, " << mangle(net->name()) << "<" << idx << ">," + OS << "SYM, " << mangle(net->name()) << "<" << idx << ">," << " EQN, EQN=(I0 * I2) + (~I0 * I1)" << endl; - draw_pin(os, "I0", net->pin_Sel(0)); - draw_pin(os, "I1", net->pin_Data(idx,0)); - draw_pin(os, "I2", net->pin_Data(idx,1)); - draw_pin(os, "O", net->pin_Result(idx)); + draw_pin(OS, "I0", net->pin_Sel(0)); + draw_pin(OS, "I1", net->pin_Data(idx,0)); + draw_pin(OS, "I2", net->pin_Data(idx,1)); + draw_pin(OS, "O", net->pin_Result(idx)); - os << "END" << endl; + OS << "END" << endl; } } -void target_xnf::lpm_ram_dq(ostream&os, const NetRamDq*ram) +void target_xnf::lpm_ram_dq(const NetRamDq*ram) { assert(ram->count_partners() == 1); const NetMemory*mem = ram->mem(); for (unsigned idx = 0 ; idx < ram->width() ; idx += 1) { - os << "SYM, " << mangle(ram->name()) + OS << "SYM, " << mangle(ram->name()) << "<" << idx << ">, RAMS" << endl; - draw_pin(os, "O", ram->pin_Q(idx)); - draw_pin(os, "D", ram->pin_Data(idx)); - draw_pin(os, "WE", ram->pin_WE()); - draw_pin(os, "WCLK", ram->pin_InClock()); + draw_pin(OS, "O", ram->pin_Q(idx)); + draw_pin(OS, "D", ram->pin_Data(idx)); + draw_pin(OS, "WE", ram->pin_WE()); + draw_pin(OS, "WCLK", ram->pin_InClock()); for (unsigned adr = 0 ; adr < ram->awidth() ; adr += 1) { strstream tmp; tmp << "A" << adr << ends; - draw_pin(os, tmp.str(), ram->pin_Address(adr)); + draw_pin(OS, tmp.str(), ram->pin_Address(adr)); } - os << "END" << endl; + OS << "END" << endl; } } -void target_xnf::net_const(ostream&os, const NetConst*c) +void target_xnf::net_const(const NetConst*c) { for (unsigned idx = 0 ; idx < c->pin_count() ; idx += 1) { verinum::V v=c->value(idx); @@ -754,7 +756,7 @@ void target_xnf::net_const(ostream&os, const NetConst*c) unsigned cpin; const NetObj*cur; - os << " PWR, " << v << ", " << choose_sig_name(&lnk) << endl; + OS << " PWR, " << v << ", " << choose_sig_name(&lnk) << endl; } } @@ -762,54 +764,54 @@ void target_xnf::net_const(ostream&os, const NetConst*c) * The logic gates I know so far can be translated directly into XNF * standard symbol types. This is a fairly obvious transformation. */ -void target_xnf::logic(ostream&os, const NetLogic*net) +void target_xnf::logic(const NetLogic*net) { // The XNF-LCA attribute overrides anything I might guess // about this object. string lca = net->attribute("XNF-LCA"); if (lca != "") { - draw_sym_with_lcaname(os, lca, net); + draw_sym_with_lcaname(OS, lca, net); return; } - os << "SYM, " << mangle(net->name()) << ", "; + OS << "SYM, " << mangle(net->name()) << ", "; switch (net->type()) { case NetLogic::AND: - os << "AND"; + OS << "AND"; break; case NetLogic::BUF: - os << "BUF"; + OS << "BUF"; break; case NetLogic::NAND: - os << "NAND"; + OS << "NAND"; break; case NetLogic::NOR: - os << "NOR"; + OS << "NOR"; break; case NetLogic::NOT: - os << "INV"; + OS << "INV"; break; case NetLogic::OR: - os << "OR"; + OS << "OR"; break; case NetLogic::XNOR: - os << "XNOR"; + OS << "XNOR"; break; case NetLogic::XOR: - os << "XOR"; + OS << "XOR"; break; case NetLogic::BUFIF0: case NetLogic::BUFIF1: - os << "TBUF"; + OS << "TBUF"; break; default: cerr << "internal error: XNF: Unhandled logic type." << endl; break; } - os << ", LIBVER=2.0.0" << endl; + OS << ", LIBVER=2.0.0" << endl; /* All of these kinds of devices have an output on pin 0. */ - draw_pin(os, "O", net->pin(0)); + draw_pin(OS, "O", net->pin(0)); /* Most devices have inputs called I for all the remaining pins. The TBUF devices are slightly different, but @@ -818,32 +820,32 @@ void target_xnf::logic(ostream&os, const NetLogic*net) case NetLogic::BUFIF0: assert(net->pin_count() == 3); - draw_pin(os, "I", net->pin(1)); - draw_pin(os, "~T", net->pin(2)); + draw_pin(OS, "I", net->pin(1)); + draw_pin(OS, "~T", net->pin(2)); break; case NetLogic::BUFIF1: assert(net->pin_count() == 3); - draw_pin(os, "I", net->pin(1)); - draw_pin(os, "T", net->pin(2)); + draw_pin(OS, "I", net->pin(1)); + draw_pin(OS, "T", net->pin(2)); break; default: if (net->pin_count() == 2) { - draw_pin(os, "I", net->pin(1)); + draw_pin(OS, "I", net->pin(1)); } else for (unsigned idx = 1; idx < net->pin_count(); idx += 1) { string name = "I"; assert(net->pin_count() <= 11); name += (char)('0'+idx-1); - draw_pin(os, name, net->pin(idx)); + draw_pin(OS, name, net->pin(idx)); } break; } - os << "END" << endl; + OS << "END" << endl; } -void target_xnf::bufz(ostream&os, const NetBUFZ*net) +void target_xnf::bufz(const NetBUFZ*net) { static int warned_once=0; if (!warned_once) { @@ -851,14 +853,14 @@ void target_xnf::bufz(ostream&os, const NetBUFZ*net) << endl; warned_once=1; } - os << "SYM, " << mangle(net->name()) << ", BUF, LIBVER=2.0.0" << endl; + OS << "SYM, " << mangle(net->name()) << ", BUF, LIBVER=2.0.0" << endl; assert(net->pin_count() == 2); - draw_pin(os, "O", net->pin(0)); - draw_pin(os, "I", net->pin(1)); - os << "END" << endl; + draw_pin(OS, "O", net->pin(0)); + draw_pin(OS, "I", net->pin(1)); + OS << "END" << endl; } -void target_xnf::udp(ostream&os, const NetUDP*net) +void target_xnf::udp(const NetUDP*net) { string lca = net->attribute("XNF-LCA"); @@ -869,7 +871,7 @@ void target_xnf::udp(ostream&os, const NetUDP*net) return; } - draw_sym_with_lcaname(os, lca, net); + draw_sym_with_lcaname(OS, lca, net); } static target_xnf target_xnf_obj; @@ -878,6 +880,9 @@ extern const struct target tgt_xnf = { "xnf", &target_xnf_obj }; /* * $Log: t-xnf.cc,v $ + * Revision 1.33 2000/08/08 01:50:42 steve + * target methods need not take a file stream. + * * Revision 1.32 2000/07/14 06:12:58 steve * Move inital value handling from NetNet to Nexus * objects. This allows better propogation of inital diff --git a/target.cc b/target.cc index 4ad694b6e..98856b6c6 100644 --- a/target.cc +++ b/target.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: target.cc,v 1.41 2000/07/29 16:21:08 steve Exp $" +#ident "$Id: target.cc,v 1.42 2000/08/08 01:50:42 steve Exp $" #endif # include "target.h" @@ -31,209 +31,209 @@ void target_t::start_design(ostream&os, const Design*) { } -void target_t::scope(ostream&, const NetScope*) +void target_t::scope(const NetScope*) { } -void target_t::event(ostream&, const NetEvent*ev) +void target_t::event(const NetEvent*ev) { cerr << ev->get_line() << ": error: target (" << typeid(*this).name() << "): Unhandled event <" << ev->full_name() << ">." << endl; } -void target_t::signal(ostream&os, const NetNet*) +void target_t::signal(const NetNet*) { } -void target_t::memory(ostream&os, const NetMemory*) +void target_t::memory(const NetMemory*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled memory." << endl; } -void target_t::func_def(ostream&os, const NetFuncDef*) +void target_t::func_def(const NetFuncDef*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled function definition." << endl; } -void target_t::task_def(ostream&os, const NetTaskDef*) +void target_t::task_def(const NetTaskDef*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled task definition." << endl; } -void target_t::logic(ostream&os, const NetLogic*) +void target_t::logic(const NetLogic*) { } -void target_t::bufz(ostream&os, const NetBUFZ*) +void target_t::bufz(const NetBUFZ*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled continuous assign (BUFZ)." << endl; } -void target_t::udp(ostream&os, const NetUDP*) +void target_t::udp(const NetUDP*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled UDP." << endl; } -void target_t::udp_comb(ostream&os, const NetUDP_COMB*) +void target_t::udp_comb(const NetUDP_COMB*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled combinational primitive." << endl; } -void target_t::lpm_add_sub(ostream&, const NetAddSub*) +void target_t::lpm_add_sub(const NetAddSub*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetAddSub." << endl; } -void target_t::lpm_clshift(ostream&, const NetCLShift*) +void target_t::lpm_clshift(const NetCLShift*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetCLShift." << endl; } -void target_t::lpm_compare(ostream&, const NetCompare*) +void target_t::lpm_compare(const NetCompare*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetCompare." << endl; } -void target_t::lpm_divide(ostream&, const NetDivide*) +void target_t::lpm_divide(const NetDivide*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetDivide." << endl; } -void target_t::lpm_ff(ostream&, const NetFF*) +void target_t::lpm_ff(const NetFF*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetFF." << endl; } -void target_t::lpm_mult(ostream&, const NetMult*) +void target_t::lpm_mult(const NetMult*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetMult." << endl; } -void target_t::lpm_mux(ostream&, const NetMux*) +void target_t::lpm_mux(const NetMux*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetMux." << endl; } -void target_t::lpm_ram_dq(ostream&, const NetRamDq*) +void target_t::lpm_ram_dq(const NetRamDq*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetRamDq." << endl; } -void target_t::net_assign(ostream&os, const NetAssign*) +void target_t::net_assign(const NetAssign*) { } -void target_t::net_assign_nb(ostream&os, const NetAssignNB*) +void target_t::net_assign_nb(const NetAssignNB*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled non-blocking assignment node." << endl; } -void target_t::net_case_cmp(ostream&os, const NetCaseCmp*) +void target_t::net_case_cmp(const NetCaseCmp*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled case compare node." << endl; } -bool target_t::net_cassign(ostream&os, const NetCAssign*dev) +bool target_t::net_cassign(const NetCAssign*dev) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetCAssign node." << endl; return false; } -void target_t::net_const(ostream&os, const NetConst*) +void target_t::net_const(const NetConst*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled CONSTANT node." << endl; } -bool target_t::net_force(ostream&os, const NetForce*dev) +bool target_t::net_force(const NetForce*dev) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled NetForce node." << endl; return false; } -void target_t::net_probe(ostream&os, const NetEvProbe*net) +void target_t::net_probe(const NetEvProbe*net) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled probe trigger node" << endl; net->dump_node(cerr, 4); } -bool target_t::process(ostream&os, const NetProcTop*top) +bool target_t::process(const NetProcTop*top) { - return top->statement()->emit_proc(os, this); + return top->statement()->emit_proc(this); } -void target_t::proc_assign(ostream&os, const NetAssign*) +void target_t::proc_assign(const NetAssign*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled procedural assignment." << endl; } -void target_t::proc_assign_mem(ostream&os, const NetAssignMem*) +void target_t::proc_assign_mem(const NetAssignMem*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled memory assignment." << endl; } -void target_t::proc_assign_nb(ostream&os, const NetAssignNB*) +void target_t::proc_assign_nb(const NetAssignNB*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled non-blocking assignment." << endl; } -void target_t::proc_assign_mem_nb(ostream&os, const NetAssignMemNB*) +void target_t::proc_assign_mem_nb(const NetAssignMemNB*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled non-blocking memory assignment." << endl; } -bool target_t::proc_block(ostream&os, const NetBlock*) +bool target_t::proc_block(const NetBlock*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled proc_block." << endl; return false; } -void target_t::proc_case(ostream&os, const NetCase*cur) +void target_t::proc_case(const NetCase*cur) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled case:" << endl; cur->dump(cerr, 6); } -bool target_t::proc_cassign(ostream&os, const NetCAssign*dev) +bool target_t::proc_cassign(const NetCAssign*dev) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled proc_cassign." << endl; return false; } -void target_t::proc_condit(ostream&os, const NetCondit*condit) +void target_t::proc_condit(const NetCondit*condit) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled conditional:" << endl; condit->dump(cerr, 6); } -bool target_t::proc_deassign(ostream&os, const NetDeassign*dev) +bool target_t::proc_deassign(const NetDeassign*dev) { cerr << dev->get_line() << ": internal error: " << "target (" << typeid(*this).name() << "): " @@ -241,14 +241,14 @@ bool target_t::proc_deassign(ostream&os, const NetDeassign*dev) return false; } -bool target_t::proc_delay(ostream&os, const NetPDelay*) +bool target_t::proc_delay(const NetPDelay*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled proc_delay." << endl; return false; } -bool target_t::proc_disable(ostream&os, const NetDisable*obj) +bool target_t::proc_disable(const NetDisable*obj) { cerr << obj->get_line() << ": internal error: " << "target (" << typeid(*this).name() << "): " @@ -256,20 +256,20 @@ bool target_t::proc_disable(ostream&os, const NetDisable*obj) return false; } -bool target_t::proc_force(ostream&os, const NetForce*dev) +bool target_t::proc_force(const NetForce*dev) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled proc_force." << endl; return false; } -void target_t::proc_forever(ostream&os, const NetForever*) +void target_t::proc_forever(const NetForever*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled proc_forever." << endl; } -bool target_t::proc_release(ostream&os, const NetRelease*dev) +bool target_t::proc_release(const NetRelease*dev) { cerr << dev->get_line() << ": internal error: " << "target (" << typeid(*this).name() << "): " @@ -277,46 +277,46 @@ bool target_t::proc_release(ostream&os, const NetRelease*dev) return false; } -void target_t::proc_repeat(ostream&os, const NetRepeat*) +void target_t::proc_repeat(const NetRepeat*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled proc_repeat." << endl; } -bool target_t::proc_trigger(ostream&os, const NetEvTrig*tr) +bool target_t::proc_trigger(const NetEvTrig*tr) { cerr << tr->get_line() << ": error: target (" << typeid(*this).name() << "): Unhandled event trigger." << endl; return false; } -void target_t::proc_stask(ostream&os, const NetSTask*) +void target_t::proc_stask(const NetSTask*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled proc_stask." << endl; } -void target_t::proc_utask(ostream&os, const NetUTask*) +void target_t::proc_utask(const NetUTask*) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled proc_utask." << endl; } -bool target_t::proc_wait(ostream&os, const NetEvWait*tr) +bool target_t::proc_wait(const NetEvWait*tr) { cerr << tr->get_line() << ": error: target (" << typeid(*this).name() << "): Unhandled event wait." << endl; return false; } -void target_t::proc_while(ostream&os, const NetWhile*net) +void target_t::proc_while(const NetWhile*net) { cerr << "target (" << typeid(*this).name() << "): " "Unhandled while:" << endl; net->dump(cerr, 6); } -void target_t::end_design(ostream&os, const Design*) +void target_t::end_design(const Design*) { } @@ -398,6 +398,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex) /* * $Log: target.cc,v $ + * Revision 1.42 2000/08/08 01:50:42 steve + * target methods need not take a file stream. + * * Revision 1.41 2000/07/29 16:21:08 steve * Report code generation errors through proc_delay. * diff --git a/target.h b/target.h index 1ba5182dd..4402e89ca 100644 --- a/target.h +++ b/target.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: target.h,v 1.40 2000/07/29 16:21:08 steve Exp $" +#ident "$Id: target.h,v 1.41 2000/08/08 01:50:42 steve Exp $" #endif # include "netlist.h" @@ -52,77 +52,78 @@ struct target { struct target_t { virtual ~target_t(); - /* Start the design. */ + /* Start the design. This sets the main output file stream + that the target should use. */ virtual void start_design(ostream&os, const Design*); /* This is called once for each scope in the design, before anything else is called. */ - virtual void scope(ostream&os, const NetScope*); + virtual void scope(const NetScope*); /* Output an event object. Called for each named event in the scope. */ - virtual void event(ostream&os, const NetEvent*); + virtual void event(const NetEvent*); /* Output a signal (called for each signal) */ - virtual void signal(ostream&os, const NetNet*); + virtual void signal(const NetNet*); /* Output a memory (called for each memory object) */ - virtual void memory(ostream&os, const NetMemory*); + virtual void memory(const NetMemory*); /* Output a defined task. */ - virtual void task_def(ostream&, const NetTaskDef*); - virtual void func_def(ostream&, const NetFuncDef*); + virtual void task_def(const NetTaskDef*); + virtual void func_def(const NetFuncDef*); /* LPM style components are handled here. */ - virtual void lpm_add_sub(ostream&os, const NetAddSub*); - virtual void lpm_clshift(ostream&os, const NetCLShift*); - virtual void lpm_compare(ostream&os, const NetCompare*); - virtual void lpm_divide(ostream&os, const NetDivide*); - virtual void lpm_ff(ostream&os, const NetFF*); - virtual void lpm_mult(ostream&os, const NetMult*); - virtual void lpm_mux(ostream&os, const NetMux*); - virtual void lpm_ram_dq(ostream&os, const NetRamDq*); + virtual void lpm_add_sub(const NetAddSub*); + virtual void lpm_clshift(const NetCLShift*); + virtual void lpm_compare(const NetCompare*); + virtual void lpm_divide(const NetDivide*); + virtual void lpm_ff(const NetFF*); + virtual void lpm_mult(const NetMult*); + virtual void lpm_mux(const NetMux*); + virtual void lpm_ram_dq(const NetRamDq*); /* Output a gate (called for each gate) */ - virtual void logic(ostream&os, const NetLogic*); - virtual void bufz(ostream&os, const NetBUFZ*); - virtual void udp(ostream&os, const NetUDP*); - virtual void udp_comb(ostream&os, const NetUDP_COMB*); - virtual void net_assign(ostream&os, const NetAssign*); - virtual void net_assign_nb(ostream&os, const NetAssignNB*); - virtual void net_case_cmp(ostream&os, const NetCaseCmp*); - virtual bool net_cassign(ostream&os, const NetCAssign*); - virtual void net_const(ostream&os, const NetConst*); - virtual bool net_force(ostream&os, const NetForce*); - virtual void net_probe(ostream&os, const NetEvProbe*); + virtual void logic(const NetLogic*); + virtual void bufz(const NetBUFZ*); + virtual void udp(const NetUDP*); + virtual void udp_comb(const NetUDP_COMB*); + virtual void net_assign(const NetAssign*); + virtual void net_assign_nb(const NetAssignNB*); + virtual void net_case_cmp(const NetCaseCmp*); + virtual bool net_cassign(const NetCAssign*); + virtual void net_const(const NetConst*); + virtual bool net_force(const NetForce*); + virtual void net_probe(const NetEvProbe*); /* Output a process (called for each process). It is up to the target to recurse if desired. */ - virtual bool process(ostream&os, const NetProcTop*); + virtual bool process(const NetProcTop*); /* Various kinds of process nodes are dispatched through these. */ - virtual void proc_assign(ostream&os, const NetAssign*); - virtual void proc_assign_mem(ostream&os, const NetAssignMem*); - virtual void proc_assign_nb(ostream&os, const NetAssignNB*); - virtual void proc_assign_mem_nb(ostream&os, const NetAssignMemNB*); - virtual bool proc_block(ostream&os, const NetBlock*); - virtual void proc_case(ostream&os, const NetCase*); - virtual bool proc_cassign(ostream&os, const NetCAssign*); - virtual void proc_condit(ostream&os, const NetCondit*); - virtual bool proc_deassign(ostream&os, const NetDeassign*); - virtual bool proc_disable(ostream&os, const NetDisable*); - virtual bool proc_force(ostream&os, const NetForce*); - virtual void proc_forever(ostream&os, const NetForever*); - virtual bool proc_release(ostream&os, const NetRelease*); - virtual void proc_repeat(ostream&os, const NetRepeat*); - virtual bool proc_trigger(ostream&os, const NetEvTrig*); - virtual void proc_stask(ostream&os, const NetSTask*); - virtual void proc_utask(ostream&os, const NetUTask*); - virtual bool proc_wait(ostream&os, const NetEvWait*); - virtual void proc_while(ostream&os, const NetWhile*); - virtual bool proc_delay(ostream&os, const NetPDelay*); + virtual void proc_assign(const NetAssign*); + virtual void proc_assign_mem(const NetAssignMem*); + virtual void proc_assign_nb(const NetAssignNB*); + virtual void proc_assign_mem_nb(const NetAssignMemNB*); + virtual bool proc_block(const NetBlock*); + virtual void proc_case(const NetCase*); + virtual bool proc_cassign(const NetCAssign*); + virtual void proc_condit(const NetCondit*); + virtual bool proc_deassign(const NetDeassign*); + virtual bool proc_delay(const NetPDelay*); + virtual bool proc_disable(const NetDisable*); + virtual bool proc_force(const NetForce*); + virtual void proc_forever(const NetForever*); + virtual bool proc_release(const NetRelease*); + virtual void proc_repeat(const NetRepeat*); + virtual bool proc_trigger(const NetEvTrig*); + virtual void proc_stask(const NetSTask*); + virtual void proc_utask(const NetUTask*); + virtual bool proc_wait(const NetEvWait*); + virtual void proc_while(const NetWhile*); /* Done with the design. */ - virtual void end_design(ostream&os, const Design*); + virtual void end_design(const Design*); }; /* This class is used by the NetExpr class to help with the scanning @@ -160,6 +161,9 @@ extern const struct target *target_table[]; /* * $Log: target.h,v $ + * Revision 1.41 2000/08/08 01:50:42 steve + * target methods need not take a file stream. + * * Revision 1.40 2000/07/29 16:21:08 steve * Report code generation errors through proc_delay. *