From ca2fd41bb6ec3ca3455c16860203b58d5d6c41d4 Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 6 May 2000 15:41:56 +0000 Subject: [PATCH] Carry assignment strength to pform. --- PGate.cc | 31 ++++++++++++++++++++++++++++- PGate.h | 20 ++++++++++++++++++- parse.y | 54 +++++++++++++++++++++++++++++++++++++++++++-------- pform.cc | 15 +++++++++++--- pform.h | 11 +++++++++-- pform_dump.cc | 32 ++++++++++++++++++++++++++++-- 6 files changed, 146 insertions(+), 17 deletions(-) diff --git a/PGate.cc b/PGate.cc index f4c5c7dce..1d4ecf7bc 100644 --- a/PGate.cc +++ b/PGate.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: PGate.cc,v 1.8 2000/03/08 04:36:53 steve Exp $" +#ident "$Id: PGate.cc,v 1.9 2000/05/06 15:41:56 steve Exp $" #endif # include "PGate.h" @@ -31,6 +31,8 @@ PGate::PGate(const string&name, : name_(name), pins_(pins) { if (del) delay_.set_delays(del); + str0_ = STRONG; + str1_ = STRONG; } PGate::PGate(const string&name, @@ -39,17 +41,41 @@ PGate::PGate(const string&name, : name_(name), pins_(pins) { if (del) delay_.set_delay(del); + str0_ = STRONG; + str1_ = STRONG; } PGate::PGate(const string&name, svector*pins) : name_(name), pins_(pins) { + str0_ = STRONG; + str1_ = STRONG; } PGate::~PGate() { } +PGate::strength_t PGate::strength0() const +{ + return str0_; +} + +void PGate::strength0(PGate::strength_t s) +{ + str0_ = s; +} + +PGate::strength_t PGate::strength1() const +{ + return str1_; +} + +void PGate::strength1(PGate::strength_t s) +{ + str1_ = s; +} + void PGate::elaborate_scope(Design*, NetScope*) const { } @@ -152,6 +178,9 @@ void PGModule::set_range(PExpr*msb, PExpr*lsb) /* * $Log: PGate.cc,v $ + * Revision 1.9 2000/05/06 15:41:56 steve + * Carry assignment strength to pform. + * * Revision 1.8 2000/03/08 04:36:53 steve * Redesign the implementation of scopes and parameters. * I now generate the scopes and notice the parameters diff --git a/PGate.h b/PGate.h index 1643d4d28..2540b28b7 100644 --- a/PGate.h +++ b/PGate.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: PGate.h,v 1.17 2000/05/02 16:27:38 steve Exp $" +#ident "$Id: PGate.h,v 1.18 2000/05/06 15:41:56 steve Exp $" #endif # include "svector.h" @@ -42,10 +42,17 @@ class Module; * This pins of a gate are connected to expressions. The elaboration * step will need to convert expressions to a network of gates in * order to elaborate expression inputs, but that can easily be done. + * + * The PGate base class also carries the strength0 and strength1 + * strengths for those gates where the driver[s] can be described by a + * single strength pair. There is a strength of the 0 drive, and a + * strength of the 1 drive. */ class PGate : public LineInfo { public: + enum strength_t { HIGHZ, WEAK, PULL, STRONG, SUPPLY }; + explicit PGate(const string&name, svector*pins, const svector*del); @@ -66,6 +73,12 @@ class PGate : public LineInfo { unsigned pin_count() const { return pins_? pins_->count() : 0; } const PExpr*pin(unsigned idx) const { return (*pins_)[idx]; } + strength_t strength0() const; + strength_t strength1() const; + + void strength0(strength_t); + void strength1(strength_t); + map attributes; virtual void dump(ostream&out) const; @@ -84,6 +97,8 @@ class PGate : public LineInfo { PDelays delay_; svector*pins_; + strength_t str0_, str1_; + private: // not implemented PGate(const PGate&); PGate& operator= (const PGate&); @@ -204,6 +219,9 @@ class PGModule : public PGate { /* * $Log: PGate.h,v $ + * Revision 1.18 2000/05/06 15:41:56 steve + * Carry assignment strength to pform. + * * Revision 1.17 2000/05/02 16:27:38 steve * Move signal elaboration to a seperate pass. * diff --git a/parse.y b/parse.y index 08f3bb67f..c39b06232 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: parse.y,v 1.93 2000/05/04 03:37:59 steve Exp $" +#ident "$Id: parse.y,v 1.94 2000/05/06 15:41:56 steve Exp $" #endif # include "parse_misc.h" @@ -34,6 +34,8 @@ extern void lex_end_table(); char*text; list*strings; + struct str_pair_t drive; + PCase::Item*citem; svector*citems; @@ -97,6 +99,7 @@ extern void lex_end_table(); %token KK_attribute +%type drive_strength drive_strength_opt dr_strength0 dr_strength1 %type udp_input_sym udp_output_sym %type udp_input_list udp_sequ_entry udp_comb_entry %type udp_entry_list udp_comb_entry_list udp_sequ_entry_list @@ -381,20 +384,49 @@ description drive_strength : '(' dr_strength0 ',' dr_strength1 ')' + { $$.str0 = $2.str0; + $$.str1 = $4.str1; + } | '(' dr_strength1 ',' dr_strength0 ')' + { $$.str0 = $4.str0; + $$.str1 = $2.str1; + } | '(' dr_strength0 ',' K_highz1 ')' + { $$.str0 = $2.str0; + $$.str1 = PGate::HIGHZ; + } | '(' dr_strength1 ',' K_highz0 ')' + { $$.str0 = PGate::HIGHZ; + $$.str1 = $2.str1; + } | '(' K_highz1 ',' dr_strength0 ')' + { $$.str0 = $4.str0; + $$.str1 = PGate::HIGHZ; + } | '(' K_highz0 ',' dr_strength1 ')' + { $$.str0 = PGate::HIGHZ; + $$.str1 = $4.str1; + } ; drive_strength_opt - : drive_strength - | + : drive_strength { $$ = $1; } + | { $$.str0 = PGate::STRONG; $$.str1 = PGate::STRONG; } ; -dr_strength0 : K_supply0 | K_strong0 | K_pull0 | K_weak0 ; -dr_strength1 : K_supply1 | K_strong1 | K_pull1 | K_weak1 ; +dr_strength0 + : K_supply0 { $$.str0 = PGate::SUPPLY; } + | K_strong0 { $$.str0 = PGate::STRONG; } + | K_pull0 { $$.str0 = PGate::PULL; } + | K_weak0 { $$.str0 = PGate::WEAK; } + ; + +dr_strength1 + : K_supply1 { $$.str1 = PGate::SUPPLY; } + | K_strong1 { $$.str1 = PGate::STRONG; } + | K_pull1 { $$.str1 = PGate::PULL; } + | K_weak1 { $$.str1 = PGate::WEAK; } + ; event_control : '@' IDENTIFIER @@ -1139,7 +1171,7 @@ module_item delete $1; } | K_assign drive_strength_opt delay3_opt assign_list ';' - { pform_make_pgassign_list($4, $3, @1.text, @1.first_line); } + { pform_make_pgassign_list($4, $3, $2, @1.text, @1.first_line); } | K_assign error '=' expression ';' | K_always statement { PProcess*tmp = pform_make_behavior(PProcess::PR_ALWAYS, $2); @@ -1197,14 +1229,20 @@ module_item_list net_decl_assign : IDENTIFIER '=' expression { PEIdent*id = new PEIdent($1); - PGAssign*tmp = pform_make_pgassign(id, $3, 0); + struct str_pair_t str; + str.str0 = PGate::STRONG; + str.str1 = PGate::STRONG; + PGAssign*tmp = pform_make_pgassign(id, $3, 0, str); tmp->set_file(@1.text); tmp->set_lineno(@1.first_line); $$ = $1; } | delay1 IDENTIFIER '=' expression { PEIdent*id = new PEIdent($2); - PGAssign*tmp = pform_make_pgassign(id, $4, $1); + struct str_pair_t str; + str.str0 = PGate::STRONG; + str.str1 = PGate::STRONG; + PGAssign*tmp = pform_make_pgassign(id, $4, $1, str); tmp->set_file(@2.text); tmp->set_lineno(@2.first_line); $$ = $2; diff --git a/pform.cc b/pform.cc index e91be538a..734622f28 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: pform.cc,v 1.57 2000/04/01 19:31:57 steve Exp $" +#ident "$Id: pform.cc,v 1.58 2000/05/06 15:41:57 steve Exp $" #endif # include "compiler.h" @@ -451,7 +451,8 @@ void pform_make_modgates(const string&type, } PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval, - svector*del) + svector*del, + struct str_pair_t str) { svector*wires = new svector(2); (*wires)[0] = lval; @@ -464,19 +465,24 @@ PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval, else cur = new PGAssign(wires, del); + cur->strength0(str.str0); + cur->strength1(str.str1); + pform_cur_module->add_gate(cur); return cur; } void pform_make_pgassign_list(svector*alist, svector*del, + struct str_pair_t str, const string& text, unsigned lineno) { PGAssign*tmp; for (unsigned idx = 0 ; idx < alist->count()/2 ; idx += 1) { tmp = pform_make_pgassign((*alist)[2*idx], - (*alist)[2*idx+1], del); + (*alist)[2*idx+1], + del, str); tmp->set_file(text); tmp->set_lineno(lineno); } @@ -853,6 +859,9 @@ int pform_parse(const char*path, map&modules, /* * $Log: pform.cc,v $ + * Revision 1.58 2000/05/06 15:41:57 steve + * Carry assignment strength to pform. + * * Revision 1.57 2000/04/01 19:31:57 steve * Named events as far as the pform. * diff --git a/pform.h b/pform.h index c439934d9..d46692b49 100644 --- a/pform.h +++ b/pform.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: pform.h,v 1.38 2000/04/01 19:31:57 steve Exp $" +#ident "$Id: pform.h,v 1.39 2000/05/06 15:41:57 steve Exp $" #endif # include "netlist.h" @@ -74,6 +74,8 @@ struct parmvalue_t { svector*by_name; }; +struct str_pair_t { PGate::strength_t str0, str1; }; + /* The lgate is gate instantiation information. */ struct lgate { lgate(int =0) @@ -158,9 +160,11 @@ extern void pform_make_modgates(const string&type, /* Make a continuous assignment node, with optional bit- or part- select. */ extern PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval, - svector*delays); + svector*delays, + struct str_pair_t str); extern void pform_make_pgassign_list(svector*alist, svector*del, + struct str_pair_t str, const string& text, unsigned lineno); @@ -185,6 +189,9 @@ extern void pform_dump(ostream&out, Module*mod); /* * $Log: pform.h,v $ + * Revision 1.39 2000/05/06 15:41:57 steve + * Carry assignment strength to pform. + * * Revision 1.38 2000/04/01 19:31:57 steve * Named events as far as the pform. * diff --git a/pform_dump.cc b/pform_dump.cc index 3955be209..0898d16ee 100644 --- a/pform_dump.cc +++ b/pform_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: pform_dump.cc,v 1.56 2000/05/04 03:37:59 steve Exp $" +#ident "$Id: pform_dump.cc,v 1.57 2000/05/06 15:41:57 steve Exp $" #endif /* @@ -44,6 +44,30 @@ ostream& operator << (ostream&o, const PDelays&d) return o; } +ostream& operator<< (ostream&o, PGate::strength_t str) +{ + switch (str) { + case PGate::HIGHZ: + o << "highz"; + break; + case PGate::WEAK: + o << "weak"; + break; + case PGate::PULL: + o << "pull"; + break; + case PGate::STRONG: + o << "strong"; + break; + case PGate::SUPPLY: + o << "supply"; + break; + default: + assert(0); + } + return o; +} + void PExpr::dump(ostream&out) const { out << typeid(*this).name(); @@ -252,7 +276,7 @@ void PGate::dump(ostream&out) const void PGAssign::dump(ostream&out) const { - out << " assign "; + out << " assign (" << strength0() << "0 " << strength1() << "1) "; dump_delays(out); out << " " << *pin(0) << " = " << *pin(1) << ";" << endl; } @@ -273,6 +297,7 @@ void PGBuiltin::dump(ostream&out) const out << " builtin gate "; } + out << "(" << strength0() << "0 " << strength1() << "1) "; dump_delays(out); out << " " << get_name(); @@ -748,6 +773,9 @@ void PUdp::dump(ostream&out) const /* * $Log: pform_dump.cc,v $ + * Revision 1.57 2000/05/06 15:41:57 steve + * Carry assignment strength to pform. + * * Revision 1.56 2000/05/04 03:37:59 steve * Add infrastructure for system functions, move * $time to that structure and add $random.