1998-11-04 00:28:49 +01:00
|
|
|
/*
|
2000-02-23 03:56:53 +01:00
|
|
|
* Copyright (c) 1998-2000 Stephen Williams (steve@icarus.com)
|
1998-11-04 00:28:49 +01:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
2002-08-12 03:34:58 +02:00
|
|
|
#ifdef HAVE_CVS_IDENT
|
2002-08-19 02:06:11 +02:00
|
|
|
#ident "$Id: netlist.cc,v 1.198 2002/08/19 00:06:12 steve Exp $"
|
1998-11-04 00:28:49 +01:00
|
|
|
#endif
|
|
|
|
|
|
2001-07-25 05:10:48 +02:00
|
|
|
# include "config.h"
|
|
|
|
|
|
|
|
|
|
# include <iostream>
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
# include <cassert>
|
1998-11-07 20:17:10 +01:00
|
|
|
# include <typeinfo>
|
1998-11-04 00:28:49 +01:00
|
|
|
# include "netlist.h"
|
1999-10-05 06:02:10 +02:00
|
|
|
# include "netmisc.h"
|
1998-11-04 00:28:49 +01:00
|
|
|
|
1998-12-01 01:42:13 +01:00
|
|
|
ostream& operator<< (ostream&o, NetNet::Type t)
|
|
|
|
|
{
|
|
|
|
|
switch (t) {
|
|
|
|
|
case NetNet::IMPLICIT:
|
|
|
|
|
o << "wire /*implicit*/";
|
|
|
|
|
break;
|
1999-07-31 21:14:47 +02:00
|
|
|
case NetNet::IMPLICIT_REG:
|
|
|
|
|
o << "reg /*implicit*/";
|
|
|
|
|
break;
|
1998-12-01 01:42:13 +01:00
|
|
|
case NetNet::REG:
|
|
|
|
|
o << "reg";
|
|
|
|
|
break;
|
|
|
|
|
case NetNet::SUPPLY0:
|
|
|
|
|
o << "supply0";
|
|
|
|
|
break;
|
|
|
|
|
case NetNet::SUPPLY1:
|
|
|
|
|
o << "supply1";
|
|
|
|
|
break;
|
|
|
|
|
case NetNet::TRI:
|
|
|
|
|
o << "tri";
|
|
|
|
|
break;
|
|
|
|
|
case NetNet::TRI0:
|
|
|
|
|
o << "tri0";
|
|
|
|
|
break;
|
|
|
|
|
case NetNet::TRI1:
|
|
|
|
|
o << "tri1";
|
|
|
|
|
break;
|
|
|
|
|
case NetNet::TRIAND:
|
|
|
|
|
o << "triand";
|
|
|
|
|
break;
|
|
|
|
|
case NetNet::TRIOR:
|
|
|
|
|
o << "trior";
|
|
|
|
|
break;
|
|
|
|
|
case NetNet::WAND:
|
|
|
|
|
o << "wand";
|
|
|
|
|
break;
|
|
|
|
|
case NetNet::WOR:
|
|
|
|
|
o << "wor";
|
|
|
|
|
break;
|
|
|
|
|
case NetNet::WIRE:
|
|
|
|
|
o << "wire";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
unsigned count_inputs(const Link&pin)
|
1998-12-02 05:37:13 +01:00
|
|
|
{
|
2000-06-25 21:59:41 +02:00
|
|
|
unsigned count = 0;
|
2000-06-25 00:55:19 +02:00
|
|
|
|
2000-06-25 21:59:41 +02:00
|
|
|
const Nexus*nex = pin.nexus();
|
|
|
|
|
for (const Link*clnk = nex->first_nlink()
|
|
|
|
|
; clnk ; clnk = clnk->next_nlink()) {
|
2000-06-25 00:55:19 +02:00
|
|
|
const NetObj*cur;
|
|
|
|
|
unsigned cpin;
|
|
|
|
|
clnk->cur_link(cur, cpin);
|
2000-05-07 06:37:55 +02:00
|
|
|
if (cur->pin(cpin).get_dir() == Link::INPUT)
|
1998-12-02 05:37:13 +01:00
|
|
|
count += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
unsigned count_outputs(const Link&pin)
|
1998-12-02 05:37:13 +01:00
|
|
|
{
|
2000-06-25 21:59:41 +02:00
|
|
|
unsigned count = 0;
|
2000-06-25 00:55:19 +02:00
|
|
|
|
2000-06-25 21:59:41 +02:00
|
|
|
const Nexus*nex = pin.nexus();
|
|
|
|
|
for (const Link*clnk = nex->first_nlink()
|
|
|
|
|
; clnk ; clnk = clnk->next_nlink()) {
|
2000-06-25 00:55:19 +02:00
|
|
|
const NetObj*cur;
|
|
|
|
|
unsigned cpin;
|
|
|
|
|
clnk->cur_link(cur, cpin);
|
2000-05-07 06:37:55 +02:00
|
|
|
if (cur->pin(cpin).get_dir() == Link::OUTPUT)
|
1998-12-02 05:37:13 +01:00
|
|
|
count += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
unsigned count_signals(const Link&pin)
|
1998-12-07 05:53:16 +01:00
|
|
|
{
|
|
|
|
|
unsigned count = 0;
|
|
|
|
|
|
2000-06-25 21:59:41 +02:00
|
|
|
const Nexus*nex = pin.nexus();
|
|
|
|
|
for (const Link*clnk = nex->first_nlink()
|
|
|
|
|
; clnk ; clnk = clnk->next_nlink()) {
|
2000-06-25 00:55:19 +02:00
|
|
|
const NetObj*cur;
|
|
|
|
|
unsigned cpin;
|
|
|
|
|
clnk->cur_link(cur, cpin);
|
1998-12-07 05:53:16 +01:00
|
|
|
if (dynamic_cast<const NetNet*>(cur))
|
|
|
|
|
count += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
const NetNet* find_link_signal(const NetObj*net, unsigned pin, unsigned&bidx)
|
|
|
|
|
{
|
2000-06-25 21:59:41 +02:00
|
|
|
const Nexus*nex = net->pin(pin).nexus();
|
|
|
|
|
|
|
|
|
|
for (const Link*clnk = nex->first_nlink()
|
|
|
|
|
; clnk ; clnk = clnk->next_nlink()) {
|
2000-06-25 00:55:19 +02:00
|
|
|
|
|
|
|
|
const NetObj*cur;
|
|
|
|
|
unsigned cpin;
|
|
|
|
|
clnk->cur_link(cur, cpin);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
const NetNet*sig = dynamic_cast<const NetNet*>(cur);
|
|
|
|
|
if (sig) {
|
|
|
|
|
bidx = cpin;
|
|
|
|
|
return sig;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link* find_next_output(Link*lnk)
|
1999-11-19 04:02:25 +01:00
|
|
|
{
|
2000-06-25 21:59:41 +02:00
|
|
|
Link*cur = lnk->next_nlink();
|
|
|
|
|
while (cur != lnk) {
|
2000-05-07 06:37:55 +02:00
|
|
|
if (cur->get_dir() == Link::OUTPUT)
|
1999-11-19 04:02:25 +01:00
|
|
|
return cur;
|
|
|
|
|
|
2000-06-25 21:59:41 +02:00
|
|
|
cur = cur->next_nlink();
|
|
|
|
|
if (cur == 0)
|
|
|
|
|
cur = lnk->nexus()->first_nlink();
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-19 04:02:25 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-07 01:46:50 +02:00
|
|
|
NetObj::NetObj(NetScope*s, const string&n, unsigned np)
|
|
|
|
|
: scope_(s), npins_(np), delay1_(0), delay2_(0), delay3_(0)
|
1998-11-04 00:28:49 +01:00
|
|
|
{
|
2000-08-27 17:51:50 +02:00
|
|
|
name_ = new char[n.length()+1];
|
|
|
|
|
strcpy(name_, n.c_str());
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
pins_ = new Link[npins_];
|
|
|
|
|
for (unsigned idx = 0 ; idx < npins_ ; idx += 1) {
|
|
|
|
|
pins_[idx].node_ = this;
|
|
|
|
|
pins_[idx].pin_ = idx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-01 02:27:34 +02:00
|
|
|
NetObj::NetObj(NetScope*s, const char*n, unsigned np)
|
|
|
|
|
: scope_(s), npins_(np), delay1_(0), delay2_(0), delay3_(0)
|
|
|
|
|
{
|
|
|
|
|
name_ = new char[strlen(n)+1];
|
|
|
|
|
strcpy(name_, n);
|
|
|
|
|
|
|
|
|
|
pins_ = new Link[npins_];
|
|
|
|
|
for (unsigned idx = 0 ; idx < npins_ ; idx += 1) {
|
|
|
|
|
pins_[idx].node_ = this;
|
|
|
|
|
pins_[idx].pin_ = idx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
NetObj::~NetObj()
|
|
|
|
|
{
|
2000-08-27 17:51:50 +02:00
|
|
|
delete[]name_;
|
1998-11-04 00:28:49 +01:00
|
|
|
delete[]pins_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-07 01:46:50 +02:00
|
|
|
NetScope* NetObj::scope()
|
|
|
|
|
{
|
|
|
|
|
return scope_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetScope* NetObj::scope() const
|
|
|
|
|
{
|
|
|
|
|
return scope_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetObj::pin(unsigned idx)
|
1999-09-13 05:10:59 +02:00
|
|
|
{
|
|
|
|
|
assert(idx < npins_);
|
|
|
|
|
return pins_[idx];
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetObj::pin(unsigned idx) const
|
1999-09-13 05:10:59 +02:00
|
|
|
{
|
|
|
|
|
assert(idx < npins_);
|
|
|
|
|
return pins_[idx];
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-07 21:45:42 +02:00
|
|
|
NetNode::NetNode(NetScope*s, const string&n, unsigned npins)
|
|
|
|
|
: NetObj(s, n, npins), node_next_(0), node_prev_(0), design_(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-01 02:27:34 +02:00
|
|
|
NetNode::NetNode(NetScope*s, const char*n, unsigned npins)
|
|
|
|
|
: NetObj(s, n, npins), node_next_(0), node_prev_(0), design_(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
NetNode::~NetNode()
|
|
|
|
|
{
|
|
|
|
|
if (design_)
|
|
|
|
|
design_->del_node(this);
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-27 20:07:57 +01:00
|
|
|
NetNet::NetNet(NetScope*s, const string&n, Type t, unsigned npins)
|
2000-10-07 01:46:50 +02:00
|
|
|
: NetObj(s, n, npins), sig_next_(0), sig_prev_(0),
|
2000-12-11 01:31:43 +01:00
|
|
|
type_(t), port_type_(NOT_A_PORT), signed_(false), msb_(npins-1), lsb_(0),
|
2002-05-26 03:39:02 +02:00
|
|
|
local_flag_(false), eref_count_(0), lref_count_(0)
|
1999-04-19 03:59:36 +02:00
|
|
|
{
|
2000-10-07 01:46:50 +02:00
|
|
|
assert(s);
|
2000-05-02 02:58:11 +02:00
|
|
|
|
2002-08-19 02:06:11 +02:00
|
|
|
release_list_ = 0;
|
|
|
|
|
|
2000-07-14 08:12:56 +02:00
|
|
|
verinum::V init_value = verinum::Vz;
|
2001-07-07 05:01:37 +02:00
|
|
|
Link::DIR dir = Link::PASSIVE;
|
|
|
|
|
|
2000-07-14 08:12:56 +02:00
|
|
|
switch (t) {
|
|
|
|
|
case REG:
|
|
|
|
|
case IMPLICIT_REG:
|
|
|
|
|
init_value = verinum::Vx;
|
2001-07-07 05:01:37 +02:00
|
|
|
dir = Link::OUTPUT;
|
2000-07-14 08:12:56 +02:00
|
|
|
break;
|
2000-11-20 01:58:40 +01:00
|
|
|
case SUPPLY0:
|
|
|
|
|
init_value = verinum::V0;
|
2001-07-07 05:01:37 +02:00
|
|
|
dir = Link::OUTPUT;
|
2000-11-20 01:58:40 +01:00
|
|
|
break;
|
|
|
|
|
case SUPPLY1:
|
|
|
|
|
init_value = verinum::V1;
|
2001-07-07 05:01:37 +02:00
|
|
|
dir = Link::OUTPUT;
|
2000-11-20 01:58:40 +01:00
|
|
|
break;
|
2000-07-14 08:12:56 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-28 02:16:18 +01:00
|
|
|
for (unsigned idx = 0 ; idx < npins ; idx += 1) {
|
|
|
|
|
pin(idx).set_name("P", idx);
|
2001-07-07 05:01:37 +02:00
|
|
|
pin(idx).set_dir(dir);
|
2000-07-14 08:12:56 +02:00
|
|
|
pin(idx).set_init(init_value);
|
1999-11-28 02:16:18 +01:00
|
|
|
}
|
2000-05-02 02:58:11 +02:00
|
|
|
|
2000-10-07 01:46:50 +02:00
|
|
|
scope()->add_signal(this);
|
1999-04-19 03:59:36 +02:00
|
|
|
}
|
|
|
|
|
|
1999-11-27 20:07:57 +01:00
|
|
|
NetNet::NetNet(NetScope*s, const string&n, Type t, long ms, long ls)
|
2000-10-07 01:46:50 +02:00
|
|
|
: NetObj(s, n, ((ms>ls)?ms-ls:ls-ms) + 1), sig_next_(0),
|
|
|
|
|
sig_prev_(0), type_(t),
|
2000-12-11 01:31:43 +01:00
|
|
|
port_type_(NOT_A_PORT), signed_(false), msb_(ms), lsb_(ls),
|
2002-05-26 03:39:02 +02:00
|
|
|
local_flag_(false), eref_count_(0), lref_count_(0)
|
1999-04-19 03:59:36 +02:00
|
|
|
{
|
2000-10-07 01:46:50 +02:00
|
|
|
assert(s);
|
2000-05-02 02:58:11 +02:00
|
|
|
|
2002-08-19 02:06:11 +02:00
|
|
|
release_list_ = 0;
|
|
|
|
|
|
2000-07-14 08:12:56 +02:00
|
|
|
verinum::V init_value = verinum::Vz;
|
2001-08-26 01:50:02 +02:00
|
|
|
Link::DIR dir = Link::PASSIVE;
|
|
|
|
|
|
2000-07-14 08:12:56 +02:00
|
|
|
switch (t) {
|
|
|
|
|
case REG:
|
|
|
|
|
case IMPLICIT_REG:
|
|
|
|
|
init_value = verinum::Vx;
|
2001-08-26 01:50:02 +02:00
|
|
|
dir = Link::OUTPUT;
|
2000-07-14 08:12:56 +02:00
|
|
|
break;
|
2000-11-20 01:58:40 +01:00
|
|
|
case SUPPLY0:
|
|
|
|
|
init_value = verinum::V0;
|
2001-08-26 01:50:02 +02:00
|
|
|
dir = Link::OUTPUT;
|
2000-11-20 01:58:40 +01:00
|
|
|
break;
|
|
|
|
|
case SUPPLY1:
|
|
|
|
|
init_value = verinum::V1;
|
2001-08-26 01:50:02 +02:00
|
|
|
dir = Link::OUTPUT;
|
2000-11-20 01:58:40 +01:00
|
|
|
break;
|
2000-07-14 08:12:56 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-28 02:16:18 +01:00
|
|
|
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1) {
|
|
|
|
|
pin(idx).set_name("P", idx);
|
2001-08-26 01:50:02 +02:00
|
|
|
pin(idx).set_dir(dir);
|
2000-07-14 08:12:56 +02:00
|
|
|
pin(idx).set_init(init_value);
|
1999-11-28 02:16:18 +01:00
|
|
|
}
|
2000-05-02 02:58:11 +02:00
|
|
|
|
2000-10-07 01:46:50 +02:00
|
|
|
s->add_signal(this);
|
1999-04-19 03:59:36 +02:00
|
|
|
}
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
NetNet::~NetNet()
|
|
|
|
|
{
|
2000-11-30 00:16:18 +01:00
|
|
|
if (eref_count_ > 0) {
|
|
|
|
|
cerr << get_line() << ": internal error: attempt to delete "
|
|
|
|
|
<< "signal ``" << name() << "'' which has "
|
|
|
|
|
<< "expression references." << endl;
|
|
|
|
|
dump_net(cerr, 4);
|
|
|
|
|
}
|
1999-11-29 00:42:02 +01:00
|
|
|
assert(eref_count_ == 0);
|
2002-05-26 03:39:02 +02:00
|
|
|
if (lref_count_ > 0) {
|
|
|
|
|
cerr << get_line() << ": internal error: attempt to delete "
|
|
|
|
|
<< "signal ``" << name() << "'' which has "
|
|
|
|
|
<< "assign references." << endl;
|
|
|
|
|
dump_net(cerr, 4);
|
|
|
|
|
}
|
|
|
|
|
assert(lref_count_ == 0);
|
2000-10-07 01:46:50 +02:00
|
|
|
if (scope())
|
|
|
|
|
scope()->rem_signal(this);
|
2002-08-19 02:06:11 +02:00
|
|
|
|
|
|
|
|
/* Detach me from all the NetRelease objects that refer to me. */
|
|
|
|
|
while (release_list_) {
|
|
|
|
|
NetRelease*tmp = release_list_;
|
|
|
|
|
release_list_ = tmp->release_next_;
|
|
|
|
|
assert(tmp->lval_ == this);
|
|
|
|
|
tmp->lval_ = 0;
|
|
|
|
|
tmp->release_next_ = 0;
|
|
|
|
|
}
|
1999-11-27 20:07:57 +01:00
|
|
|
}
|
|
|
|
|
|
2000-09-24 17:44:44 +02:00
|
|
|
NetNet::Type NetNet::type() const
|
|
|
|
|
{
|
|
|
|
|
return type_;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-02 05:02:57 +02:00
|
|
|
void NetNet::type(NetNet::Type t)
|
|
|
|
|
{
|
|
|
|
|
if (type_ == t)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Link::DIR dir = Link::PASSIVE;
|
|
|
|
|
switch (t) {
|
|
|
|
|
case REG:
|
|
|
|
|
case IMPLICIT_REG:
|
|
|
|
|
dir = Link::OUTPUT;
|
|
|
|
|
break;
|
|
|
|
|
case SUPPLY0:
|
|
|
|
|
dir = Link::OUTPUT;
|
|
|
|
|
break;
|
|
|
|
|
case SUPPLY1:
|
|
|
|
|
dir = Link::OUTPUT;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type_ = t;
|
|
|
|
|
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1) {
|
|
|
|
|
pin(idx).set_dir(dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-24 17:44:44 +02:00
|
|
|
NetNet::PortType NetNet::port_type() const
|
|
|
|
|
{
|
|
|
|
|
return port_type_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetNet::port_type(NetNet::PortType t)
|
|
|
|
|
{
|
|
|
|
|
port_type_ = t;
|
|
|
|
|
}
|
|
|
|
|
|
2000-12-11 01:31:43 +01:00
|
|
|
bool NetNet::get_signed() const
|
|
|
|
|
{
|
|
|
|
|
return signed_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetNet::set_signed(bool flag)
|
|
|
|
|
{
|
|
|
|
|
signed_ = flag;
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-21 06:59:35 +02:00
|
|
|
bool NetNet::get_isint() const
|
|
|
|
|
{
|
|
|
|
|
return isint_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetNet::set_isint(bool flag)
|
|
|
|
|
{
|
|
|
|
|
isint_ = flag;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-24 17:44:44 +02:00
|
|
|
long NetNet::lsb() const
|
|
|
|
|
{
|
|
|
|
|
return lsb_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long NetNet::msb() const
|
|
|
|
|
{
|
|
|
|
|
return msb_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-13 05:10:59 +02:00
|
|
|
unsigned NetNet::sb_to_idx(long sb) const
|
|
|
|
|
{
|
|
|
|
|
if (msb_ >= lsb_)
|
|
|
|
|
return sb - lsb_;
|
|
|
|
|
else
|
|
|
|
|
return lsb_ - sb;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-29 00:42:02 +01:00
|
|
|
void NetNet::incr_eref()
|
|
|
|
|
{
|
|
|
|
|
eref_count_ += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetNet::decr_eref()
|
|
|
|
|
{
|
|
|
|
|
assert(eref_count_ > 0);
|
|
|
|
|
eref_count_ -= 1;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-26 03:39:02 +02:00
|
|
|
unsigned NetNet::peek_eref() const
|
1999-11-29 00:42:02 +01:00
|
|
|
{
|
|
|
|
|
return eref_count_;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-26 03:39:02 +02:00
|
|
|
void NetNet::incr_lref()
|
|
|
|
|
{
|
|
|
|
|
lref_count_ += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetNet::decr_lref()
|
|
|
|
|
{
|
|
|
|
|
assert(lref_count_ > 0);
|
|
|
|
|
lref_count_ -= 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetNet::peek_lref() const
|
|
|
|
|
{
|
|
|
|
|
return lref_count_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetNet::get_refs() const
|
|
|
|
|
{
|
|
|
|
|
return lref_count_ + eref_count_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-19 06:20:03 +02:00
|
|
|
NetSubnet::NetSubnet(NetNet*sig, unsigned off, unsigned wid)
|
|
|
|
|
: NetNet(sig->scope(), sig->scope()->local_hsymbol(), sig->type(), wid)
|
1999-11-18 04:52:19 +01:00
|
|
|
{
|
2002-06-19 06:20:03 +02:00
|
|
|
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
|
|
|
|
connect(sig->pin(idx+off), pin(idx));
|
|
|
|
|
|
1999-11-18 04:52:19 +01:00
|
|
|
local_flag(true);
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-29 20:36:02 +02:00
|
|
|
NetProc::NetProc()
|
|
|
|
|
: next_(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
NetProc::~NetProc()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-28 02:51:41 +02:00
|
|
|
NetProcTop::NetProcTop(NetScope*s, Type t, NetProc*st)
|
|
|
|
|
: type_(t), statement_(st), scope_(s)
|
1999-07-18 07:52:46 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetProcTop::~NetProcTop()
|
|
|
|
|
{
|
|
|
|
|
delete statement_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-18 23:17:50 +02:00
|
|
|
NetProc* NetProcTop::statement()
|
|
|
|
|
{
|
|
|
|
|
return statement_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetProc* NetProcTop::statement() const
|
|
|
|
|
{
|
|
|
|
|
return statement_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-11 01:03:36 +01:00
|
|
|
NetScope* NetProcTop::scope()
|
|
|
|
|
{
|
|
|
|
|
return scope_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-28 02:51:41 +02:00
|
|
|
const NetScope* NetProcTop::scope() const
|
|
|
|
|
{
|
|
|
|
|
return scope_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-03 06:28:38 +02:00
|
|
|
/*
|
1999-11-01 03:07:40 +01:00
|
|
|
* The NetFF class represents an LPM_FF device. The pinout is assigned
|
|
|
|
|
* like so:
|
|
|
|
|
* 0 -- Clock
|
|
|
|
|
* 1 -- Enable
|
|
|
|
|
* 2 -- Aload
|
|
|
|
|
* 3 -- Aset
|
|
|
|
|
* 4 -- Aclr
|
|
|
|
|
* 5 -- Sload
|
|
|
|
|
* 6 -- Sset
|
|
|
|
|
* 7 -- Sclr
|
|
|
|
|
*
|
|
|
|
|
* 8 -- Data[0]
|
|
|
|
|
* 9 -- Q[0]
|
|
|
|
|
* ...
|
|
|
|
|
*/
|
|
|
|
|
|
2001-07-01 02:27:34 +02:00
|
|
|
NetFF::NetFF(NetScope*s, const char*n, unsigned wid)
|
2000-11-11 01:03:36 +01:00
|
|
|
: NetNode(s, n, 8 + 2*wid)
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
pin_Clock().set_dir(Link::INPUT);
|
|
|
|
|
pin_Clock().set_name("Clock", 0);
|
|
|
|
|
pin_Enable().set_dir(Link::INPUT);
|
|
|
|
|
pin_Enable().set_name("Enable", 0);
|
|
|
|
|
pin_Aload().set_dir(Link::INPUT);
|
|
|
|
|
pin_Aload().set_name("Aload", 0);
|
|
|
|
|
pin_Aset().set_dir(Link::INPUT);
|
|
|
|
|
pin_Aset().set_name("Aset", 0);
|
|
|
|
|
pin_Aclr().set_dir(Link::INPUT);
|
|
|
|
|
pin_Aclr().set_name("Aclr", 0);
|
|
|
|
|
pin_Sload().set_dir(Link::INPUT);
|
|
|
|
|
pin_Sload().set_name("Sload", 0);
|
|
|
|
|
pin_Sset().set_dir(Link::INPUT);
|
|
|
|
|
pin_Sset().set_name("Sset", 0);
|
|
|
|
|
pin_Sclr().set_dir(Link::INPUT);
|
|
|
|
|
pin_Sclr().set_name("Sclr", 0);
|
|
|
|
|
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
|
|
|
|
|
pin_Data(idx).set_dir(Link::INPUT);
|
|
|
|
|
pin_Data(idx).set_name("Data", idx);
|
|
|
|
|
pin_Q(idx).set_dir(Link::OUTPUT);
|
|
|
|
|
pin_Q(idx).set_name("Q", idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetFF::~NetFF()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetFF::width() const
|
|
|
|
|
{
|
|
|
|
|
return (pin_count() - 8) / 2;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetFF::pin_Clock()
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetFF::pin_Clock() const
|
1999-11-02 05:55:34 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetFF::pin_Enable()
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetFF::pin_Enable() const
|
1999-11-02 05:55:34 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetFF::pin_Aload()
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
return pin(2);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetFF::pin_Aset()
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
return pin(3);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetFF::pin_Aclr()
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
return pin(4);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetFF::pin_Sload()
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
return pin(5);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetFF::pin_Sset()
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
return pin(6);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetFF::pin_Sclr()
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
return pin(7);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetFF::pin_Data(unsigned w)
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
unsigned pn = 8 + 2*w;
|
|
|
|
|
assert(pn < pin_count());
|
|
|
|
|
return pin(pn);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetFF::pin_Data(unsigned w) const
|
1999-11-02 05:55:34 +01:00
|
|
|
{
|
|
|
|
|
unsigned pn = 8 + 2*w;
|
|
|
|
|
assert(pn < pin_count());
|
|
|
|
|
return pin(pn);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetFF::pin_Q(unsigned w)
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
unsigned pn = 9 + w*2;
|
|
|
|
|
assert(pn < pin_count());
|
|
|
|
|
return pin(pn);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetFF::pin_Q(unsigned w) const
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
unsigned pn = 9 + w*2;
|
|
|
|
|
assert(pn < pin_count());
|
|
|
|
|
return pin(pn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The NetAddSub class represents an LPM_ADD_SUB device. The pinout is
|
1999-09-03 06:28:38 +02:00
|
|
|
* assigned like so:
|
|
|
|
|
* 0 -- Add_Sub
|
|
|
|
|
* 1 -- Aclr
|
|
|
|
|
* 2 -- Clock
|
|
|
|
|
* 3 -- Cin
|
|
|
|
|
* 4 -- Cout
|
|
|
|
|
* 5 -- Overflow
|
|
|
|
|
* 6 -- DataA[0]
|
|
|
|
|
* 7 -- DataB[0]
|
|
|
|
|
* 8 -- Result[0]
|
|
|
|
|
*/
|
2001-06-07 04:12:43 +02:00
|
|
|
NetAddSub::NetAddSub(NetScope*s, const string&n, unsigned w)
|
|
|
|
|
: NetNode(s, n, w*3+6)
|
1999-09-03 06:28:38 +02:00
|
|
|
{
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(0).set_dir(Link::INPUT); pin(0).set_name("Add_Sub", 0);
|
|
|
|
|
pin(1).set_dir(Link::INPUT); pin(1).set_name("Aclr", 0);
|
|
|
|
|
pin(2).set_dir(Link::INPUT); pin(2).set_name("Clock", 0);
|
|
|
|
|
pin(3).set_dir(Link::INPUT); pin(3).set_name("Cin", 0);
|
|
|
|
|
pin(4).set_dir(Link::OUTPUT); pin(4).set_name("Cout", 0);
|
|
|
|
|
pin(5).set_dir(Link::OUTPUT); pin(5).set_name("Overflow", 0);
|
1999-09-03 06:28:38 +02:00
|
|
|
for (unsigned idx = 0 ; idx < w ; idx += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin_DataA(idx).set_dir(Link::INPUT);
|
|
|
|
|
pin_DataB(idx).set_dir(Link::INPUT);
|
|
|
|
|
pin_Result(idx).set_dir(Link::OUTPUT);
|
1999-10-31 05:11:27 +01:00
|
|
|
pin_DataA(idx).set_name("DataA", idx);
|
|
|
|
|
pin_DataB(idx).set_name("DataB", idx);
|
|
|
|
|
pin_Result(idx).set_name("Result", idx);
|
1999-09-03 06:28:38 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetAddSub::~NetAddSub()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-04 03:57:15 +02:00
|
|
|
unsigned NetAddSub::width()const
|
|
|
|
|
{
|
|
|
|
|
return (pin_count() - 6) / 3;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetAddSub::pin_Cout()
|
1999-12-16 03:42:14 +01:00
|
|
|
{
|
|
|
|
|
return pin(4);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetAddSub::pin_Cout() const
|
1999-12-16 03:42:14 +01:00
|
|
|
{
|
|
|
|
|
return pin(4);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetAddSub::pin_DataA(unsigned idx)
|
1999-09-03 06:28:38 +02:00
|
|
|
{
|
|
|
|
|
idx = 6 + idx*3;
|
|
|
|
|
assert(idx < pin_count());
|
|
|
|
|
return pin(idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetAddSub::pin_DataA(unsigned idx) const
|
1999-11-05 05:40:40 +01:00
|
|
|
{
|
|
|
|
|
idx = 6 + idx*3;
|
|
|
|
|
assert(idx < pin_count());
|
|
|
|
|
return pin(idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetAddSub::pin_DataB(unsigned idx)
|
1999-09-03 06:28:38 +02:00
|
|
|
{
|
|
|
|
|
idx = 7 + idx*3;
|
|
|
|
|
assert(idx < pin_count());
|
|
|
|
|
return pin(idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetAddSub::pin_DataB(unsigned idx) const
|
1999-11-05 05:40:40 +01:00
|
|
|
{
|
|
|
|
|
idx = 7 + idx*3;
|
|
|
|
|
assert(idx < pin_count());
|
|
|
|
|
return pin(idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetAddSub::pin_Result(unsigned idx)
|
1999-09-03 06:28:38 +02:00
|
|
|
{
|
|
|
|
|
idx = 8 + idx*3;
|
|
|
|
|
assert(idx < pin_count());
|
|
|
|
|
return pin(idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetAddSub::pin_Result(unsigned idx) const
|
1999-10-31 05:11:27 +01:00
|
|
|
{
|
|
|
|
|
idx = 8 + idx*3;
|
|
|
|
|
assert(idx < pin_count());
|
|
|
|
|
return pin(idx);
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-14 21:24:28 +01:00
|
|
|
/*
|
|
|
|
|
* The pinout for the NetCLShift is:
|
|
|
|
|
* 0 -- Direction
|
|
|
|
|
* 1 -- Underflow
|
|
|
|
|
* 2 -- Overflow
|
|
|
|
|
* 3 -- Data(0)
|
|
|
|
|
* 3+W -- Result(0)
|
|
|
|
|
* 3+2W -- Distance(0)
|
|
|
|
|
*/
|
2001-07-05 00:59:25 +02:00
|
|
|
NetCLShift::NetCLShift(NetScope*s, const string&n,
|
|
|
|
|
unsigned width, unsigned width_dist)
|
|
|
|
|
: NetNode(s, n, 3+2*width+width_dist), width_(width), width_dist_(width_dist)
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(0).set_dir(Link::INPUT); pin(0).set_name("Direction", 0);
|
|
|
|
|
pin(1).set_dir(Link::OUTPUT); pin(1).set_name("Underflow", 0);
|
|
|
|
|
pin(2).set_dir(Link::OUTPUT); pin(2).set_name("Overflow", 0);
|
1999-11-14 21:24:28 +01:00
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < width_ ; idx += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(3+idx).set_dir(Link::INPUT);
|
1999-11-14 21:24:28 +01:00
|
|
|
pin(3+idx).set_name("Data", idx);
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(3+width_+idx).set_dir(Link::OUTPUT);
|
1999-11-14 21:24:28 +01:00
|
|
|
pin(3+width_+idx).set_name("Result", idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < width_dist_ ; idx += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(3+2*width_+idx).set_dir(Link::INPUT);
|
1999-11-14 21:24:28 +01:00
|
|
|
pin(3+2*width_+idx).set_name("Distance", idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetCLShift::~NetCLShift()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetCLShift::width() const
|
|
|
|
|
{
|
|
|
|
|
return width_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetCLShift::width_dist() const
|
|
|
|
|
{
|
|
|
|
|
return width_dist_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCLShift::pin_Direction()
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCLShift::pin_Direction() const
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCLShift::pin_Underflow()
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCLShift::pin_Underflow() const
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCLShift::pin_Overflow()
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
return pin(2);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCLShift::pin_Overflow() const
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
return pin(2);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCLShift::pin_Data(unsigned idx)
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_);
|
|
|
|
|
return pin(3+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCLShift::pin_Data(unsigned idx) const
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_);
|
|
|
|
|
return pin(3+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCLShift::pin_Result(unsigned idx)
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_);
|
|
|
|
|
return pin(3+width_+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCLShift::pin_Result(unsigned idx) const
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_);
|
|
|
|
|
return pin(3+width_+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCLShift::pin_Distance(unsigned idx)
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_dist_);
|
|
|
|
|
return pin(3+2*width_+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCLShift::pin_Distance(unsigned idx) const
|
1999-11-14 21:24:28 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_dist_);
|
|
|
|
|
return pin(3+2*width_+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-15 06:14:18 +02:00
|
|
|
NetCompare::NetCompare(NetScope*s, const string&n, unsigned wi)
|
|
|
|
|
: NetNode(s, n, 8+2*wi), width_(wi)
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(0).set_dir(Link::INPUT); pin(0).set_name("Aclr");
|
|
|
|
|
pin(1).set_dir(Link::INPUT); pin(1).set_name("Clock");
|
|
|
|
|
pin(2).set_dir(Link::OUTPUT); pin(2).set_name("AGB");
|
|
|
|
|
pin(3).set_dir(Link::OUTPUT); pin(3).set_name("AGEB");
|
|
|
|
|
pin(4).set_dir(Link::OUTPUT); pin(4).set_name("AEB");
|
|
|
|
|
pin(5).set_dir(Link::OUTPUT); pin(5).set_name("ANEB");
|
|
|
|
|
pin(6).set_dir(Link::OUTPUT); pin(6).set_name("ALB");
|
|
|
|
|
pin(7).set_dir(Link::OUTPUT); pin(7).set_name("ALEB");
|
1999-11-15 00:43:45 +01:00
|
|
|
for (unsigned idx = 0 ; idx < width_ ; idx += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(8+idx).set_dir(Link::INPUT);
|
1999-11-15 00:43:45 +01:00
|
|
|
pin(8+idx).set_name("DataA", idx);
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(8+width_+idx).set_dir(Link::INPUT);
|
1999-11-15 00:43:45 +01:00
|
|
|
pin(8+width_+idx).set_name("DataB", idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetCompare::~NetCompare()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetCompare::width() const
|
|
|
|
|
{
|
|
|
|
|
return width_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCompare::pin_Aclr()
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCompare::pin_Aclr() const
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCompare::pin_Clock()
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCompare::pin_Clock() const
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCompare::pin_AGB()
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(2);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCompare::pin_AGB() const
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(2);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCompare::pin_AGEB()
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(3);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCompare::pin_AGEB() const
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(3);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCompare::pin_AEB()
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(4);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCompare::pin_AEB() const
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(4);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCompare::pin_ANEB()
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(5);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCompare::pin_ANEB() const
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(5);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCompare::pin_ALB()
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(6);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCompare::pin_ALB() const
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(6);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCompare::pin_ALEB()
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(7);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCompare::pin_ALEB() const
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(7);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCompare::pin_DataA(unsigned idx)
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(8+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCompare::pin_DataA(unsigned idx) const
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(8+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetCompare::pin_DataB(unsigned idx)
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(8+width_+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetCompare::pin_DataB(unsigned idx) const
|
1999-11-15 00:43:45 +01:00
|
|
|
{
|
|
|
|
|
return pin(8+width_+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-16 04:19:26 +02:00
|
|
|
NetDivide::NetDivide(NetScope*sc, const string&n, unsigned wr,
|
2000-04-01 23:40:22 +02:00
|
|
|
unsigned wa, unsigned wb)
|
2001-10-16 04:19:26 +02:00
|
|
|
: NetNode(sc, n, wr+wa+wb), width_r_(wr), width_a_(wa), width_b_(wb)
|
2000-04-01 23:40:22 +02:00
|
|
|
{
|
|
|
|
|
unsigned p = 0;
|
|
|
|
|
for (unsigned idx = 0 ; idx < width_r_ ; idx += 1, p += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(p).set_dir(Link::OUTPUT);
|
2000-04-01 23:40:22 +02:00
|
|
|
pin(p).set_name("Result", idx);
|
|
|
|
|
}
|
|
|
|
|
for (unsigned idx = 0 ; idx < width_a_ ; idx += 1, p += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(p).set_dir(Link::INPUT);
|
2000-04-01 23:40:22 +02:00
|
|
|
pin(p).set_name("DataA", idx);
|
|
|
|
|
}
|
|
|
|
|
for (unsigned idx = 0 ; idx < width_b_ ; idx += 1, p += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(p).set_dir(Link::INPUT);
|
2000-04-01 23:40:22 +02:00
|
|
|
pin(p).set_name("DataB", idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetDivide::~NetDivide()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetDivide::width_r() const
|
|
|
|
|
{
|
|
|
|
|
return width_r_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetDivide::width_a() const
|
|
|
|
|
{
|
|
|
|
|
return width_a_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetDivide::width_b() const
|
|
|
|
|
{
|
|
|
|
|
return width_b_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetDivide::pin_Result(unsigned idx)
|
2000-04-01 23:40:22 +02:00
|
|
|
{
|
|
|
|
|
assert(idx < width_r_);
|
|
|
|
|
return pin(idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetDivide::pin_Result(unsigned idx) const
|
2000-04-01 23:40:22 +02:00
|
|
|
{
|
|
|
|
|
assert(idx < width_r_);
|
|
|
|
|
return pin(idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetDivide::pin_DataA(unsigned idx)
|
2000-04-01 23:40:22 +02:00
|
|
|
{
|
|
|
|
|
assert(idx < width_a_);
|
|
|
|
|
return pin(idx+width_r_);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetDivide::pin_DataA(unsigned idx) const
|
2000-04-01 23:40:22 +02:00
|
|
|
{
|
|
|
|
|
assert(idx < width_a_);
|
|
|
|
|
return pin(idx+width_r_);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetDivide::pin_DataB(unsigned idx)
|
2000-04-01 23:40:22 +02:00
|
|
|
{
|
|
|
|
|
assert(idx < width_b_);
|
|
|
|
|
return pin(idx+width_r_+width_a_);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetDivide::pin_DataB(unsigned idx) const
|
2000-04-01 23:40:22 +02:00
|
|
|
{
|
|
|
|
|
assert(idx < width_b_);
|
|
|
|
|
return pin(idx+width_r_+width_a_);
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-17 01:45:05 +02:00
|
|
|
NetMult::NetMult(NetScope*sc, const string&n, unsigned wr,
|
|
|
|
|
unsigned wa, unsigned wb, unsigned ws)
|
|
|
|
|
: NetNode(sc, n, 2+wr+wa+wb+ws), width_r_(wr), width_a_(wa), width_b_(wb),
|
|
|
|
|
width_s_(ws)
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(0).set_dir(Link::INPUT); pin(0).set_name("Aclr", 0);
|
|
|
|
|
pin(1).set_dir(Link::INPUT); pin(1).set_name("Clock", 0);
|
2000-01-13 04:35:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned p = 2;
|
|
|
|
|
for (unsigned idx = 0 ; idx < width_r_ ; idx += 1, p += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(p).set_dir(Link::OUTPUT);
|
2000-01-13 04:35:35 +01:00
|
|
|
pin(p).set_name("Result", idx);
|
|
|
|
|
}
|
|
|
|
|
for (unsigned idx = 0 ; idx < width_a_ ; idx += 1, p += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(p).set_dir(Link::INPUT);
|
2000-01-13 04:35:35 +01:00
|
|
|
pin(p).set_name("DataA", idx);
|
|
|
|
|
}
|
|
|
|
|
for (unsigned idx = 0 ; idx < width_b_ ; idx += 1, p += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(p).set_dir(Link::INPUT);
|
2000-01-13 04:35:35 +01:00
|
|
|
pin(p).set_name("DataB", idx);
|
|
|
|
|
}
|
|
|
|
|
for (unsigned idx = 0 ; idx < width_s_ ; idx += 1, p += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(p).set_dir(Link::INPUT);
|
2000-01-13 04:35:35 +01:00
|
|
|
pin(p).set_name("Sum", idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetMult::~NetMult()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetMult::width_r() const
|
|
|
|
|
{
|
|
|
|
|
return width_r_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetMult::width_a() const
|
|
|
|
|
{
|
|
|
|
|
return width_a_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetMult::width_b() const
|
|
|
|
|
{
|
|
|
|
|
return width_b_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetMult::width_s() const
|
|
|
|
|
{
|
|
|
|
|
return width_s_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMult::pin_Aclr()
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMult::pin_Aclr() const
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMult::pin_Clock()
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMult::pin_Clock() const
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMult::pin_Result(unsigned idx)
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_r_);
|
|
|
|
|
return pin(idx+2);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMult::pin_Result(unsigned idx) const
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_r_);
|
|
|
|
|
return pin(idx+2);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMult::pin_DataA(unsigned idx)
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_a_);
|
|
|
|
|
return pin(idx+2+width_r_);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMult::pin_DataA(unsigned idx) const
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_a_);
|
|
|
|
|
return pin(idx+2+width_r_);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMult::pin_DataB(unsigned idx)
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_b_);
|
|
|
|
|
return pin(idx+2+width_r_+width_a_);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMult::pin_DataB(unsigned idx) const
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_b_);
|
|
|
|
|
return pin(idx+2+width_r_+width_a_);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMult::pin_Sum(unsigned idx)
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_s_);
|
|
|
|
|
return pin(idx+2+width_r_+width_a_+width_b_);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMult::pin_Sum(unsigned idx) const
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width_s_);
|
|
|
|
|
return pin(idx+2+width_r_+width_a_+width_b_);
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-04 04:53:26 +01:00
|
|
|
/*
|
|
|
|
|
* The NetMux class represents an LPM_MUX device. The pinout is assigned
|
|
|
|
|
* like so:
|
|
|
|
|
* 0 -- Aclr (optional)
|
|
|
|
|
* 1 -- Clock (optional)
|
|
|
|
|
* 2 -- Result[0]
|
|
|
|
|
* 2+N -- Result[N]
|
|
|
|
|
*/
|
|
|
|
|
|
2001-01-18 04:16:35 +01:00
|
|
|
NetMux::NetMux(NetScope*s, const string&n,
|
|
|
|
|
unsigned wi, unsigned si, unsigned sw)
|
|
|
|
|
: NetNode(s, n, 2+wi+sw+wi*si), width_(wi), size_(si), swidth_(sw)
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(0).set_dir(Link::INPUT); pin(0).set_name("Aclr", 0);
|
|
|
|
|
pin(1).set_dir(Link::INPUT); pin(1).set_name("Clock", 0);
|
1999-11-04 04:53:26 +01:00
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < width_ ; idx += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin_Result(idx).set_dir(Link::OUTPUT);
|
1999-11-04 04:53:26 +01:00
|
|
|
pin_Result(idx).set_name("Result", idx);
|
|
|
|
|
|
|
|
|
|
for (unsigned jdx = 0 ; jdx < size_ ; jdx += 1) {
|
|
|
|
|
pin_Data(idx,jdx).set_dir(Link::INPUT);
|
|
|
|
|
pin_Data(idx,jdx).set_name("Data", jdx*width_+idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < swidth_ ; idx += 1) {
|
1999-11-05 05:40:40 +01:00
|
|
|
pin_Sel(idx).set_dir(Link::INPUT);
|
1999-11-04 04:53:26 +01:00
|
|
|
pin_Sel(idx).set_name("Sel", idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetMux::~NetMux()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetMux::width()const
|
|
|
|
|
{
|
|
|
|
|
return width_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetMux::size() const
|
|
|
|
|
{
|
|
|
|
|
return size_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetMux::sel_width() const
|
|
|
|
|
{
|
|
|
|
|
return swidth_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMux::pin_Aclr()
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMux::pin_Aclr() const
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMux::pin_Clock()
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMux::pin_Clock() const
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMux::pin_Result(unsigned w)
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
|
|
|
|
assert(w < width_);
|
|
|
|
|
return pin(2+w);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMux::pin_Result(unsigned w) const
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
|
|
|
|
assert(w < width_);
|
|
|
|
|
return pin(2+w);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMux::pin_Sel(unsigned w)
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
|
|
|
|
assert(w < swidth_);
|
|
|
|
|
return pin(2+width_+w);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMux::pin_Sel(unsigned w) const
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
|
|
|
|
assert(w < swidth_);
|
|
|
|
|
return pin(2+width_+w);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetMux::pin_Data(unsigned w, unsigned s)
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
|
|
|
|
assert(w < width_);
|
|
|
|
|
assert(s < size_);
|
|
|
|
|
return pin(2+width_+swidth_+s*width_+w);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetMux::pin_Data(unsigned w, unsigned s) const
|
1999-11-04 04:53:26 +01:00
|
|
|
{
|
|
|
|
|
assert(w < width_);
|
|
|
|
|
assert(s < size_);
|
|
|
|
|
return pin(2+width_+swidth_+s*width_+w);
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-21 01:13:08 +01:00
|
|
|
|
2001-10-28 02:14:53 +01:00
|
|
|
NetRamDq::NetRamDq(NetScope*s, const string&n, NetMemory*mem, unsigned awid)
|
|
|
|
|
: NetNode(s, n, 3+2*mem->width()+awid), mem_(mem), awidth_(awid)
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(0).set_dir(Link::INPUT); pin(0).set_name("InClock", 0);
|
|
|
|
|
pin(1).set_dir(Link::INPUT); pin(1).set_name("OutClock", 0);
|
|
|
|
|
pin(2).set_dir(Link::INPUT); pin(2).set_name("WE", 0);
|
1999-11-21 01:13:08 +01:00
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < awidth_ ; idx += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(3+idx).set_dir(Link::INPUT);
|
1999-11-21 01:13:08 +01:00
|
|
|
pin(3+idx).set_name("Address", idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < width() ; idx += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(3+awidth_+idx).set_dir(Link::INPUT);
|
1999-11-21 01:13:08 +01:00
|
|
|
pin(3+awidth_+idx).set_name("Data", idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < width() ; idx += 1) {
|
2000-05-07 06:37:55 +02:00
|
|
|
pin(3+awidth_+width()+idx).set_dir(Link::OUTPUT);
|
1999-11-21 01:13:08 +01:00
|
|
|
pin(3+awidth_+width()+idx).set_name("Q", idx);
|
|
|
|
|
}
|
1999-12-05 03:24:08 +01:00
|
|
|
|
|
|
|
|
next_ = mem_->ram_list_;
|
|
|
|
|
mem_->ram_list_ = this;
|
1999-11-21 01:13:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetRamDq::~NetRamDq()
|
|
|
|
|
{
|
1999-12-05 03:24:08 +01:00
|
|
|
if (mem_->ram_list_ == this) {
|
|
|
|
|
mem_->ram_list_ = next_;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
NetRamDq*cur = mem_->ram_list_;
|
|
|
|
|
while (cur->next_ != this) {
|
|
|
|
|
assert(cur->next_);
|
|
|
|
|
cur = cur->next_;
|
|
|
|
|
}
|
|
|
|
|
assert(cur->next_ == this);
|
|
|
|
|
cur->next_ = next_;
|
|
|
|
|
}
|
1999-11-21 01:13:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetRamDq::width() const
|
|
|
|
|
{
|
|
|
|
|
return mem_->width();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetRamDq::awidth() const
|
|
|
|
|
{
|
|
|
|
|
return awidth_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetRamDq::size() const
|
|
|
|
|
{
|
|
|
|
|
return mem_->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetMemory* NetRamDq::mem() const
|
|
|
|
|
{
|
|
|
|
|
return mem_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-05 20:30:42 +01:00
|
|
|
unsigned NetRamDq::count_partners() const
|
|
|
|
|
{
|
|
|
|
|
unsigned count = 0;
|
|
|
|
|
for (NetRamDq*cur = mem_->ram_list_ ; cur ; cur = cur->next_)
|
|
|
|
|
count += 1;
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-05 03:24:08 +01:00
|
|
|
void NetRamDq::absorb_partners()
|
|
|
|
|
{
|
|
|
|
|
NetRamDq*cur, *tmp;
|
|
|
|
|
for (cur = mem_->ram_list_, tmp = 0
|
|
|
|
|
; cur||tmp ; cur = cur? cur->next_ : tmp) {
|
|
|
|
|
tmp = 0;
|
|
|
|
|
if (cur == this) continue;
|
|
|
|
|
|
|
|
|
|
bool ok_flag = true;
|
|
|
|
|
for (unsigned idx = 0 ; idx < awidth() ; idx += 1)
|
|
|
|
|
ok_flag &= pin_Address(idx).is_linked(cur->pin_Address(idx));
|
|
|
|
|
|
|
|
|
|
if (!ok_flag) continue;
|
|
|
|
|
|
|
|
|
|
if (pin_InClock().is_linked()
|
|
|
|
|
&& cur->pin_InClock().is_linked()
|
|
|
|
|
&& ! pin_InClock().is_linked(cur->pin_InClock()))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (pin_OutClock().is_linked()
|
|
|
|
|
&& cur->pin_OutClock().is_linked()
|
|
|
|
|
&& ! pin_OutClock().is_linked(cur->pin_OutClock()))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (pin_WE().is_linked()
|
|
|
|
|
&& cur->pin_WE().is_linked()
|
|
|
|
|
&& ! pin_WE().is_linked(cur->pin_WE()))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < width() ; idx += 1) {
|
|
|
|
|
if (!pin_Data(idx).is_linked()) continue;
|
|
|
|
|
if (! cur->pin_Data(idx).is_linked()) continue;
|
|
|
|
|
|
|
|
|
|
ok_flag &= pin_Data(idx).is_linked(cur->pin_Data(idx));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! ok_flag) continue;
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < width() ; idx += 1) {
|
|
|
|
|
if (!pin_Q(idx).is_linked()) continue;
|
|
|
|
|
if (! cur->pin_Q(idx).is_linked()) continue;
|
|
|
|
|
|
|
|
|
|
ok_flag &= pin_Q(idx).is_linked(cur->pin_Q(idx));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! ok_flag) continue;
|
|
|
|
|
|
|
|
|
|
// I see no other reason to reject cur, so link up all
|
|
|
|
|
// my pins and delete it.
|
|
|
|
|
connect(pin_InClock(), cur->pin_InClock());
|
|
|
|
|
connect(pin_OutClock(), cur->pin_OutClock());
|
|
|
|
|
connect(pin_WE(), cur->pin_WE());
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < awidth() ; idx += 1)
|
|
|
|
|
connect(pin_Address(idx), cur->pin_Address(idx));
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < width() ; idx += 1) {
|
|
|
|
|
connect(pin_Data(idx), cur->pin_Data(idx));
|
|
|
|
|
connect(pin_Q(idx), cur->pin_Q(idx));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tmp = cur->next_;
|
|
|
|
|
delete cur;
|
|
|
|
|
cur = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetRamDq::pin_InClock()
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetRamDq::pin_InClock() const
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
return pin(0);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetRamDq::pin_OutClock()
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetRamDq::pin_OutClock() const
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
return pin(1);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetRamDq::pin_WE()
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
return pin(2);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetRamDq::pin_WE() const
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
return pin(2);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetRamDq::pin_Address(unsigned idx)
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < awidth_);
|
|
|
|
|
return pin(3+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetRamDq::pin_Address(unsigned idx) const
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < awidth_);
|
|
|
|
|
return pin(3+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetRamDq::pin_Data(unsigned idx)
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width());
|
|
|
|
|
return pin(3+awidth_+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetRamDq::pin_Data(unsigned idx) const
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width());
|
|
|
|
|
return pin(3+awidth_+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
Link& NetRamDq::pin_Q(unsigned idx)
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width());
|
|
|
|
|
return pin(3+awidth_+width()+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 06:37:55 +02:00
|
|
|
const Link& NetRamDq::pin_Q(unsigned idx) const
|
1999-11-21 01:13:08 +01:00
|
|
|
{
|
|
|
|
|
assert(idx < width());
|
|
|
|
|
return pin(3+awidth_+width()+idx);
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-07 21:45:42 +02:00
|
|
|
NetBUFZ::NetBUFZ(NetScope*s, const string&n)
|
|
|
|
|
: NetNode(s, n, 2)
|
1999-10-31 05:11:27 +01:00
|
|
|
{
|
|
|
|
|
pin(0).set_dir(Link::OUTPUT);
|
|
|
|
|
pin(1).set_dir(Link::INPUT);
|
|
|
|
|
pin(0).set_name("O", 0);
|
|
|
|
|
pin(1).set_name("I", 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetBUFZ::~NetBUFZ()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-10-28 02:14:53 +01:00
|
|
|
NetCaseCmp::NetCaseCmp(NetScope*s, const string&n)
|
|
|
|
|
: NetNode(s, n, 3)
|
1999-10-10 03:59:54 +02:00
|
|
|
{
|
1999-12-02 17:58:58 +01:00
|
|
|
pin(0).set_dir(Link::OUTPUT); pin(0).set_name("O",0);
|
|
|
|
|
pin(1).set_dir(Link::INPUT); pin(1).set_name("I",0);
|
|
|
|
|
pin(2).set_dir(Link::INPUT); pin(2).set_name("I",1);
|
1999-10-10 03:59:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetCaseCmp::~NetCaseCmp()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-24 06:24:18 +02:00
|
|
|
NetCondit::NetCondit(NetExpr*ex, NetProc*i, NetProc*e)
|
|
|
|
|
: expr_(ex), if_(i), else_(e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-18 23:17:50 +02:00
|
|
|
NetCondit::~NetCondit()
|
|
|
|
|
{
|
|
|
|
|
delete expr_;
|
|
|
|
|
if (if_) delete if_;
|
|
|
|
|
if (else_) delete else_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetExpr* NetCondit::expr() const
|
|
|
|
|
{
|
|
|
|
|
return expr_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetExpr* NetCondit::expr()
|
|
|
|
|
{
|
|
|
|
|
return expr_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-17 01:32:18 +02:00
|
|
|
void NetCondit::set_expr(NetExpr*ex)
|
|
|
|
|
{
|
|
|
|
|
delete expr_;
|
|
|
|
|
expr_ = ex;
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-18 23:17:50 +02:00
|
|
|
NetProc* NetCondit::if_clause()
|
|
|
|
|
{
|
|
|
|
|
return if_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetProc* NetCondit::else_clause()
|
|
|
|
|
{
|
|
|
|
|
return else_;
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-28 02:14:53 +01:00
|
|
|
NetConst::NetConst(NetScope*s, const string&n, verinum::V v)
|
|
|
|
|
: NetNode(s, n, 1)
|
1999-10-10 03:59:54 +02:00
|
|
|
{
|
|
|
|
|
pin(0).set_dir(Link::OUTPUT);
|
1999-10-31 05:11:27 +01:00
|
|
|
pin(0).set_name("O", 0);
|
1999-12-17 04:38:46 +01:00
|
|
|
value_ = new verinum::V[1];
|
|
|
|
|
value_[0] = v;
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-28 02:14:53 +01:00
|
|
|
NetConst::NetConst(NetScope*s, const string&n, const verinum&val)
|
|
|
|
|
: NetNode(s, n, val.len())
|
1999-12-17 04:38:46 +01:00
|
|
|
{
|
|
|
|
|
value_ = new verinum::V[pin_count()];
|
|
|
|
|
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1) {
|
|
|
|
|
pin(idx).set_dir(Link::OUTPUT);
|
|
|
|
|
pin(idx).set_name("O", idx);
|
|
|
|
|
value_[idx] = val.get(idx);
|
|
|
|
|
}
|
1999-10-10 03:59:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetConst::~NetConst()
|
|
|
|
|
{
|
1999-12-17 04:38:46 +01:00
|
|
|
delete[]value_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verinum::V NetConst::value(unsigned idx) const
|
|
|
|
|
{
|
|
|
|
|
assert(idx < pin_count());
|
|
|
|
|
return value_[idx];
|
1999-10-10 03:59:54 +02:00
|
|
|
}
|
|
|
|
|
|
2000-03-08 05:36:53 +01:00
|
|
|
NetFuncDef::NetFuncDef(NetScope*s, const svector<NetNet*>&po)
|
|
|
|
|
: scope_(s), statement_(0), ports_(po)
|
1999-08-26 00:22:41 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetFuncDef::~NetFuncDef()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 05:36:53 +01:00
|
|
|
const string NetFuncDef::name() const
|
1999-09-01 00:38:29 +02:00
|
|
|
{
|
2000-03-08 05:36:53 +01:00
|
|
|
return scope_->name();
|
1999-09-01 00:38:29 +02:00
|
|
|
}
|
|
|
|
|
|
1999-09-01 22:46:19 +02:00
|
|
|
void NetFuncDef::set_proc(NetProc*st)
|
|
|
|
|
{
|
|
|
|
|
assert(statement_ == 0);
|
|
|
|
|
assert(st != 0);
|
|
|
|
|
statement_ = st;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-01 00:38:29 +02:00
|
|
|
const NetProc* NetFuncDef::proc() const
|
|
|
|
|
{
|
|
|
|
|
return statement_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 05:36:53 +01:00
|
|
|
NetScope*NetFuncDef::scope()
|
|
|
|
|
{
|
|
|
|
|
return scope_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-01 22:46:19 +02:00
|
|
|
unsigned NetFuncDef::port_count() const
|
|
|
|
|
{
|
|
|
|
|
return ports_.count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetNet* NetFuncDef::port(unsigned idx) const
|
|
|
|
|
{
|
|
|
|
|
assert(idx < ports_.count());
|
|
|
|
|
return ports_[idx];
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-03 04:12:51 +02:00
|
|
|
NetSTask::NetSTask(const string&na, const svector<NetExpr*>&pa)
|
2000-09-22 05:58:30 +02:00
|
|
|
: name_(0), parms_(pa)
|
1998-11-04 00:28:49 +01:00
|
|
|
{
|
2000-09-22 05:58:30 +02:00
|
|
|
name_ = new char[na.length() + 1];
|
|
|
|
|
strcpy(name_, na.c_str());
|
1999-07-03 04:12:51 +02:00
|
|
|
assert(name_[0] == '$');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetSTask::~NetSTask()
|
|
|
|
|
{
|
|
|
|
|
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
|
1999-05-30 03:11:46 +02:00
|
|
|
delete parms_[idx];
|
1999-03-01 04:27:53 +01:00
|
|
|
|
2000-09-22 05:58:30 +02:00
|
|
|
delete[]name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char*NetSTask::name() const
|
|
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetSTask::nparms() const
|
|
|
|
|
{
|
|
|
|
|
return parms_.count();
|
1999-07-03 04:12:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetExpr* NetSTask::parm(unsigned idx) const
|
|
|
|
|
{
|
|
|
|
|
return parms_[idx];
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-06 04:28:02 +02:00
|
|
|
NetEUFunc::NetEUFunc(NetScope*def, NetESignal*res, svector<NetExpr*>&p)
|
1999-09-01 00:38:29 +02:00
|
|
|
: func_(def), result_(res), parms_(p)
|
|
|
|
|
{
|
1999-09-01 22:46:19 +02:00
|
|
|
expr_width(result_->expr_width());
|
1999-09-01 00:38:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEUFunc::~NetEUFunc()
|
|
|
|
|
{
|
|
|
|
|
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
|
|
|
|
|
delete parms_[idx];
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 05:36:53 +01:00
|
|
|
const string NetEUFunc::name() const
|
1999-09-01 00:38:29 +02:00
|
|
|
{
|
|
|
|
|
return func_->name();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetESignal*NetEUFunc::result() const
|
|
|
|
|
{
|
|
|
|
|
return result_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-01 22:46:19 +02:00
|
|
|
unsigned NetEUFunc::parm_count() const
|
|
|
|
|
{
|
|
|
|
|
return parms_.count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetExpr* NetEUFunc::parm(unsigned idx) const
|
|
|
|
|
{
|
|
|
|
|
assert(idx < parms_.count());
|
|
|
|
|
return parms_[idx];
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-06 04:28:02 +02:00
|
|
|
const NetScope* NetEUFunc::func() const
|
1999-09-01 22:46:19 +02:00
|
|
|
{
|
|
|
|
|
return func_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-01 00:38:29 +02:00
|
|
|
NetEUFunc* NetEUFunc::dup_expr() const
|
|
|
|
|
{
|
|
|
|
|
assert(0);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-02 04:28:12 +02:00
|
|
|
NetUTask::NetUTask(NetScope*def)
|
1999-07-24 04:11:19 +02:00
|
|
|
: task_(def)
|
1999-07-03 04:12:51 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetUTask::~NetUTask()
|
|
|
|
|
{
|
1998-11-04 00:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2001-04-06 04:28:02 +02:00
|
|
|
const string NetUTask::name() const
|
2001-04-02 04:28:12 +02:00
|
|
|
{
|
|
|
|
|
return task_->name();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetScope* NetUTask::task() const
|
|
|
|
|
{
|
|
|
|
|
return task_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-20 04:21:10 +02:00
|
|
|
NetExpr::NetExpr(unsigned w)
|
2001-12-31 01:08:14 +01:00
|
|
|
: width_(w), signed_flag_(false)
|
1999-09-20 04:21:10 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
NetExpr::~NetExpr()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-26 07:05:58 +02:00
|
|
|
bool NetExpr::has_sign() const
|
|
|
|
|
{
|
2001-12-31 01:08:14 +01:00
|
|
|
return signed_flag_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetExpr::cast_signed(bool flag)
|
|
|
|
|
{
|
|
|
|
|
signed_flag_ = flag;
|
2000-09-26 07:05:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NetExpr::has_width() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-07 22:47:13 +01:00
|
|
|
/*
|
|
|
|
|
* Create a bitwise operator node from the opcode and the left and
|
|
|
|
|
* right expressions. Don't worry about the width of the expression
|
|
|
|
|
* yet, we'll get that from the l-value, whatever that turns out to
|
|
|
|
|
* be.
|
|
|
|
|
*/
|
1999-07-31 05:16:54 +02:00
|
|
|
NetEBAdd::NetEBAdd(char op, NetExpr*l, NetExpr*r)
|
|
|
|
|
: NetEBinary(op, l, r)
|
|
|
|
|
{
|
2000-05-19 03:43:16 +02:00
|
|
|
if (r->expr_width() > l->expr_width())
|
|
|
|
|
expr_width(r->expr_width());
|
1999-09-16 06:18:15 +02:00
|
|
|
else
|
|
|
|
|
expr_width(l->expr_width());
|
2002-04-14 20:41:34 +02:00
|
|
|
|
|
|
|
|
cast_signed(l->has_sign() && r->has_sign());
|
1999-07-31 05:16:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEBAdd::~NetEBAdd()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-11 01:29:37 +02:00
|
|
|
NetEBAdd* NetEBAdd::dup_expr() const
|
|
|
|
|
{
|
|
|
|
|
NetEBAdd*result = new NetEBAdd(op_, left_->dup_expr(),
|
|
|
|
|
right_->dup_expr());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-07 22:47:13 +01:00
|
|
|
/*
|
|
|
|
|
* Create a bitwise operator node from the opcode and the left and
|
|
|
|
|
* right expressions. Don't worry about the width of the expression
|
|
|
|
|
* yet, we'll get that from the l-value, whatever that turns out to
|
|
|
|
|
* be. However, if we don't, our default will be the width of the
|
|
|
|
|
* largest operand.
|
|
|
|
|
*/
|
1999-07-31 05:16:54 +02:00
|
|
|
NetEBBits::NetEBBits(char op, NetExpr*l, NetExpr*r)
|
|
|
|
|
: NetEBinary(op, l, r)
|
|
|
|
|
{
|
2001-02-07 22:47:13 +01:00
|
|
|
if (r->expr_width() > l->expr_width())
|
|
|
|
|
expr_width(r->expr_width());
|
|
|
|
|
else
|
|
|
|
|
expr_width(l->expr_width());
|
1999-07-31 05:16:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEBBits::~NetEBBits()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-11 01:29:37 +02:00
|
|
|
NetEBBits* NetEBBits::dup_expr() const
|
|
|
|
|
{
|
|
|
|
|
NetEBBits*result = new NetEBBits(op_, left_->dup_expr(),
|
|
|
|
|
right_->dup_expr());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-29 03:53:22 +02:00
|
|
|
/*
|
|
|
|
|
* Create a comparison operator with two sub-expressions.
|
|
|
|
|
*
|
|
|
|
|
* Handle the special case of an unsized constant on the left or right
|
|
|
|
|
* side by resizing the number to match the other
|
|
|
|
|
* expression. Otherwise, the netlist will have to allow the
|
|
|
|
|
* expressions to have different widths.
|
|
|
|
|
*/
|
1999-07-31 05:16:54 +02:00
|
|
|
NetEBComp::NetEBComp(char op, NetExpr*l, NetExpr*r)
|
|
|
|
|
: NetEBinary(op, l, r)
|
|
|
|
|
{
|
2001-09-29 03:53:22 +02:00
|
|
|
if (NetEConst*tmp = dynamic_cast<NetEConst*>(r)) do {
|
|
|
|
|
|
|
|
|
|
if (tmp->has_width())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (tmp->expr_width() == l->expr_width())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
tmp->set_width(l->expr_width());
|
|
|
|
|
|
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
|
|
if (NetEConst*tmp = dynamic_cast<NetEConst*>(l)) do {
|
|
|
|
|
|
|
|
|
|
if (tmp->has_width())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (tmp->expr_width() == r->expr_width())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
tmp->set_width(r->expr_width());
|
|
|
|
|
|
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
|
|
|
1999-09-16 02:33:45 +02:00
|
|
|
expr_width(1);
|
1999-07-31 05:16:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEBComp::~NetEBComp()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-11 01:29:37 +02:00
|
|
|
NetEBComp* NetEBComp::dup_expr() const
|
|
|
|
|
{
|
|
|
|
|
NetEBComp*result = new NetEBComp(op_, left_->dup_expr(),
|
|
|
|
|
right_->dup_expr());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-28 20:43:23 +02:00
|
|
|
NetEBDiv::NetEBDiv(char op, NetExpr*l, NetExpr*r)
|
|
|
|
|
: NetEBinary(op, l, r)
|
|
|
|
|
{
|
|
|
|
|
unsigned w = l->expr_width();
|
|
|
|
|
if (r->expr_width() > w)
|
|
|
|
|
w = r->expr_width();
|
|
|
|
|
|
|
|
|
|
expr_width(w);
|
2002-04-14 20:41:34 +02:00
|
|
|
cast_signed(l->has_sign() && r->has_sign());
|
2000-04-28 20:43:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEBDiv::~NetEBDiv()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEBDiv* NetEBDiv::dup_expr() const
|
|
|
|
|
{
|
|
|
|
|
NetEBDiv*result = new NetEBDiv(op_, left_->dup_expr(),
|
|
|
|
|
right_->dup_expr());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-30 03:11:46 +02:00
|
|
|
NetEBinary::NetEBinary(char op, NetExpr*l, NetExpr*r)
|
|
|
|
|
: op_(op), left_(l), right_(r)
|
1999-03-01 04:27:53 +01:00
|
|
|
{
|
|
|
|
|
}
|
1998-11-07 20:17:10 +01:00
|
|
|
|
|
|
|
|
NetEBinary::~NetEBinary()
|
1998-11-04 00:28:49 +01:00
|
|
|
{
|
1999-05-30 03:11:46 +02:00
|
|
|
delete left_;
|
|
|
|
|
delete right_;
|
1998-11-07 20:17:10 +01:00
|
|
|
}
|
|
|
|
|
|
2001-02-10 22:20:38 +01:00
|
|
|
bool NetEBinary::has_width() const
|
|
|
|
|
{
|
|
|
|
|
return left_->has_width() && right_->has_width();
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-23 02:21:54 +02:00
|
|
|
NetEBinary* NetEBinary::dup_expr() const
|
1998-11-07 20:17:10 +01:00
|
|
|
{
|
1999-09-23 02:21:54 +02:00
|
|
|
assert(0);
|
|
|
|
|
}
|
1998-11-07 20:17:10 +01:00
|
|
|
|
1999-09-23 02:21:54 +02:00
|
|
|
NetEBLogic::NetEBLogic(char op, NetExpr*l, NetExpr*r)
|
|
|
|
|
: NetEBinary(op, l, r)
|
|
|
|
|
{
|
|
|
|
|
expr_width(1);
|
1998-11-07 18:05:05 +01:00
|
|
|
}
|
|
|
|
|
|
1999-09-23 02:21:54 +02:00
|
|
|
NetEBLogic::~NetEBLogic()
|
1999-05-30 03:11:46 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-11 01:29:37 +02:00
|
|
|
NetEBLogic* NetEBLogic::dup_expr() const
|
|
|
|
|
{
|
|
|
|
|
NetEBLogic*result = new NetEBLogic(op_, left_->dup_expr(),
|
|
|
|
|
right_->dup_expr());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-13 04:35:35 +01:00
|
|
|
NetEBMult::NetEBMult(char op, NetExpr*l, NetExpr*r)
|
|
|
|
|
: NetEBinary(op, l, r)
|
|
|
|
|
{
|
|
|
|
|
expr_width(l->expr_width() + r->expr_width());
|
2002-04-14 20:41:34 +02:00
|
|
|
cast_signed(l->has_sign() && r->has_sign());
|
2000-01-13 04:35:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEBMult::~NetEBMult()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEBMult* NetEBMult::dup_expr() const
|
|
|
|
|
{
|
|
|
|
|
NetEBMult*result = new NetEBMult(op_, left_->dup_expr(),
|
|
|
|
|
right_->dup_expr());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-23 05:56:57 +02:00
|
|
|
NetEBShift::NetEBShift(char op, NetExpr*l, NetExpr*r)
|
|
|
|
|
: NetEBinary(op, l, r)
|
|
|
|
|
{
|
|
|
|
|
expr_width(l->expr_width());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEBShift::~NetEBShift()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-06 05:32:37 +01:00
|
|
|
bool NetEBShift::has_width() const
|
|
|
|
|
{
|
|
|
|
|
return left_->has_width();
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-11 01:29:37 +02:00
|
|
|
NetEBShift* NetEBShift::dup_expr() const
|
|
|
|
|
{
|
|
|
|
|
NetEBShift*result = new NetEBShift(op_, left_->dup_expr(),
|
|
|
|
|
right_->dup_expr());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-20 04:21:10 +02:00
|
|
|
NetEConst::NetEConst(const verinum&val)
|
|
|
|
|
: NetExpr(val.len()), value_(val)
|
|
|
|
|
{
|
2001-12-31 01:08:14 +01:00
|
|
|
cast_signed(value_.has_sign());
|
1999-09-20 04:21:10 +02:00
|
|
|
}
|
|
|
|
|
|
1998-11-07 20:17:10 +01:00
|
|
|
NetEConst::~NetEConst()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-26 07:05:58 +02:00
|
|
|
const verinum& NetEConst::value() const
|
|
|
|
|
{
|
|
|
|
|
return value_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NetEConst::has_width() const
|
|
|
|
|
{
|
|
|
|
|
return value_.has_len();
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-30 03:11:46 +02:00
|
|
|
NetEConst* NetEConst::dup_expr() const
|
|
|
|
|
{
|
|
|
|
|
NetEConst*tmp = new NetEConst(value_);
|
|
|
|
|
tmp->set_line(*this);
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-19 03:59:36 +02:00
|
|
|
NetEMemory::NetEMemory(NetMemory*m, NetExpr*i)
|
1999-11-21 19:03:35 +01:00
|
|
|
: NetExpr(m->width()), mem_(m), idx_(i)
|
1999-04-19 03:59:36 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEMemory::~NetEMemory()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-04 20:28:14 +02:00
|
|
|
const string NetEMemory::name() const
|
2002-01-22 02:40:04 +01:00
|
|
|
{
|
|
|
|
|
return mem_->name();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetExpr* NetEMemory::index() const
|
|
|
|
|
{
|
|
|
|
|
return idx_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-02 05:13:30 +02:00
|
|
|
NetMemory::NetMemory(NetScope*sc, const string&n, long w, long s, long e)
|
2002-08-04 20:28:14 +02:00
|
|
|
: width_(w), idxh_(s), idxl_(e), ram_list_(0), scope_(sc)
|
1999-08-01 23:48:11 +02:00
|
|
|
{
|
2002-08-04 20:28:14 +02:00
|
|
|
name_ = strdup(n.c_str());
|
2000-05-02 05:13:30 +02:00
|
|
|
scope_->add_memory(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetMemory::~NetMemory()
|
|
|
|
|
{
|
|
|
|
|
assert(scope_);
|
|
|
|
|
scope_->rem_memory(this);
|
2002-08-04 20:28:14 +02:00
|
|
|
free(name_);
|
1999-08-01 23:48:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetMemory::count() const
|
|
|
|
|
{
|
|
|
|
|
if (idxh_ < idxl_)
|
|
|
|
|
return idxl_ - idxh_ + 1;
|
|
|
|
|
else
|
|
|
|
|
return idxh_ - idxl_ + 1;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-04 20:28:14 +02:00
|
|
|
const char* NetMemory::name() const
|
|
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-08-01 23:48:11 +02:00
|
|
|
unsigned NetMemory::index_to_address(long idx) const
|
|
|
|
|
{
|
|
|
|
|
if (idxh_ < idxl_)
|
|
|
|
|
return idx - idxh_;
|
|
|
|
|
else
|
|
|
|
|
return idx - idxl_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-04-19 03:59:36 +02:00
|
|
|
|
1999-05-30 03:11:46 +02:00
|
|
|
NetEMemory* NetEMemory::dup_expr() const
|
|
|
|
|
{
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-20 04:21:10 +02:00
|
|
|
NetEParam::NetEParam()
|
1999-09-21 02:13:40 +02:00
|
|
|
: des_(0)
|
1999-09-20 04:21:10 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-03 05:47:14 +01:00
|
|
|
NetEParam::NetEParam(Design*d, NetScope*s, const hname_t&n)
|
2000-03-08 05:36:53 +01:00
|
|
|
: des_(d), scope_(s), name_(n)
|
1999-09-20 04:21:10 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEParam::~NetEParam()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-07 05:38:08 +02:00
|
|
|
bool NetEParam::has_width() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-20 04:21:10 +02:00
|
|
|
NetEParam* NetEParam::dup_expr() const
|
|
|
|
|
{
|
2000-06-12 05:57:10 +02:00
|
|
|
return new NetEParam(des_, scope_, name_);
|
1999-09-20 04:21:10 +02:00
|
|
|
}
|
|
|
|
|
|
1999-11-27 20:07:57 +01:00
|
|
|
NetEScope::NetEScope(NetScope*s)
|
|
|
|
|
: scope_(s)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEScope::~NetEScope()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetScope* NetEScope::scope() const
|
|
|
|
|
{
|
|
|
|
|
return scope_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 20:20:07 +02:00
|
|
|
NetESFunc::NetESFunc(const string&n, unsigned width, unsigned np)
|
2000-10-05 07:03:01 +02:00
|
|
|
: name_(0)
|
2000-05-04 05:37:58 +02:00
|
|
|
{
|
2000-10-05 07:03:01 +02:00
|
|
|
name_ = new char [n.length()+1];
|
|
|
|
|
strcpy(name_, n.c_str());
|
2000-05-04 05:37:58 +02:00
|
|
|
expr_width(width);
|
2000-05-07 20:20:07 +02:00
|
|
|
nparms_ = np;
|
|
|
|
|
parms_ = new NetExpr*[np];
|
|
|
|
|
for (unsigned idx = 0 ; idx < nparms_ ; idx += 1)
|
|
|
|
|
parms_[idx] = 0;
|
2000-05-04 05:37:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetESFunc::~NetESFunc()
|
|
|
|
|
{
|
2000-05-07 20:20:07 +02:00
|
|
|
for (unsigned idx = 0 ; idx < nparms_ ; idx += 1)
|
|
|
|
|
if (parms_[idx]) delete parms_[idx];
|
|
|
|
|
|
|
|
|
|
delete[]parms_;
|
2000-10-05 07:03:01 +02:00
|
|
|
delete[]name_;
|
2000-05-04 05:37:58 +02:00
|
|
|
}
|
|
|
|
|
|
2000-10-05 07:03:01 +02:00
|
|
|
const char* NetESFunc::name() const
|
2000-05-04 05:37:58 +02:00
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 20:20:07 +02:00
|
|
|
unsigned NetESFunc::nparms() const
|
|
|
|
|
{
|
|
|
|
|
return nparms_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetESFunc::parm(unsigned idx, NetExpr*v)
|
|
|
|
|
{
|
|
|
|
|
assert(idx < nparms_);
|
|
|
|
|
if (parms_[idx])
|
|
|
|
|
delete parms_[idx];
|
|
|
|
|
parms_[idx] = v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetExpr* NetESFunc::parm(unsigned idx) const
|
|
|
|
|
{
|
|
|
|
|
assert(idx < nparms_);
|
|
|
|
|
return parms_[idx];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetExpr* NetESFunc::parm(unsigned idx)
|
|
|
|
|
{
|
|
|
|
|
assert(idx < nparms_);
|
|
|
|
|
return parms_[idx];
|
|
|
|
|
}
|
|
|
|
|
|
1999-02-08 03:49:56 +01:00
|
|
|
NetESignal::NetESignal(NetNet*n)
|
1999-11-29 00:42:02 +01:00
|
|
|
: NetExpr(n->pin_count()), net_(n)
|
1999-02-08 03:49:56 +01:00
|
|
|
{
|
2001-07-27 06:51:44 +02:00
|
|
|
msi_ = n->pin_count() - 1;
|
|
|
|
|
lsi_ = 0;
|
|
|
|
|
net_->incr_eref();
|
|
|
|
|
set_line(*n);
|
2001-12-31 01:08:14 +01:00
|
|
|
cast_signed(net_->get_signed());
|
2001-07-27 06:51:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetESignal::NetESignal(NetNet*n, unsigned m, unsigned l)
|
|
|
|
|
: NetExpr(m - l + 1), net_(n)
|
|
|
|
|
{
|
|
|
|
|
assert(m >= l);
|
|
|
|
|
msi_ = m;
|
|
|
|
|
lsi_ = l;
|
1999-11-29 00:42:02 +01:00
|
|
|
net_->incr_eref();
|
1999-06-02 17:38:46 +02:00
|
|
|
set_line(*n);
|
2001-12-31 01:08:14 +01:00
|
|
|
cast_signed(net_->get_signed());
|
1999-02-08 03:49:56 +01:00
|
|
|
}
|
|
|
|
|
|
1999-11-29 00:42:02 +01:00
|
|
|
NetESignal::~NetESignal()
|
1999-07-17 05:08:31 +02:00
|
|
|
{
|
1999-11-29 00:42:02 +01:00
|
|
|
net_->decr_eref();
|
1999-07-17 05:08:31 +02:00
|
|
|
}
|
|
|
|
|
|
2000-08-27 17:51:50 +02:00
|
|
|
string NetESignal::name() const
|
1998-11-07 20:17:10 +01:00
|
|
|
{
|
1999-11-29 00:42:02 +01:00
|
|
|
return net_->name();
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-27 06:51:44 +02:00
|
|
|
unsigned NetESignal::bit_count() const
|
1999-11-29 00:42:02 +01:00
|
|
|
{
|
2001-07-27 06:51:44 +02:00
|
|
|
return msi_ - lsi_ + 1;
|
1999-11-29 00:42:02 +01:00
|
|
|
}
|
|
|
|
|
|
2001-07-27 06:51:44 +02:00
|
|
|
Link& NetESignal::bit(unsigned idx)
|
1999-11-29 00:42:02 +01:00
|
|
|
{
|
2001-07-27 06:51:44 +02:00
|
|
|
assert(idx <= (msi_ - lsi_));
|
|
|
|
|
return net_->pin(idx + lsi_);
|
1998-11-07 20:17:10 +01:00
|
|
|
}
|
|
|
|
|
|
2001-07-22 02:17:49 +02:00
|
|
|
const NetNet* NetESignal::sig() const
|
|
|
|
|
{
|
|
|
|
|
return net_;
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-27 06:51:44 +02:00
|
|
|
unsigned NetESignal::lsi() const
|
|
|
|
|
{
|
|
|
|
|
return lsi_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned NetESignal::msi() const
|
|
|
|
|
{
|
|
|
|
|
return msi_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEBitSel::NetEBitSel(NetESignal*sig, NetExpr*ex)
|
1999-04-25 02:44:10 +02:00
|
|
|
: sig_(sig), idx_(ex)
|
|
|
|
|
{
|
1999-10-31 05:11:27 +01:00
|
|
|
// This supports mux type indexing of an expression, so the
|
1999-07-16 06:33:41 +02:00
|
|
|
// with is by definition 1 bit.
|
|
|
|
|
expr_width(1);
|
1999-04-25 02:44:10 +02:00
|
|
|
}
|
|
|
|
|
|
2001-07-27 06:51:44 +02:00
|
|
|
NetEBitSel::~NetEBitSel()
|
1999-04-25 02:44:10 +02:00
|
|
|
{
|
1999-05-30 03:11:46 +02:00
|
|
|
delete idx_;
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-27 06:51:44 +02:00
|
|
|
string NetEBitSel::name() const
|
2000-08-27 17:51:50 +02:00
|
|
|
{
|
|
|
|
|
return sig_->name();
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-27 06:51:44 +02:00
|
|
|
const NetNet* NetEBitSel::sig() const
|
2001-07-22 02:17:49 +02:00
|
|
|
{
|
|
|
|
|
return sig_->sig();
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-27 06:51:44 +02:00
|
|
|
NetEBitSel* NetEBitSel::dup_expr() const
|
1999-05-30 03:11:46 +02:00
|
|
|
{
|
|
|
|
|
assert(0);
|
1999-04-25 02:44:10 +02:00
|
|
|
}
|
|
|
|
|
|
1999-07-17 21:50:59 +02:00
|
|
|
NetETernary::NetETernary(NetExpr*c, NetExpr*t, NetExpr*f)
|
|
|
|
|
: cond_(c), true_val_(t), false_val_(f)
|
|
|
|
|
{
|
|
|
|
|
expr_width(true_val_->expr_width());
|
2002-04-14 21:02:34 +02:00
|
|
|
cast_signed(c->has_sign() && t->has_sign() && f->has_sign());
|
1999-07-17 21:50:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetETernary::~NetETernary()
|
|
|
|
|
{
|
|
|
|
|
delete cond_;
|
|
|
|
|
delete true_val_;
|
|
|
|
|
delete false_val_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-11 06:43:17 +02:00
|
|
|
const NetExpr* NetETernary::cond_expr() const
|
|
|
|
|
{
|
|
|
|
|
return cond_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetExpr* NetETernary::true_expr() const
|
|
|
|
|
{
|
|
|
|
|
return true_val_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetExpr* NetETernary::false_expr() const
|
|
|
|
|
{
|
|
|
|
|
return false_val_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-28 05:11:29 +02:00
|
|
|
NetEUnary::NetEUnary(char op, NetExpr*ex)
|
|
|
|
|
: NetExpr(ex->expr_width()), op_(op), expr_(ex)
|
|
|
|
|
{
|
2001-11-19 05:26:46 +01:00
|
|
|
switch (op_) {
|
|
|
|
|
case '!':
|
|
|
|
|
expr_width(1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-02-01 06:09:14 +01:00
|
|
|
switch (op_) {
|
|
|
|
|
case '-':
|
|
|
|
|
case '+':
|
|
|
|
|
cast_signed(ex->has_sign());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
;
|
|
|
|
|
}
|
1999-09-28 05:11:29 +02:00
|
|
|
}
|
|
|
|
|
|
1998-11-07 20:17:10 +01:00
|
|
|
NetEUnary::~NetEUnary()
|
|
|
|
|
{
|
1999-05-30 03:11:46 +02:00
|
|
|
delete expr_;
|
1998-11-07 20:17:10 +01:00
|
|
|
}
|
|
|
|
|
|
1999-11-04 04:53:26 +01:00
|
|
|
NetEUBits::NetEUBits(char op, NetExpr*ex)
|
|
|
|
|
: NetEUnary(op, ex)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEUBits::~NetEUBits()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-29 06:24:00 +01:00
|
|
|
NetEUReduce::NetEUReduce(char op, NetExpr*ex)
|
|
|
|
|
: NetEUnary(op, ex)
|
|
|
|
|
{
|
|
|
|
|
expr_width(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetEUReduce::~NetEUReduce()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-07 21:45:42 +02:00
|
|
|
NetLogic::NetLogic(NetScope*s, const string&n, unsigned pins, TYPE t)
|
|
|
|
|
: NetNode(s, n, pins), type_(t)
|
1998-12-02 05:37:13 +01:00
|
|
|
{
|
|
|
|
|
pin(0).set_dir(Link::OUTPUT);
|
1999-10-31 05:11:27 +01:00
|
|
|
pin(0).set_name("O", 0);
|
|
|
|
|
for (unsigned idx = 1 ; idx < pins ; idx += 1) {
|
1998-12-02 05:37:13 +01:00
|
|
|
pin(idx).set_dir(Link::INPUT);
|
1999-10-31 05:11:27 +01:00
|
|
|
pin(idx).set_name("I", idx-1);
|
|
|
|
|
}
|
1998-12-02 05:37:13 +01:00
|
|
|
}
|
|
|
|
|
|
1999-09-30 23:28:34 +02:00
|
|
|
NetTaskDef::NetTaskDef(const string&n, const svector<NetNet*>&po)
|
|
|
|
|
: name_(n), proc_(0), ports_(po)
|
1999-07-03 04:12:51 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetTaskDef::~NetTaskDef()
|
|
|
|
|
{
|
|
|
|
|
delete proc_;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-30 23:28:34 +02:00
|
|
|
void NetTaskDef::set_proc(NetProc*p)
|
|
|
|
|
{
|
|
|
|
|
assert(proc_ == 0);
|
|
|
|
|
proc_ = p;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-18 03:02:53 +02:00
|
|
|
unsigned NetTaskDef::port_count() const
|
|
|
|
|
{
|
|
|
|
|
return ports_.count();
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-24 04:11:19 +02:00
|
|
|
NetNet* NetTaskDef::port(unsigned idx)
|
|
|
|
|
{
|
|
|
|
|
assert(idx < ports_.count());
|
|
|
|
|
return ports_[idx];
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-18 03:02:53 +02:00
|
|
|
const string& NetTaskDef::name() const
|
|
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NetProc*NetTaskDef::proc() const
|
|
|
|
|
{
|
|
|
|
|
return proc_;
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
/*
|
|
|
|
|
* $Log: netlist.cc,v $
|
2002-08-19 02:06:11 +02:00
|
|
|
* Revision 1.198 2002/08/19 00:06:12 steve
|
|
|
|
|
* Allow release to handle removal of target net.
|
|
|
|
|
*
|
2002-08-12 03:34:58 +02:00
|
|
|
* Revision 1.197 2002/08/12 01:34:59 steve
|
|
|
|
|
* conditional ident string using autoconfig.
|
|
|
|
|
*
|
2002-08-04 20:28:14 +02:00
|
|
|
* Revision 1.196 2002/08/04 18:28:15 steve
|
|
|
|
|
* Do not use hierarchical names of memories to
|
|
|
|
|
* generate vvp labels. -tdll target does not
|
|
|
|
|
* used hierarchical name string to look up the
|
|
|
|
|
* memory objects in the design.
|
|
|
|
|
*
|
2002-07-29 01:58:44 +02:00
|
|
|
* Revision 1.195 2002/07/28 23:58:44 steve
|
|
|
|
|
* Fix NetBlock destructor to delete substatements.
|
|
|
|
|
*
|
2002-07-24 18:24:45 +02:00
|
|
|
* Revision 1.194 2002/07/24 16:24:45 steve
|
|
|
|
|
* Rewrite find_similar_event to support doing
|
|
|
|
|
* all event matching and replacement in one
|
|
|
|
|
* shot, saving time in the scans.
|
|
|
|
|
*
|
2002-07-02 05:02:57 +02:00
|
|
|
* Revision 1.193 2002/07/02 03:02:57 steve
|
|
|
|
|
* Change the signal to a net when assignments go away.
|
|
|
|
|
*
|
2002-06-21 06:59:35 +02:00
|
|
|
* Revision 1.192 2002/06/21 04:59:35 steve
|
|
|
|
|
* Carry integerness throughout the compilation.
|
|
|
|
|
*
|
2002-06-19 06:20:03 +02:00
|
|
|
* Revision 1.191 2002/06/19 04:20:03 steve
|
|
|
|
|
* Remove NetTmp and add NetSubnet class.
|
|
|
|
|
*
|
2002-06-05 05:44:25 +02:00
|
|
|
* Revision 1.190 2002/06/05 03:44:25 steve
|
|
|
|
|
* Add support for memory words in l-value of
|
|
|
|
|
* non-blocking assignments, and remove the special
|
|
|
|
|
* NetAssignMem_ and NetAssignMemNB classes.
|
|
|
|
|
*
|
2002-06-04 07:38:43 +02:00
|
|
|
* Revision 1.189 2002/06/04 05:38:44 steve
|
|
|
|
|
* Add support for memory words in l-value of
|
|
|
|
|
* blocking assignments, and remove the special
|
|
|
|
|
* NetAssignMem class.
|
|
|
|
|
*
|
2002-05-27 02:08:45 +02:00
|
|
|
* Revision 1.188 2002/05/27 00:08:45 steve
|
|
|
|
|
* Support carrying the scope of named begin-end
|
|
|
|
|
* blocks down to the code generator, and have
|
|
|
|
|
* the vvp code generator use that to support disable.
|
|
|
|
|
*
|
2002-05-26 03:39:02 +02:00
|
|
|
* Revision 1.187 2002/05/26 01:39:02 steve
|
|
|
|
|
* Carry Verilog 2001 attributes with processes,
|
|
|
|
|
* all the way through to the ivl_target API.
|
|
|
|
|
*
|
|
|
|
|
* Divide signal reference counts between rval
|
|
|
|
|
* and lval references.
|
|
|
|
|
*
|
2002-05-23 05:08:50 +02:00
|
|
|
* Revision 1.186 2002/05/23 03:08:51 steve
|
|
|
|
|
* Add language support for Verilog-2001 attribute
|
|
|
|
|
* syntax. Hook this support into existing $attribute
|
|
|
|
|
* handling, and add number and void value types.
|
|
|
|
|
*
|
|
|
|
|
* Add to the ivl_target API new functions for access
|
|
|
|
|
* of complex attributes attached to gates.
|
|
|
|
|
*
|
2002-05-05 23:11:49 +02:00
|
|
|
* Revision 1.185 2002/05/05 21:11:50 steve
|
|
|
|
|
* Put off evaluation of concatenation repeat expresions
|
|
|
|
|
* until after parameters are defined. This allows parms
|
|
|
|
|
* to be used in repeat expresions.
|
|
|
|
|
*
|
|
|
|
|
* Add the builtin $signed system function.
|
1998-11-04 00:28:49 +01:00
|
|
|
*/
|
|
|
|
|
|