diff --git a/design_dump.cc b/design_dump.cc index bca5bd9a1..a86ab1540 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -136,6 +136,13 @@ ostream& operator <<(ostream&o, struct __ScopePathManip marg) return o; } +void NetBranch::dump(ostream&o, unsigned ind) const +{ + o << setw(ind) << "" << "branch ..."; + o << " island=" << get_island(); + o << " // " << get_fileline() << endl; +} + void NetDelaySrc::dump(ostream&o, unsigned ind) const { o << setw(ind) << "" << "specify delay"; @@ -1511,6 +1518,13 @@ void Design::dump(ostream&o) const } while (cur != nodes_->node_next_); } + o << "ELABORATED BRANCHES:" << endl; + + if (branches_) { + for (NetBranch*cur = branches_ ; cur ; cur = cur->next_) + cur->dump(o, 0); + } + o << "ELABORATED PROCESSES:" << endl; // Dump the processes. diff --git a/elab_expr.cc b/elab_expr.cc index 922e0f708..ca4201869 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -1253,6 +1253,7 @@ NetExpr* PECallFunction::elaborate_access_func_(Design*des, NetScope*scope, branch = new NetBranch(dis); branch->set_line(*this); + des->add_branch(branch); connect(branch->pin(0), sig->pin(0)); join_island(branch); diff --git a/emit.cc b/emit.cc index deb4b1a0e..9ab956afa 100644 --- a/emit.cc +++ b/emit.cc @@ -455,6 +455,11 @@ int Design::emit(struct target_t*tgt) const } + bool branches_rc = true; + for (NetBranch*cur = branches_ ; cur ; cur = cur->next_) { + branches_rc = tgt->branch(cur) && branches_rc; + } + // emit task and function definitions bool tasks_rc = true; for (list::const_iterator scope = root_scopes_.begin(); @@ -477,6 +482,8 @@ int Design::emit(struct target_t*tgt) const return -2; if (proc_rc == false) return -3; + if (branches_rc == false) + return -4; return rc; } diff --git a/net_design.cc b/net_design.cc index 1ee8a4e1f..29835c15f 100644 --- a/net_design.cc +++ b/net_design.cc @@ -38,6 +38,7 @@ Design:: Design() : errors(0), nodes_(0), procs_(0), aprocs_(0), lcounter_(0) { + branches_ = 0; procs_idx_ = 0; des_precision_ = 0; nodes_functor_cur_ = 0; @@ -758,6 +759,12 @@ void Design::del_node(NetNode*net) net->design_ = 0; } +void Design::add_branch(NetBranch*bra) +{ + bra->next_ = branches_; + branches_ = bra; +} + void Design::add_process(NetProcTop*pro) { pro->next_ = procs_; diff --git a/netlist.h b/netlist.h index d07e51d5e..2b2e81cb0 100644 --- a/netlist.h +++ b/netlist.h @@ -181,8 +181,13 @@ class NetBranch : public NetPins, public IslandBranch { explicit NetBranch(ivl_discipline_t dis, perm_string name); ~NetBranch(); + void dump(ostream&, unsigned) const; + private: perm_string name_; + // The design class uses this member to list the branches. + friend class Design; + NetBranch*next_; }; class Link { @@ -859,6 +864,7 @@ class NetScope : public Attrib { NetNet::Type default_nettype_; NetEvent *events_; + typedef std::map::const_iterator signals_map_iter_t; std::map signals_map_; perm_string module_name_; @@ -3871,6 +3877,9 @@ class Design { void add_node(NetNode*); void del_node(NetNode*); + // BRANCHES + void add_branch(NetBranch*); + // PROCESSES void add_process(NetProcTop*); void add_process(NetAnalogTop*); @@ -3901,6 +3910,9 @@ class Design { NetNode*nodes_functor_cur_; NetNode*nodes_functor_nxt_; + // List the branches in the design. + NetBranch*branches_; + // List the processes in the design. NetProcTop*procs_; NetProcTop*procs_idx_; diff --git a/target.cc b/target.cc index cc33018ac..8e5147c0f 100644 --- a/target.cc +++ b/target.cc @@ -32,6 +32,13 @@ void target_t::scope(const NetScope*) { } +bool target_t::branch(const NetBranch*obj) +{ + cerr << obj->get_fileline() << ": error: target (" << typeid(*this).name() + << "): Unhandled branch." << endl; + return false; +} + void target_t::event(const NetEvent*ev) { cerr << ev->get_fileline() << ": error: target (" << typeid(*this).name() diff --git a/target.h b/target.h index c62212086..b957f1693 100644 --- a/target.h +++ b/target.h @@ -63,6 +63,9 @@ struct target_t { virtual void signal(const NetNet*) =0; virtual bool signal_paths(const NetNet*); + /* Analog branches */ + virtual bool branch(const NetBranch*); + /* Output a defined task. */ virtual void task_def(const NetScope*); virtual bool func_def(const NetScope*);