From 0da27a2f45e2ad1b65173d71c4d194035843fd0e Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sun, 9 Nov 2008 15:32:50 -0800 Subject: [PATCH] Collect analog branches into islands. Discipline islands all along were intended to carry collections of analog branches, as well as the current switch modeling support. --- design_dump.cc | 2 +- elab_expr.cc | 1 + ivl_target_priv.h | 6 +++--- net_tran.cc | 25 +++++++++++++------------ netlist.cc | 2 +- netlist.h | 17 +++++++++++------ t-dll.cc | 2 +- 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/design_dump.cc b/design_dump.cc index 5a2d3b8cb..bca5bd9a1 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -678,7 +678,7 @@ void NetTaskDef::dump(ostream&o, unsigned ind) const void NetTran::dump_node(ostream&o, unsigned ind) const { o << setw(ind) << "" << type_ << " " << name() - << " island " << island; + << " island " << get_island(); if (type_ == IVL_SW_TRAN_VP) { o << " width=" << vector_width() << " part=" << part_width() diff --git a/elab_expr.cc b/elab_expr.cc index 2755e46c7..922e0f708 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -1254,6 +1254,7 @@ NetExpr* PECallFunction::elaborate_access_func_(Design*des, NetScope*scope, branch = new NetBranch(dis); branch->set_line(*this); connect(branch->pin(0), sig->pin(0)); + join_island(branch); } else { ivl_assert(*this, 0); diff --git a/ivl_target_priv.h b/ivl_target_priv.h index 042e0e415..eae6f3970 100644 --- a/ivl_target_priv.h +++ b/ivl_target_priv.h @@ -1,5 +1,5 @@ #ifndef __ivl_target_priv_H -#define __ivl_target_H +#define __ivl_target_priv_H /* * Copyright (c) 2008 Stephen Williams (steve@icarus.com) * @@ -33,10 +33,10 @@ * have disciplines and do not belong to islands. */ -class discipline_t; +class ivl_discipline_s; struct ivl_island_s { - discipline_t*discipline; + ivl_discipline_s*discipline; // user accessible flags. They are initially false, always. vector flags; }; diff --git a/net_tran.cc b/net_tran.cc index a129f5256..aa36329f2 100644 --- a/net_tran.cc +++ b/net_tran.cc @@ -78,7 +78,7 @@ unsigned NetTran::part_offset() const return off_; } -void join_island(NetObj*obj) +void join_island(NetPins*obj) { IslandBranch*branch = dynamic_cast (obj); @@ -88,7 +88,7 @@ void join_island(NetObj*obj) // If this is a branch, but already given to an island, then // stop. - if (branch->island) + if (branch->island_) return; list uncommitted_neighbors; @@ -110,31 +110,32 @@ void join_island(NetObj*obj) if (tmp == obj) continue; - // If tmb is not a branch, then skip it. + // If tmp is not a branch, then skip it. IslandBranch*tmp_branch = dynamic_cast (tmp); if (tmp_branch == 0) continue; - // If that is an uncommitted branch, then save + // If tmp is an uncommitted branch, then save // it. When I finally choose an island for self, // these branches will be scanned so that they join // this island as well. - if (tmp_branch->island == 0) { + if (tmp_branch->island_ == 0) { uncommitted_neighbors.push_back(tmp); continue; } - ivl_assert(*obj, branch->island==0 || branch->island==tmp_branch->island); + ivl_assert(*obj, branch->island_==0 || branch->island_==tmp_branch->island_); // We found an existing island to join. Join it // now. Keep scanning in order to find more neighbors. - if (branch->island == 0) { + if (branch->island_ == 0) { if (debug_elaborate) cerr << obj->get_fileline() << ": debug: " << "Join branch to existing island." << endl; - branch->island = tmp_branch->island; + branch->island_ = tmp_branch->island_; + ivl_assert(*obj, branch->island_->discipline == tmp_branch->island_->discipline); - } else if (branch->island != tmp_branch->island) { + } else if (branch->island_ != tmp_branch->island_) { cerr << obj->get_fileline() << ": internal error: " << "Oops, Found 2 neighboring islands." << endl; ivl_assert(*obj, 0); @@ -144,9 +145,9 @@ void join_island(NetObj*obj) // If after all that we did not find an island to join, then // start the island not and join it. - if (branch->island == 0) { - branch->island = new ivl_island_s; - branch->island->discipline = 0; + if (branch->island_ == 0) { + branch->island_ = new ivl_island_s; + branch->island_->discipline = branch->discipline_; if (debug_elaborate) cerr << obj->get_fileline() << ": debug: " << "Create new island for this branch" << endl; diff --git a/netlist.cc b/netlist.cc index 764cb514a..c950e5f38 100644 --- a/netlist.cc +++ b/netlist.cc @@ -243,7 +243,7 @@ NetNode::~NetNode() } NetBranch::NetBranch(ivl_discipline_t dis) -: NetPins(2), discipline_(dis) +: NetPins(2), IslandBranch(dis) { pin(0).set_dir(Link::PASSIVE); pin(1).set_dir(Link::PASSIVE); diff --git a/netlist.h b/netlist.h index 11acc908b..d07e51d5e 100644 --- a/netlist.h +++ b/netlist.h @@ -55,6 +55,7 @@ class NetEvent; class NetNet; class NetNode; class NetObj; +class NetPins; class NetProc; class NetProcTop; class NetRelease; @@ -74,7 +75,7 @@ struct functor_t; ostream& operator << (ostream&o, ivl_variable_type_t val); -extern void join_island(NetObj*obj); +extern void join_island(NetPins*obj); class NetPins : public LineInfo { @@ -154,10 +155,15 @@ class NetObj : public NetPins, public Attrib { class IslandBranch { public: - IslandBranch() : island(0) { } + IslandBranch(ivl_discipline_t dis =0) : island_(0), discipline_(dis) { } - public: - struct ivl_island_s* island; + ivl_island_t get_island() const { return island_; } + + friend void join_island(NetPins*); + + private: + ivl_island_t island_; + ivl_discipline_t discipline_; }; /* @@ -168,7 +174,7 @@ class IslandBranch { * potential. Pin(1) is the sink of flow and the minus (or ground) of * potential. */ -class NetBranch : public NetPins { +class NetBranch : public NetPins, public IslandBranch { public: explicit NetBranch(ivl_discipline_t dis); @@ -176,7 +182,6 @@ class NetBranch : public NetPins { ~NetBranch(); private: - ivl_discipline_t discipline_; perm_string name_; }; diff --git a/t-dll.cc b/t-dll.cc index d70a94d13..e0d59eded 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -1051,7 +1051,7 @@ bool dll_target::tran(const NetTran*net) obj->offset = 0; obj->name = net->name(); obj->scope = find_scope(des_, net->scope()); - obj->island = net->island; + obj->island = net->get_island(); assert(obj->scope); assert(obj->island);