From 9cef973d9ba6dd925c0b4429889396579c0893bf Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 8 Jun 2002 23:42:46 +0000 Subject: [PATCH] Add NetRamDq synthsesis from memory l-values. --- design_dump.cc | 13 ++++++++++- net_assign.cc | 12 ++++++++-- netlist.h | 8 +++++-- syn-rules.y | 61 ++++++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 82 insertions(+), 12 deletions(-) diff --git a/design_dump.cc b/design_dump.cc index bbcce4524..1e1fcac22 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: design_dump.cc,v 1.126 2002/06/05 03:44:25 steve Exp $" +#ident "$Id: design_dump.cc,v 1.127 2002/06/08 23:42:46 steve Exp $" #endif # include "config.h" @@ -431,6 +431,14 @@ void NetAssign_::dump_lval(ostream&o) const } else { o << "[" << (loff_+lwid_-1) << ":" << loff_ << "]"; } + } else if (mem_) { + // Is there an obvious way to flag memories in the dump + // as different from the _real_ bit mux case? + // o << "**memory**"; + o << mem_->name().c_str() << "["; + if (bmux_) o << *bmux_; + else o << "**oops**"; + o << "]"; } else { o << ""; } @@ -965,6 +973,9 @@ void Design::dump(ostream&o) const /* * $Log: design_dump.cc,v $ + * Revision 1.127 2002/06/08 23:42:46 steve + * Add NetRamDq synthsesis from memory l-values. + * * Revision 1.126 2002/06/05 03:44:25 steve * Add support for memory words in l-value of * non-blocking assignments, and remove the special diff --git a/net_assign.cc b/net_assign.cc index 31575c57a..fde16e270 100644 --- a/net_assign.cc +++ b/net_assign.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: net_assign.cc,v 1.11 2002/06/04 05:38:44 steve Exp $" +#ident "$Id: net_assign.cc,v 1.12 2002/06/08 23:42:46 steve Exp $" #endif # include "config.h" @@ -68,6 +68,11 @@ void NetAssign_::set_bmux(NetExpr*r) bmux_ = r; } +NetExpr* NetAssign_::bmux() +{ + return bmux_; +} + const NetExpr* NetAssign_::bmux() const { return bmux_; @@ -96,7 +101,7 @@ NetNet* NetAssign_::sig() const return sig_; } -const NetMemory* NetAssign_::mem() const +NetMemory* NetAssign_::mem() const { return mem_; } @@ -231,6 +236,9 @@ NetAssignNB::~NetAssignNB() /* * $Log: net_assign.cc,v $ + * Revision 1.12 2002/06/08 23:42:46 steve + * Add NetRamDq synthsesis from memory l-values. + * * Revision 1.11 2002/06/04 05:38:44 steve * Add support for memory words in l-value of * blocking assignments, and remove the special diff --git a/netlist.h b/netlist.h index 94d267f11..cff396a55 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.241 2002/06/05 03:44:25 steve Exp $" +#ident "$Id: netlist.h,v 1.242 2002/06/08 23:42:46 steve Exp $" #endif /* @@ -1228,6 +1228,7 @@ class NetAssign_ { // If this expression exists, then only a single bit is to be // set from the rval, and the value of this expression selects // the pin that gets the value. + NetExpr*bmux(); const NetExpr*bmux() const; unsigned get_loff() const; @@ -1244,7 +1245,7 @@ class NetAssign_ { const char*name() const; NetNet* sig() const; - const NetMemory*mem() const; + NetMemory*mem() const; // This pointer is for keeping simple lists. NetAssign_* more; @@ -2924,6 +2925,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.242 2002/06/08 23:42:46 steve + * Add NetRamDq synthsesis from memory l-values. + * * Revision 1.241 2002/06/05 03:44:25 steve * Add support for memory words in l-value of * non-blocking assignments, and remove the special diff --git a/syn-rules.y b/syn-rules.y index d327acac3..ecbe7eb71 100644 --- a/syn-rules.y +++ b/syn-rules.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: syn-rules.y,v 1.20 2002/06/05 03:44:25 steve Exp $" +#ident "$Id: syn-rules.y,v 1.21 2002/06/08 23:42:46 steve Exp $" #endif # include "config.h" @@ -133,6 +133,38 @@ static void hookup_DFF_CE(NetFF*ff, NetESignal*d, NetEvProbe*pclk, } +static void hookup_RAMDQ(NetRamDq*ram, NetESignal*d, NetNet*adr, + NetEvProbe*pclk, NetNet*ce, + NetAssign_*a, unsigned rval_pinoffset) +{ + assert(d); + assert(a); + + /* Connect the input Data bits of the RAM, from the r-value of + the assignment. */ + int loff = a->get_loff(); + for (unsigned idx = 0 ; idx < ram->width() ; idx += 1) { + connect(ram->pin_Data(idx), d->bit(idx+rval_pinoffset)); + } + + /* Connect the Address pins from the adr net discovered by the + caller. */ + for (unsigned idx = 0 ; idx < ram->awidth() ; idx += 1) { + connect(ram->pin_Address(idx), adr->pin(idx)); + } + + /* Connect the input clock and the WE of the RAM. */ + assert(pclk); + connect(ram->pin_InClock(), pclk->pin(0)); + assert(ce); + connect(ram->pin_WE(), ce->pin(0)); + + /* This notices any other NetRamDq objects connected to the + same NetMemory, that have the same address pins and are + otherwise compatible. This absorbs them into this object. */ + ram->absorb_partners(); +} + static void make_DFF_CE(Design*des, NetProcTop*top, NetEvWait*wclk, NetEvent*eclk, NetExpr*cexp, NetAssignBase*asn) { @@ -162,11 +194,20 @@ static void make_DFF_CE(Design*des, NetProcTop*top, NetEvWait*wclk, // first data and 0, then carry and 1. // FIXME: ff gets its pin names wrong when loff_ is nonzero. - // cerr << "new NetFF named " << a->name() << endl; - NetFF*ff = new NetFF(top->scope(), a->name(), + if (a->sig()) { + // cerr << "new NetFF named " << a->name() << endl; + NetFF*ff = new NetFF(top->scope(), a->name(), a->lwidth()); - hookup_DFF_CE(ff, d, pclk, ce, a, rval_pinoffset); - des->add_node(ff); + hookup_DFF_CE(ff, d, pclk, ce, a, rval_pinoffset); + des->add_node(ff); + } else if (a->mem()) { + NetMemory *m=a->mem(); + NetNet *adr = a->bmux()->synthesize(des); + NetRamDq*ram = new NetRamDq(top->scope(), m->name().c_str(), + m, adr->pin_count()); + hookup_RAMDQ(ram, d, adr, pclk, ce, a, rval_pinoffset); + des->add_node(ram); + } rval_pinoffset += a->lwidth(); } des->delete_process(top); @@ -217,7 +258,10 @@ struct tokenize : public proc_match_t { { syn_token_t*cur; cur = new syn_token_t; - cur->token = dev->l_val(0)->bmux() ? S_ASSIGN_MUX : S_ASSIGN; + // Bit Muxes can't be synthesized (yet), but it's too much + // work to detect them now. + // cur->token = dev->l_val(0)->bmux() ? S_ASSIGN_MUX : S_ASSIGN; + cur->token = S_ASSIGN; cur->assign = dev; cur->next_ = 0; last_->next_ = cur; @@ -229,7 +273,10 @@ struct tokenize : public proc_match_t { { syn_token_t*cur; cur = new syn_token_t; - cur->token = dev->l_val(0)->bmux() ? S_ASSIGN_MUX : S_ASSIGN; + // Bit Muxes can't be synthesized (yet), but it's too much + // work to detect them now. + // cur->token = dev->l_val(0)->bmux() ? S_ASSIGN_MUX : S_ASSIGN; + cur->token = S_ASSIGN; cur->assign = dev; cur->next_ = 0; last_->next_ = cur;