Skip to content

Commit

Permalink
Pad r-values in certain assignments.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Sep 12, 1999
1 parent 1c238f1 commit 25d6912
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
19 changes: 18 additions & 1 deletion elaborate.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: elaborate.cc,v 1.81 1999/09/10 04:04:06 steve Exp $"
#ident "$Id: elaborate.cc,v 1.82 1999/09/12 01:16:51 steve Exp $"
#endif

/*
Expand Down Expand Up @@ -1609,6 +1609,20 @@ NetProc* PAssignNB::elaborate(Design*des, const string&path) const
NetAssignNB*cur;
if (mux == 0) {
unsigned wid = msb - lsb + 1;

rv->set_width(wid);

/* If the l-value is larger then the r-value, then pad
the r-value with 0s. */
if (wid > rv->expr_width()) {
verinum pad(verinum::V0, wid-rv->expr_width());
NetEConst*co = new NetEConst(pad);
NetEConcat*cc = new NetEConcat(2);
cc->set(0, co);
cc->set(1, rv);
cc->set_width(wid);
rv = cc;
}
cur = new NetAssignNB(des->local_symbol(path), des, wid, rv);
for (unsigned idx = 0 ; idx < wid ; idx += 1)
connect(cur->pin(idx), reg->pin(idx+lsb));
Expand Down Expand Up @@ -2320,6 +2334,9 @@ Design* elaborate(const map<string,Module*>&modules,

/*
* $Log: elaborate.cc,v $
* Revision 1.82 1999/09/12 01:16:51 steve
* Pad r-values in certain assignments.
*
* Revision 1.81 1999/09/10 04:04:06 steve
* Add ternary elaboration.
*
Expand Down
9 changes: 6 additions & 3 deletions netlist.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: netlist.cc,v 1.59 1999/09/11 04:43:17 steve Exp $"
#ident "$Id: netlist.cc,v 1.60 1999/09/12 01:16:51 steve Exp $"
#endif

# include <cassert>
Expand Down Expand Up @@ -832,8 +832,8 @@ bool NetEBinary::set_width(unsigned w)
switch (op_) {
case 'a': // logical and (&&)
case 'o': // logical or (||)
assert(w == 1);
expr_width(w);
expr_width(1);
flag = false;
break;

case 'l': // left shift (<<)
Expand Down Expand Up @@ -1762,6 +1762,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))

/*
* $Log: netlist.cc,v $
* Revision 1.60 1999/09/12 01:16:51 steve
* Pad r-values in certain assignments.
*
* Revision 1.59 1999/09/11 04:43:17 steve
* Support ternary and <= operators in vvm.
*
Expand Down

0 comments on commit 25d6912

Please sign in to comment.