2000-09-02 22:54:20 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2000 Stephen Williams (steve@icarus.com)
|
|
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
|
|
|
|
#if !defined(WINNT) && !defined(macintosh)
|
2000-10-18 22:04:39 +02:00
|
|
|
#ident "$Id: net_assign.cc,v 1.6 2000/10/18 20:04:39 steve Exp $"
|
2000-09-02 22:54:20 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# include "netlist.h"
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* NetAssign
|
|
|
|
|
*/
|
|
|
|
|
|
2000-09-20 04:53:14 +02:00
|
|
|
unsigned count_lval_width(const NetAssign_*idx)
|
|
|
|
|
{
|
|
|
|
|
unsigned wid = 0;
|
|
|
|
|
while (idx) {
|
|
|
|
|
wid += idx->lwidth();
|
|
|
|
|
idx = idx->more;
|
|
|
|
|
}
|
|
|
|
|
return wid;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-02 22:54:20 +02:00
|
|
|
NetAssign_::NetAssign_(const string&n, unsigned w)
|
|
|
|
|
: NetNode(n, w), bmux_(0)
|
|
|
|
|
{
|
|
|
|
|
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1) {
|
|
|
|
|
pin(idx).set_dir(Link::OUTPUT);
|
|
|
|
|
pin(idx).set_name("P", idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-10 04:18:16 +02:00
|
|
|
more = 0;
|
2000-09-02 22:54:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetAssign_::~NetAssign_()
|
|
|
|
|
{
|
2000-09-10 04:18:16 +02:00
|
|
|
assert( more == 0 );
|
2000-09-02 22:54:20 +02:00
|
|
|
if (bmux_) delete bmux_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetAssign_::set_bmux(NetExpr*r)
|
|
|
|
|
{
|
|
|
|
|
assert(bmux_ == 0);
|
|
|
|
|
bmux_ = r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetExpr* NetAssign_::bmux() const
|
|
|
|
|
{
|
|
|
|
|
return bmux_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-07 02:06:53 +02:00
|
|
|
unsigned NetAssign_::lwidth() const
|
|
|
|
|
{
|
|
|
|
|
if (bmux_) return 1;
|
|
|
|
|
else return pin_count();
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-02 22:54:20 +02:00
|
|
|
NetAssignBase::NetAssignBase(NetAssign_*lv, NetExpr*rv)
|
|
|
|
|
: lval_(lv), rval_(rv)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetAssignBase::~NetAssignBase()
|
|
|
|
|
{
|
|
|
|
|
if (rval_) delete rval_;
|
2000-09-10 04:18:16 +02:00
|
|
|
while (lval_) {
|
|
|
|
|
NetAssign_*tmp = lval_;
|
|
|
|
|
lval_ = tmp->more;
|
|
|
|
|
tmp->more = 0;
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
2000-09-02 22:54:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetExpr* NetAssignBase::rval()
|
|
|
|
|
{
|
|
|
|
|
return rval_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetExpr* NetAssignBase::rval() const
|
|
|
|
|
{
|
|
|
|
|
return rval_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetAssignBase::set_rval(NetExpr*r)
|
|
|
|
|
{
|
|
|
|
|
if (rval_) delete rval_;
|
|
|
|
|
rval_ = r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetAssign_* NetAssignBase::l_val(unsigned idx)
|
|
|
|
|
{
|
2000-09-10 04:18:16 +02:00
|
|
|
NetAssign_*cur = lval_;
|
|
|
|
|
while (idx > 0) {
|
|
|
|
|
if (cur == 0)
|
|
|
|
|
return cur;
|
|
|
|
|
|
|
|
|
|
cur = cur->more;
|
|
|
|
|
idx -= 1;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-02 22:54:20 +02:00
|
|
|
assert(idx == 0);
|
2000-09-10 04:18:16 +02:00
|
|
|
return cur;
|
2000-09-02 22:54:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetAssign_* NetAssignBase::l_val(unsigned idx) const
|
|
|
|
|
{
|
2000-09-10 04:18:16 +02:00
|
|
|
const NetAssign_*cur = lval_;
|
|
|
|
|
while (idx > 0) {
|
|
|
|
|
if (cur == 0)
|
|
|
|
|
return cur;
|
|
|
|
|
|
|
|
|
|
cur = cur->more;
|
|
|
|
|
idx -= 1;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-02 22:54:20 +02:00
|
|
|
assert(idx == 0);
|
2000-09-10 04:18:16 +02:00
|
|
|
return cur;
|
2000-09-02 22:54:20 +02:00
|
|
|
}
|
|
|
|
|
|
2000-10-18 22:04:39 +02:00
|
|
|
unsigned NetAssignBase::l_val_count() const
|
|
|
|
|
{
|
|
|
|
|
const NetAssign_*cur = lval_;
|
|
|
|
|
unsigned cnt = 0;
|
|
|
|
|
while (cur) {
|
|
|
|
|
cnt += 1;
|
|
|
|
|
cur = cur->more;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-07 02:06:53 +02:00
|
|
|
unsigned NetAssignBase::lwidth() const
|
|
|
|
|
{
|
2000-09-10 04:18:16 +02:00
|
|
|
unsigned sum = 0;
|
|
|
|
|
for (NetAssign_*cur = lval_ ; cur ; cur = cur->more)
|
|
|
|
|
sum += cur->lwidth();
|
|
|
|
|
return sum;
|
2000-09-07 02:06:53 +02:00
|
|
|
}
|
|
|
|
|
|
2000-09-02 22:54:20 +02:00
|
|
|
|
2000-09-03 01:40:12 +02:00
|
|
|
NetAssign::NetAssign(NetAssign_*lv, NetExpr*rv)
|
|
|
|
|
: NetAssignBase(lv, rv)
|
2000-09-02 22:54:20 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetAssign::~NetAssign()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-03 01:40:12 +02:00
|
|
|
NetAssignNB::NetAssignNB(NetAssign_*lv, NetExpr*rv)
|
|
|
|
|
: NetAssignBase(lv, rv)
|
2000-09-02 22:54:20 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetAssignNB::~NetAssignNB()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* $Log: net_assign.cc,v $
|
2000-10-18 22:04:39 +02:00
|
|
|
* Revision 1.6 2000/10/18 20:04:39 steve
|
|
|
|
|
* Add ivl_lval_t and support for assignment l-values.
|
|
|
|
|
*
|
2000-09-20 04:53:14 +02:00
|
|
|
* Revision 1.5 2000/09/20 02:53:15 steve
|
|
|
|
|
* Correctly measure comples l-values of assignments.
|
|
|
|
|
*
|
2000-09-10 04:18:16 +02:00
|
|
|
* Revision 1.4 2000/09/10 02:18:16 steve
|
|
|
|
|
* elaborate complex l-values
|
|
|
|
|
*
|
2000-09-07 02:06:53 +02:00
|
|
|
* Revision 1.3 2000/09/07 00:06:53 steve
|
|
|
|
|
* encapsulate access to the l-value expected width.
|
|
|
|
|
*
|
2000-09-03 01:40:12 +02:00
|
|
|
* Revision 1.2 2000/09/02 23:40:13 steve
|
|
|
|
|
* Pull NetAssign_ creation out of constructors.
|
|
|
|
|
*
|
2000-09-02 22:54:20 +02:00
|
|
|
* Revision 1.1 2000/09/02 20:54:20 steve
|
|
|
|
|
* Rearrange NetAssign to make NetAssign_ separate.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|