Carry assignment strength to pform.

This commit is contained in:
steve 2000-05-06 15:41:56 +00:00
parent 43643ba98f
commit ca2fd41bb6
6 changed files with 146 additions and 17 deletions

View File

@ -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<PExpr*>*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

20
PGate.h
View File

@ -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<PExpr*>*pins,
const svector<PExpr*>*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<string,string> attributes;
virtual void dump(ostream&out) const;
@ -84,6 +97,8 @@ class PGate : public LineInfo {
PDelays delay_;
svector<PExpr*>*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.
*

54
parse.y
View File

@ -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<string>*strings;
struct str_pair_t drive;
PCase::Item*citem;
svector<PCase::Item*>*citems;
@ -97,6 +99,7 @@ extern void lex_end_table();
%token KK_attribute
%type <drive> drive_strength drive_strength_opt dr_strength0 dr_strength1
%type <letter> udp_input_sym udp_output_sym
%type <text> udp_input_list udp_sequ_entry udp_comb_entry
%type <strings> 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;

View File

@ -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<PExpr*>*del)
svector<PExpr*>*del,
struct str_pair_t str)
{
svector<PExpr*>*wires = new svector<PExpr*>(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<PExpr*>*alist,
svector<PExpr*>*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<string,Module*>&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.
*

11
pform.h
View File

@ -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<portname_t*>*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<PExpr*>*delays);
svector<PExpr*>*delays,
struct str_pair_t str);
extern void pform_make_pgassign_list(svector<PExpr*>*alist,
svector<PExpr*>*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.
*

View File

@ -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.