Detect scalar/vector declarion mismatch.

This commit is contained in:
steve 2002-01-26 05:28:28 +00:00
parent b906f4c0a1
commit 712080f7e0
4 changed files with 64 additions and 24 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: PWire.cc,v 1.7 2001/12/03 04:47:14 steve Exp $"
#ident "$Id: PWire.cc,v 1.8 2002/01/26 05:28:28 steve Exp $"
#endif
# include "config.h"
@ -39,14 +39,7 @@ NetNet::Type PWire::get_wire_type() const
{
return type_;
}
#if 0
string PWire::name() const
{
string name = hname_[0];
for (unsigned idx = 1 ; hname_[idx] ; idx += 1)
name = name + "." + hname_[idx];
}
#endif
const hname_t& PWire::path() const
{
return hname_;
@ -127,6 +120,9 @@ void PWire::set_memory_idx(PExpr*ldx, PExpr*rdx)
/*
* $Log: PWire.cc,v $
* Revision 1.8 2002/01/26 05:28:28 steve
* Detect scalar/vector declarion mismatch.
*
* Revision 1.7 2001/12/03 04:47:14 steve
* Parser and pform use hierarchical names as hname_t
* objects instead of encoded strings.

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: elab_sig.cc,v 1.19 2002/01/23 03:35:17 steve Exp $"
#ident "$Id: elab_sig.cc,v 1.20 2002/01/26 05:28:28 steve Exp $"
#endif
# include "config.h"
@ -390,6 +390,10 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
if (msb_.count()) {
svector<long>mnum (msb_.count());
svector<long>lnum (msb_.count());
/* There may be places where the signal is declared as a
scaler. Count those here, for consistency check
later. */
unsigned count_scalars = 0;
/* There may be multiple declarations of ranges, because
the symbol may have its range declared in i.e. input
@ -398,6 +402,14 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
for (unsigned idx = 0 ; idx < msb_.count() ; idx += 1) {
if (msb_[idx] == 0) {
count_scalars += 1;
assert(lsb_[idx] == 0);
mnum[idx] = 0;
lnum[idx] = 0;
continue;
}
NetEConst*tmp;
NetExpr*texpr = elab_and_eval(des, scope, msb_[idx]);
@ -428,6 +440,18 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
}
/* Check that the declarations were all scalar or all
vector. It is an error to mix them. Use the
count_scalars to know. */
if ((count_scalars > 0) && (count_scalars != msb_.count())) {
cerr << get_line() << ": error: Signal ``" << hname_
<< "'' declared both as a vector and a scalar."
<< endl;
des->errors += 1;
return;
}
/* Make sure all the values for msb and lsb match by
value. If not, report an error. */
for (unsigned idx = 1 ; idx < msb_.count() ; idx += 1) {
@ -495,6 +519,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
/*
* $Log: elab_sig.cc,v $
* Revision 1.20 2002/01/26 05:28:28 steve
* Detect scalar/vector declarion mismatch.
*
* Revision 1.19 2002/01/23 03:35:17 steve
* Detect incorrect function ports.
*

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.88 2002/01/12 04:03:39 steve Exp $"
#ident "$Id: pform.cc,v 1.89 2002/01/26 05:28:28 steve Exp $"
#endif
# include "config.h"
@ -401,8 +401,6 @@ static void pform_set_net_range(const char*name,
const svector<PExpr*>*range,
bool signed_flag)
{
assert(range);
assert(range->count() == 2);
PWire*cur = pform_cur_module->get_wire(hier_name(name));
if (cur == 0) {
@ -410,9 +408,17 @@ static void pform_set_net_range(const char*name,
return;
}
assert((*range)[0]);
assert((*range)[1]);
cur->set_range((*range)[0], (*range)[1]);
if (range == 0) {
/* This is the special case that we really mean a
scalar. Set a fake range. */
cur->set_range(0, 0);
} else {
assert(range->count() == 2);
assert((*range)[0]);
assert((*range)[1]);
cur->set_range((*range)[0], (*range)[1]);
}
cur->set_signed(signed_flag);
}
@ -756,8 +762,7 @@ void pform_makewire(const vlltype&li,
; cur ++ ) {
char*txt = *cur;
pform_makewire(li, txt, type);
if (range)
pform_set_net_range(txt, range, false);
pform_set_net_range(txt, range, false);
free(txt);
}
@ -1155,6 +1160,9 @@ int pform_parse(const char*path, FILE*file)
/*
* $Log: pform.cc,v $
* Revision 1.89 2002/01/26 05:28:28 steve
* Detect scalar/vector declarion mismatch.
*
* Revision 1.88 2002/01/12 04:03:39 steve
* Drive strengths for continuous assignments.
*

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.68 2001/12/03 04:47:15 steve Exp $"
#ident "$Id: pform_dump.cc,v 1.69 2002/01/26 05:28:28 steve Exp $"
#endif
# include "config.h"
@ -227,11 +227,17 @@ void PWire::dump(ostream&out) const
assert(msb_.count() == lsb_.count());
for (unsigned idx = 0 ; idx < msb_.count() ; idx += 1) {
assert(msb_[idx]);
if (lsb_[idx])
out << " [" << *msb_[idx] << ":" << *lsb_[idx] << "]";
else
out << " [" << *msb_[idx] << "]";
if (msb_[idx] == 0) {
assert(lsb_[idx] == 0);
out << " <scalar>";
} else {
if (lsb_[idx])
out << " [" << *msb_[idx] << ":" << *lsb_[idx] << "]";
else
out << " [" << *msb_[idx] << "]";
}
}
out << " " << hname_;
@ -814,6 +820,9 @@ void PUdp::dump(ostream&out) const
/*
* $Log: pform_dump.cc,v $
* Revision 1.69 2002/01/26 05:28:28 steve
* Detect scalar/vector declarion mismatch.
*
* Revision 1.68 2001/12/03 04:47:15 steve
* Parser and pform use hierarchical names as hname_t
* objects instead of encoded strings.