Support elaborate_net for PEString objects.
This commit is contained in:
parent
fd5c0cfa28
commit
03aebd7525
20
PExpr.cc
20
PExpr.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: PExpr.cc,v 1.28 2001/12/03 04:47:14 steve Exp $"
|
||||
#ident "$Id: PExpr.cc,v 1.29 2001/12/30 21:32:03 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
|
|
@ -46,18 +46,6 @@ bool PExpr::is_constant(Module*) const
|
|||
return false;
|
||||
}
|
||||
|
||||
NetNet* PExpr::elaborate_net(Design*des, NetScope*scope, unsigned,
|
||||
unsigned long,
|
||||
unsigned long,
|
||||
unsigned long,
|
||||
Link::strength_t,
|
||||
Link::strength_t) const
|
||||
{
|
||||
cerr << get_line() << ": error: Unable to elaborate `"
|
||||
<< *this << "' as gates." << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
NetNet* PExpr::elaborate_lnet(Design*des, NetScope*) const
|
||||
{
|
||||
cerr << get_line() << ": error: expression not valid in assign l-value: "
|
||||
|
|
@ -216,13 +204,14 @@ bool PENumber::is_constant(Module*) const
|
|||
return true;
|
||||
}
|
||||
|
||||
PEString::PEString(const string&s)
|
||||
PEString::PEString(char*s)
|
||||
: text_(s)
|
||||
{
|
||||
}
|
||||
|
||||
PEString::~PEString()
|
||||
{
|
||||
delete[]text_;
|
||||
}
|
||||
|
||||
string PEString::value() const
|
||||
|
|
@ -267,6 +256,9 @@ bool PEUnary::is_constant(Module*m) const
|
|||
|
||||
/*
|
||||
* $Log: PExpr.cc,v $
|
||||
* Revision 1.29 2001/12/30 21:32:03 steve
|
||||
* Support elaborate_net for PEString objects.
|
||||
*
|
||||
* Revision 1.28 2001/12/03 04:47:14 steve
|
||||
* Parser and pform use hierarchical names as hname_t
|
||||
* objects instead of encoded strings.
|
||||
|
|
|
|||
23
PExpr.h
23
PExpr.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: PExpr.h,v 1.53 2001/12/03 04:47:14 steve Exp $"
|
||||
#ident "$Id: PExpr.h,v 1.54 2001/12/30 21:32:03 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <string>
|
||||
|
|
@ -285,21 +285,35 @@ class PENumber : public PExpr {
|
|||
verinum*const value_;
|
||||
};
|
||||
|
||||
/*
|
||||
* This represents a string constant in an expression.
|
||||
*
|
||||
* The s parameter to the PEString constructor is a C string that this
|
||||
* class instance will take for its own. The caller should not delete
|
||||
* the string, the destructor will do it.
|
||||
*/
|
||||
class PEString : public PExpr {
|
||||
|
||||
public:
|
||||
explicit PEString(const string&s);
|
||||
explicit PEString(char*s);
|
||||
~PEString();
|
||||
|
||||
string value() const;
|
||||
virtual void dump(ostream&) const;
|
||||
virtual NetNet* elaborate_net(Design*des, NetScope*scope,
|
||||
unsigned width,
|
||||
unsigned long rise,
|
||||
unsigned long fall,
|
||||
unsigned long decay,
|
||||
Link::strength_t drive0,
|
||||
Link::strength_t drive1) const;
|
||||
virtual NetEConst*elaborate_expr(Design*des, NetScope*) const;
|
||||
virtual NetEConst*elaborate_pexpr(Design*des, NetScope*sc) const;
|
||||
|
||||
virtual bool is_constant(Module*) const;
|
||||
|
||||
private:
|
||||
const string text_;
|
||||
char*text_;
|
||||
};
|
||||
|
||||
class PEUnary : public PExpr {
|
||||
|
|
@ -449,6 +463,9 @@ class PECallFunction : public PExpr {
|
|||
|
||||
/*
|
||||
* $Log: PExpr.h,v $
|
||||
* Revision 1.54 2001/12/30 21:32:03 steve
|
||||
* Support elaborate_net for PEString objects.
|
||||
*
|
||||
* Revision 1.53 2001/12/03 04:47:14 steve
|
||||
* Parser and pform use hierarchical names as hname_t
|
||||
* objects instead of encoded strings.
|
||||
|
|
|
|||
66
elab_net.cc
66
elab_net.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: elab_net.cc,v 1.82 2001/12/03 04:47:14 steve Exp $"
|
||||
#ident "$Id: elab_net.cc,v 1.83 2001/12/30 21:32:03 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
|
|
@ -29,6 +29,18 @@
|
|||
|
||||
# include <iostream>
|
||||
|
||||
NetNet* PExpr::elaborate_net(Design*des, NetScope*scope, unsigned,
|
||||
unsigned long,
|
||||
unsigned long,
|
||||
unsigned long,
|
||||
Link::strength_t,
|
||||
Link::strength_t) const
|
||||
{
|
||||
cerr << get_line() << ": error: Unable to elaborate `"
|
||||
<< *this << "' as gates." << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Elaborating binary operations generally involves elaborating the
|
||||
* left and right expressions, then making an output wire and
|
||||
|
|
@ -1539,6 +1551,55 @@ NetNet* PENumber::elaborate_net(Design*des, NetScope*scope,
|
|||
return net;
|
||||
}
|
||||
|
||||
/*
|
||||
* A string is a NetEConst node that is made of the ASCII bits of the
|
||||
* string instead of the bits of a number. In fact, a string is just
|
||||
* another numeric notation.
|
||||
*/
|
||||
NetNet* PEString::elaborate_net(Design*des, NetScope*scope,
|
||||
unsigned lwidth,
|
||||
unsigned long rise,
|
||||
unsigned long fall,
|
||||
unsigned long decay,
|
||||
Link::strength_t drive0,
|
||||
Link::strength_t drive1) const
|
||||
{
|
||||
unsigned strbits = strlen(text_) * 8;
|
||||
NetNet*net;
|
||||
|
||||
/* If we are constrained by a l-value size, then just make a
|
||||
number constant with the correct size and set as many bits
|
||||
in that constant as make sense. Pad excess with zeros. */
|
||||
if (lwidth > 0) {
|
||||
net = new NetNet(scope, scope->local_hsymbol(),
|
||||
NetNet::IMPLICIT, lwidth);
|
||||
|
||||
} else {
|
||||
net = new NetNet(scope, scope->local_hsymbol(),
|
||||
NetNet::IMPLICIT, strbits);
|
||||
}
|
||||
net->local_flag(true);
|
||||
|
||||
/* Make a verinum that is filled with the 0 pad. */
|
||||
verinum num(verinum::V0, net->pin_count());
|
||||
|
||||
unsigned idx;
|
||||
for (idx = 0 ; idx < num.len() && idx < strbits; idx += 1) {
|
||||
char byte = text_[strbits/8 - 1 - idx/8];
|
||||
char mask = 1<<(idx%8);
|
||||
num.set(idx, (byte & mask)? verinum::V1 : verinum::V0);
|
||||
}
|
||||
|
||||
NetConst*tmp = new NetConst(scope, scope->local_hsymbol(), num);
|
||||
for (idx = 0 ; idx < net->pin_count() ; idx += 1) {
|
||||
tmp->pin(idx).drive0(drive0);
|
||||
tmp->pin(idx).drive1(drive1);
|
||||
connect(net->pin(idx), tmp->pin(idx));
|
||||
}
|
||||
|
||||
des->add_node(tmp);
|
||||
return net;
|
||||
}
|
||||
|
||||
/*
|
||||
* Elaborate the ternary operator in a netlist by creating a LPM_MUX
|
||||
|
|
@ -1880,6 +1941,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
|
|||
|
||||
/*
|
||||
* $Log: elab_net.cc,v $
|
||||
* Revision 1.83 2001/12/30 21:32:03 steve
|
||||
* Support elaborate_net for PEString objects.
|
||||
*
|
||||
* Revision 1.82 2001/12/03 04:47:14 steve
|
||||
* Parser and pform use hierarchical names as hname_t
|
||||
* objects instead of encoded strings.
|
||||
|
|
|
|||
3
parse.y
3
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.141 2001/12/14 02:05:13 steve Exp $"
|
||||
#ident "$Id: parse.y,v 1.142 2001/12/30 21:32:03 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
|
|
@ -819,7 +819,6 @@ expr_primary
|
|||
tmp->set_file(@1.text);
|
||||
tmp->set_lineno(@1.first_line);
|
||||
$$ = tmp;
|
||||
delete $1;
|
||||
}
|
||||
| identifier
|
||||
{ PEIdent*tmp = new PEIdent(*$1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue