Support the creation of scopes.
This commit is contained in:
parent
ac25dc03a8
commit
4cfa3e4047
|
|
@ -18,7 +18,7 @@
|
|||
# 59 Temple Place - Suite 330
|
||||
# Boston, MA 02111-1307, USA
|
||||
#
|
||||
#ident "$Id: Makefile.in,v 1.28 1999/11/18 03:52:19 steve Exp $"
|
||||
#ident "$Id: Makefile.in,v 1.29 1999/11/27 19:07:57 steve Exp $"
|
||||
#
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
|
|
@ -68,8 +68,8 @@ distclean: clean
|
|||
TT = t-null.o t-verilog.o t-vvm.o t-xnf.o
|
||||
FF = nobufz.o nodangle.o propinit.o sigfold.o synth.o xnfio.o xnfsyn.o
|
||||
|
||||
O = main.o cprop.o design_dump.o elaborate.o elab_expr.o elab_net.o \
|
||||
emit.o eval.o eval_tree.o expr_synth.o functor.o \
|
||||
O = main.o cprop.o design_dump.o dup_expr.o elaborate.o elab_expr.o \
|
||||
elab_net.o emit.o eval.o eval_tree.o expr_synth.o functor.o \
|
||||
lexor.o lexor_keyword.o mangle.o netlist.o pad_to_width.o \
|
||||
parse.o parse_misc.o pform.o pform_dump.o \
|
||||
set_width.o \
|
||||
|
|
|
|||
8
Module.h
8
Module.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: Module.h,v 1.9 1999/08/23 16:48:39 steve Exp $"
|
||||
#ident "$Id: Module.h,v 1.10 1999/11/27 19:07:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <list>
|
||||
|
|
@ -33,6 +33,7 @@ class PFunction;
|
|||
class PWire;
|
||||
class PProcess;
|
||||
class Design;
|
||||
class NetScope;
|
||||
|
||||
/*
|
||||
* A module is a named container and scope. A module holds a bunch of
|
||||
|
|
@ -93,7 +94,7 @@ class Module {
|
|||
const list<PProcess*>& get_behaviors() const { return behaviors_; }
|
||||
|
||||
void dump(ostream&out) const;
|
||||
bool elaborate(Design*, const string&path, svector<PExpr*>*overrides_) const;
|
||||
bool elaborate(Design*, NetScope*scope, svector<PExpr*>*overrides_) const;
|
||||
|
||||
private:
|
||||
const string name_;
|
||||
|
|
@ -113,6 +114,9 @@ class Module {
|
|||
|
||||
/*
|
||||
* $Log: Module.h,v $
|
||||
* Revision 1.10 1999/11/27 19:07:57 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.9 1999/08/23 16:48:39 steve
|
||||
* Parameter overrides support from Peter Monta
|
||||
* AND and XOR support wide expressions.
|
||||
|
|
|
|||
7
PWire.h
7
PWire.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: PWire.h,v 1.5 1999/06/17 05:34:42 steve Exp $"
|
||||
#ident "$Id: PWire.h,v 1.6 1999/11/27 19:07:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "netlist.h"
|
||||
|
|
@ -58,7 +58,7 @@ class PWire : public LineInfo {
|
|||
// Write myself to the specified stream.
|
||||
void dump(ostream&out) const;
|
||||
|
||||
void elaborate(Design*, const string&path) const;
|
||||
void elaborate(Design*, NetScope*scope) const;
|
||||
|
||||
private:
|
||||
string name_;
|
||||
|
|
@ -82,6 +82,9 @@ class PWire : public LineInfo {
|
|||
|
||||
/*
|
||||
* $Log: PWire.h,v $
|
||||
* Revision 1.6 1999/11/27 19:07:57 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.5 1999/06/17 05:34:42 steve
|
||||
* Clean up interface of the PWire class,
|
||||
* Properly match wire ranges.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: design_dump.cc,v 1.59 1999/11/24 04:01:58 steve Exp $"
|
||||
#ident "$Id: design_dump.cc,v 1.60 1999/11/27 19:07:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -49,6 +49,8 @@ void NetNet::dump_net(ostream&o, unsigned ind) const
|
|||
pin_count() << "]";
|
||||
if (local_flag_)
|
||||
o << " (local)";
|
||||
if (scope_)
|
||||
o << " scope=" << scope_->name();
|
||||
o << " #(" << rise_time() << "," << fall_time() << "," <<
|
||||
decay_time() << ") init=";
|
||||
for (unsigned idx = pin_count() ; idx > 0 ; idx -= 1)
|
||||
|
|
@ -581,7 +583,19 @@ void NetRepeat::dump(ostream&o, unsigned ind) const
|
|||
|
||||
void NetScope::dump(ostream&o) const
|
||||
{
|
||||
o << name_ << endl;
|
||||
o << name_;
|
||||
switch (type_) {
|
||||
case BEGIN_END:
|
||||
o << " sequential block";
|
||||
break;
|
||||
case FORK_JOIN:
|
||||
o << " parallel block";
|
||||
break;
|
||||
case MODULE:
|
||||
o << " module";
|
||||
break;
|
||||
}
|
||||
o << endl;
|
||||
}
|
||||
|
||||
void NetSTask::dump(ostream&o, unsigned ind) const
|
||||
|
|
@ -710,6 +724,11 @@ void NetEIdent::dump(ostream&o) const
|
|||
o << name_;
|
||||
}
|
||||
|
||||
void NetEScope::dump(ostream&o) const
|
||||
{
|
||||
o << "<scope=" << scope_->name() << ">";
|
||||
}
|
||||
|
||||
void NetESignal::dump(ostream&o) const
|
||||
{
|
||||
o << name();
|
||||
|
|
@ -855,6 +874,9 @@ void Design::dump(ostream&o) const
|
|||
|
||||
/*
|
||||
* $Log: design_dump.cc,v $
|
||||
* Revision 1.60 1999/11/27 19:07:57 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.59 1999/11/24 04:01:58 steve
|
||||
* Detect and list scope names.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 1999 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)
|
||||
#ident "$Id: dup_expr.cc,v 1.1 1999/11/27 19:07:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "netlist.h"
|
||||
# include <cassert>
|
||||
|
||||
NetEScope* NetEScope::dup_expr() const
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: dup_expr.cc,v $
|
||||
* Revision 1.1 1999/11/27 19:07:57 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
*/
|
||||
|
||||
11
elab_expr.cc
11
elab_expr.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: elab_expr.cc,v 1.9 1999/11/21 17:35:37 steve Exp $"
|
||||
#ident "$Id: elab_expr.cc,v 1.10 1999/11/27 19:07:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -181,6 +181,12 @@ NetExpr* PEIdent::elaborate_expr(Design*des, const string&path) const
|
|||
return tmp;
|
||||
}
|
||||
|
||||
if (NetScope*nsc = des->find_scope(text_)) {
|
||||
NetEScope*tmp = new NetEScope(nsc);
|
||||
tmp->set_line(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// If the identifier names a signal (a register or wire)
|
||||
// then create a NetESignal node to handle it.
|
||||
if (NetNet*net = des->find_signal(path, text_)) {
|
||||
|
|
@ -324,6 +330,9 @@ NetExpr*PETernary::elaborate_expr(Design*des, const string&path) const
|
|||
|
||||
/*
|
||||
* $Log: elab_expr.cc,v $
|
||||
* Revision 1.10 1999/11/27 19:07:57 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.9 1999/11/21 17:35:37 steve
|
||||
* Memory name lookup handles scopes.
|
||||
*
|
||||
|
|
|
|||
33
elab_net.cc
33
elab_net.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: elab_net.cc,v 1.8 1999/11/21 17:35:37 steve Exp $"
|
||||
#ident "$Id: elab_net.cc,v 1.9 1999/11/27 19:07:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "PExpr.h"
|
||||
|
|
@ -73,7 +73,7 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
|
|||
switch (op_) {
|
||||
case '^': // XOR
|
||||
assert(lsig->pin_count() == rsig->pin_count());
|
||||
osig = new NetNet(des->local_symbol(path), NetNet::WIRE,
|
||||
osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
|
||||
lsig->pin_count());
|
||||
osig->local_flag(true);
|
||||
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
|
||||
|
|
@ -92,7 +92,7 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
|
|||
|
||||
case '&': // AND
|
||||
assert(lsig->pin_count() == rsig->pin_count());
|
||||
osig = new NetNet(des->local_symbol(path), NetNet::WIRE,
|
||||
osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
|
||||
lsig->pin_count());
|
||||
osig->local_flag(true);
|
||||
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
|
||||
|
|
@ -111,7 +111,7 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
|
|||
|
||||
case '|': // Bitwise OR
|
||||
assert(lsig->pin_count() == rsig->pin_count());
|
||||
osig = new NetNet(des->local_symbol(path), NetNet::WIRE,
|
||||
osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
|
||||
lsig->pin_count());
|
||||
osig->local_flag(true);
|
||||
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
|
||||
|
|
@ -156,7 +156,7 @@ NetNet* PEBinary::elaborate_net(Design*des, const string&path,
|
|||
}
|
||||
|
||||
// The output is the AND of the two logic values.
|
||||
osig = new NetNet(des->local_symbol(path), NetNet::WIRE);
|
||||
osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
|
||||
osig->local_flag(true);
|
||||
connect(gate->pin(0), osig->pin(0));
|
||||
des->add_signal(osig);
|
||||
|
|
@ -237,7 +237,7 @@ NetNet* PEBinary::elaborate_net_add_(Design*des, const string&path,
|
|||
width = rsig->pin_count();
|
||||
|
||||
// Make the adder as wide as the widest operand
|
||||
osig = new NetNet(des->local_symbol(path), NetNet::WIRE, width);
|
||||
osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE, width);
|
||||
NetAddSub*adder = new NetAddSub(name, width);
|
||||
|
||||
// Connect the adder to the various parts.
|
||||
|
|
@ -306,7 +306,7 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, const string&path,
|
|||
return 0;
|
||||
}
|
||||
|
||||
NetNet*osig = new NetNet(des->local_symbol(path), NetNet::WIRE);
|
||||
NetNet*osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
|
||||
osig->local_flag(true);
|
||||
|
||||
NetNode*gate;
|
||||
|
|
@ -356,7 +356,7 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, const string&path,
|
|||
des->add_node(gate_t);
|
||||
|
||||
// Attach a label to this intermediate wire
|
||||
NetNet*tmp = new NetNet(des->local_symbol(path),
|
||||
NetNet*tmp = new NetNet(0, des->local_symbol(path),
|
||||
NetNet::WIRE);
|
||||
tmp->local_flag(true);
|
||||
connect(gate_t->pin(0), tmp->pin(0));
|
||||
|
|
@ -430,7 +430,7 @@ NetNet* PEBinary::elaborate_net_shift_(Design*des, const string&path,
|
|||
/* Very special case, constant 0 shift. */
|
||||
if (dist == 0) return lsig;
|
||||
|
||||
NetNet*osig = new NetNet(des->local_symbol(path), NetNet::WIRE,
|
||||
NetNet*osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
|
||||
lsig->pin_count());
|
||||
osig->local_flag(true);
|
||||
|
||||
|
|
@ -469,7 +469,7 @@ NetNet* PEBinary::elaborate_net_shift_(Design*des, const string&path,
|
|||
lsig->pin_count(),
|
||||
rsig->pin_count());
|
||||
|
||||
NetNet*osig = new NetNet(des->local_symbol(path), NetNet::WIRE,
|
||||
NetNet*osig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
|
||||
lsig->pin_count());
|
||||
osig->local_flag(true);
|
||||
|
||||
|
|
@ -514,7 +514,7 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
|
|||
const NetEConst*pc = dynamic_cast<const NetEConst*>(pe);
|
||||
assert(pc);
|
||||
verinum pvalue = pc->value();
|
||||
sig = new NetNet(path+"."+text_, NetNet::IMPLICIT,
|
||||
sig = new NetNet(0, path+"."+text_, NetNet::IMPLICIT,
|
||||
pc->expr_width());
|
||||
for (unsigned idx = 0; idx < sig->pin_count(); idx += 1) {
|
||||
NetConst*cp = new NetConst(des->local_symbol(path),
|
||||
|
|
@ -525,7 +525,7 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
|
|||
|
||||
} else {
|
||||
|
||||
sig = new NetNet(path+"."+text_, NetNet::IMPLICIT, 1);
|
||||
sig = new NetNet(0, path+"."+text_, NetNet::IMPLICIT, 1);
|
||||
des->add_signal(sig);
|
||||
cerr << get_line() << ": warning: Implicitly defining "
|
||||
"wire " << path << "." << text_ << "." << endl;
|
||||
|
|
@ -666,7 +666,7 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
|
|||
}
|
||||
|
||||
/* Fine, create an implicit wire as an l-value. */
|
||||
sig = new NetNet(path+"."+text_, NetNet::IMPLICIT, 1);
|
||||
sig = new NetNet(0, path+"."+text_, NetNet::IMPLICIT, 1);
|
||||
des->add_signal(sig);
|
||||
cerr << get_line() << ": warning: Implicitly defining "
|
||||
"wire " << path << "." << text_ << "." << endl;
|
||||
|
|
@ -758,7 +758,7 @@ NetNet* PENumber::elaborate_net(Design*des, const string&path,
|
|||
if ((lwidth > 0) && (lwidth < width))
|
||||
width = lwidth;
|
||||
|
||||
NetNet*net = new NetNet(des->local_symbol(path),
|
||||
NetNet*net = new NetNet(0, des->local_symbol(path),
|
||||
NetNet::IMPLICIT, width);
|
||||
net->local_flag(true);
|
||||
for (unsigned idx = 0 ; idx < width ; idx += 1) {
|
||||
|
|
@ -795,7 +795,7 @@ NetNet* PETernary::elaborate_net(Design*des, const string&path,
|
|||
assert(width == tru_sig->pin_count());
|
||||
assert(expr_sig->pin_count() == 1);
|
||||
|
||||
NetNet*sig = new NetNet(des->local_symbol(path), NetNet::WIRE,
|
||||
NetNet*sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
|
||||
tru_sig->pin_count());
|
||||
sig->local_flag(true);
|
||||
|
||||
|
|
@ -816,6 +816,9 @@ NetNet* PETernary::elaborate_net(Design*des, const string&path,
|
|||
|
||||
/*
|
||||
* $Log: elab_net.cc,v $
|
||||
* Revision 1.9 1999/11/27 19:07:57 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.8 1999/11/21 17:35:37 steve
|
||||
* Memory name lookup handles scopes.
|
||||
*
|
||||
|
|
|
|||
89
elaborate.cc
89
elaborate.cc
|
|
@ -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.129 1999/11/24 04:01:58 steve Exp $"
|
||||
#ident "$Id: elaborate.cc,v 1.130 1999/11/27 19:07:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -54,8 +54,9 @@ static const map<string,PUdp*>* udplist = 0;
|
|||
* elaboration this creates an object in the design that represent the
|
||||
* defined item.
|
||||
*/
|
||||
void PWire::elaborate(Design*des, const string&path) const
|
||||
void PWire::elaborate(Design*des, NetScope*scope) const
|
||||
{
|
||||
const string path = scope->name();
|
||||
NetNet::Type wtype = type_;
|
||||
if (wtype == NetNet::IMPLICIT)
|
||||
wtype = NetNet::WIRE;
|
||||
|
|
@ -141,7 +142,7 @@ void PWire::elaborate(Design*des, const string&path) const
|
|||
|
||||
} else {
|
||||
|
||||
NetNet*sig = new NetNet(path + "." + name_, wtype, msb, lsb);
|
||||
NetNet*sig = new NetNet(scope, path + "." + name_, wtype, msb, lsb);
|
||||
sig->set_line(*this);
|
||||
sig->port_type(port_type_);
|
||||
sig->set_attributes(attributes);
|
||||
|
|
@ -376,7 +377,8 @@ void PGBuiltin::elaborate(Design*des, const string&path) const
|
|||
void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
|
||||
{
|
||||
assert(get_name() != "");
|
||||
const string my_name = des->make_scope(path, get_name());
|
||||
NetScope*my_scope = des->make_scope(path, NetScope::MODULE, get_name());
|
||||
const string my_name = my_scope -> name();
|
||||
|
||||
const svector<PExpr*>*pins;
|
||||
|
||||
|
|
@ -445,7 +447,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
|
|||
// elaboration causes the module to generate a netlist with
|
||||
// the ports represented by NetNet objects. I will find them
|
||||
// later.
|
||||
rmod->elaborate(des, my_name, overrides_);
|
||||
rmod->elaborate(des, my_scope, overrides_);
|
||||
|
||||
// Now connect the ports of the newly elaborated designs to
|
||||
// the expressions that are the instantiation parameters. Scan
|
||||
|
|
@ -635,7 +637,7 @@ NetNet* PEConcat::elaborate_net(Design*des, const string&path,
|
|||
operands, and connect it up. Scan the operands of the
|
||||
concat operator from least significant to most significant,
|
||||
which is opposite from how they are given in the list. */
|
||||
NetNet*osig = new NetNet(des->local_symbol(path),
|
||||
NetNet*osig = new NetNet(0, des->local_symbol(path),
|
||||
NetNet::IMPLICIT, pins);
|
||||
pins = 0;
|
||||
for (unsigned idx = nets.count() ; idx > 0 ; idx -= 1) {
|
||||
|
|
@ -690,7 +692,7 @@ NetNet* PEConcat::elaborate_lnet(Design*des, const string&path) const
|
|||
operands, and connect it up. Scan the operands of the
|
||||
concat operator from least significant to most significant,
|
||||
which is opposite from how they are given in the list. */
|
||||
NetNet*osig = new NetNet(des->local_symbol(path),
|
||||
NetNet*osig = new NetNet(0, des->local_symbol(path),
|
||||
NetNet::IMPLICIT, pins);
|
||||
pins = 0;
|
||||
for (unsigned idx = nets.count() ; idx > 0 ; idx -= 1) {
|
||||
|
|
@ -724,7 +726,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
|
|||
NetLogic*gate;
|
||||
switch (op_) {
|
||||
case '~': // Bitwise NOT
|
||||
sig = new NetNet(des->local_symbol(path), NetNet::WIRE,
|
||||
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE,
|
||||
sub_sig->pin_count());
|
||||
sig->local_flag(true);
|
||||
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1) {
|
||||
|
|
@ -742,7 +744,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
|
|||
|
||||
case 'N': // Reduction NOR
|
||||
case '!': // Reduction NOT
|
||||
sig = new NetNet(des->local_symbol(path), NetNet::WIRE);
|
||||
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
|
||||
sig->local_flag(true);
|
||||
gate = new NetLogic(des->local_symbol(path),
|
||||
1+sub_sig->pin_count(),
|
||||
|
|
@ -759,7 +761,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
|
|||
break;
|
||||
|
||||
case '&': // Reduction AND
|
||||
sig = new NetNet(des->local_symbol(path), NetNet::WIRE);
|
||||
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
|
||||
sig->local_flag(true);
|
||||
gate = new NetLogic(des->local_symbol(path),
|
||||
1+sub_sig->pin_count(),
|
||||
|
|
@ -776,7 +778,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
|
|||
break;
|
||||
|
||||
case '|': // Reduction OR
|
||||
sig = new NetNet(des->local_symbol(path), NetNet::WIRE);
|
||||
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
|
||||
sig->local_flag(true);
|
||||
gate = new NetLogic(des->local_symbol(path),
|
||||
1+sub_sig->pin_count(),
|
||||
|
|
@ -793,7 +795,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
|
|||
break;
|
||||
|
||||
case '^': // Reduction XOR
|
||||
sig = new NetNet(des->local_symbol(path), NetNet::WIRE);
|
||||
sig = new NetNet(0, des->local_symbol(path), NetNet::WIRE);
|
||||
sig->local_flag(true);
|
||||
gate = new NetLogic(des->local_symbol(path),
|
||||
1+sub_sig->pin_count(),
|
||||
|
|
@ -1124,7 +1126,7 @@ NetProc* PAssign::elaborate(Design*des, const string&path) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
NetNet*tmp = new NetNet(n, NetNet::REG, wid);
|
||||
NetNet*tmp = new NetNet(0, n, NetNet::REG, wid);
|
||||
tmp->set_line(*this);
|
||||
des->add_signal(tmp);
|
||||
|
||||
|
|
@ -1322,7 +1324,9 @@ NetProc* PBlock::elaborate(Design*des, const string&path) const
|
|||
NetBlock*cur = new NetBlock(type);
|
||||
bool fail_flag = false;
|
||||
|
||||
string npath = name_.length()? des->make_scope(path, name_) : path;
|
||||
string npath = name_.length()
|
||||
? des->make_scope(path, NetScope::BEGIN_END, name_) -> name()
|
||||
: path;
|
||||
|
||||
// Handle the special case that the block contains only one
|
||||
// statement. There is no need to keep the block node.
|
||||
|
|
@ -1949,8 +1953,9 @@ NetProc* PWhile::elaborate(Design*des, const string&path) const
|
|||
return loop;
|
||||
}
|
||||
|
||||
bool Module::elaborate(Design*des, const string&path, svector<PExpr*>*overrides_) const
|
||||
bool Module::elaborate(Design*des, NetScope*scope, svector<PExpr*>*overrides_) const
|
||||
{
|
||||
const string path = scope->name();
|
||||
bool result_flag = true;
|
||||
|
||||
// Generate all the parameters that this instance of this
|
||||
|
|
@ -2035,7 +2040,7 @@ bool Module::elaborate(Design*des, const string&path, svector<PExpr*>*overrides_
|
|||
; wt != wl.end()
|
||||
; wt ++ ) {
|
||||
|
||||
(*wt)->elaborate(des, path);
|
||||
(*wt)->elaborate(des, scope);
|
||||
}
|
||||
|
||||
// Elaborate functions.
|
||||
|
|
@ -2129,11 +2134,11 @@ Design* elaborate(const map<string,Module*>&modules,
|
|||
// module and elaborate what I find.
|
||||
Design*des = new Design;
|
||||
|
||||
des->make_root_scope(root);
|
||||
NetScope*scope = des->make_root_scope(root);
|
||||
|
||||
modlist = &modules;
|
||||
udplist = &primitives;
|
||||
bool rc = rmod->elaborate(des, root, (svector<PExpr*>*)0);
|
||||
bool rc = rmod->elaborate(des, scope, (svector<PExpr*>*)0);
|
||||
modlist = 0;
|
||||
udplist = 0;
|
||||
|
||||
|
|
@ -2147,6 +2152,9 @@ Design* elaborate(const map<string,Module*>&modules,
|
|||
|
||||
/*
|
||||
* $Log: elaborate.cc,v $
|
||||
* Revision 1.130 1999/11/27 19:07:57 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.129 1999/11/24 04:01:58 steve
|
||||
* Detect and list scope names.
|
||||
*
|
||||
|
|
@ -2252,50 +2260,5 @@ Design* elaborate(const map<string,Module*>&modules,
|
|||
* Allow expanding of additive operators.
|
||||
*
|
||||
* Revision 1.100 1999/09/25 02:57:30 steve
|
||||
* Parse system function calls.
|
||||
*
|
||||
* Revision 1.99 1999/09/23 03:56:57 steve
|
||||
* Support shift operators.
|
||||
*
|
||||
* Revision 1.98 1999/09/23 02:28:27 steve
|
||||
* internal error message for funky comparison width.
|
||||
*
|
||||
* Revision 1.97 1999/09/23 00:21:54 steve
|
||||
* Move set_width methods into a single file,
|
||||
* Add the NetEBLogic class for logic expressions,
|
||||
* Fix error setting with of && in if statements.
|
||||
*
|
||||
* Revision 1.96 1999/09/22 21:25:42 steve
|
||||
* Expand bits in delayed assignments.
|
||||
*
|
||||
* Revision 1.95 1999/09/22 04:30:04 steve
|
||||
* Parse and elaborate named for/join blocks.
|
||||
*
|
||||
* Revision 1.94 1999/09/22 02:00:48 steve
|
||||
* assignment with blocking event delay.
|
||||
*
|
||||
* Revision 1.93 1999/09/20 02:21:10 steve
|
||||
* Elaborate parameters in phases.
|
||||
*
|
||||
* Revision 1.92 1999/09/18 22:23:50 steve
|
||||
* Match bit widths comming out of task output ports.
|
||||
*
|
||||
* Revision 1.91 1999/09/18 02:51:35 steve
|
||||
* report non-constant part select expressions.
|
||||
*
|
||||
* Revision 1.90 1999/09/18 01:53:08 steve
|
||||
* Detect constant lessthen-equal expressions.
|
||||
*
|
||||
* Revision 1.89 1999/09/17 02:06:25 steve
|
||||
* Handle unconnected module ports.
|
||||
*
|
||||
* Revision 1.88 1999/09/16 04:18:15 steve
|
||||
* elaborate concatenation repeats.
|
||||
*
|
||||
* Revision 1.87 1999/09/16 00:33:45 steve
|
||||
* Handle implicit !=0 in if statements.
|
||||
*
|
||||
* Revision 1.86 1999/09/15 04:17:52 steve
|
||||
* separate assign lval elaboration for error checking.
|
||||
*/
|
||||
|
||||
|
|
|
|||
17
emit.cc
17
emit.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: emit.cc,v 1.29 1999/11/21 00:13:08 steve Exp $"
|
||||
#ident "$Id: emit.cc,v 1.30 1999/11/27 19:07:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -255,6 +255,13 @@ bool Design::emit(ostream&o, struct target_t*tgt) const
|
|||
bool rc = true;
|
||||
tgt->start_design(o, this);
|
||||
|
||||
// enumerate the scopes
|
||||
{ map<string,NetScope*>::const_iterator sc;
|
||||
for (sc = scopes_.begin() ; sc != scopes_.end() ; sc++) {
|
||||
tgt->scope(o, (*sc).second);
|
||||
}
|
||||
}
|
||||
|
||||
// emit signals
|
||||
if (signals_) {
|
||||
NetNet*cur = signals_->sig_next_;
|
||||
|
|
@ -339,6 +346,11 @@ void NetEParam::expr_scan(struct expr_scan_t*tgt) const
|
|||
<< endl;
|
||||
}
|
||||
|
||||
void NetEScope::expr_scan(struct expr_scan_t*tgt) const
|
||||
{
|
||||
tgt->expr_scope(this);
|
||||
}
|
||||
|
||||
void NetEUFunc::expr_scan(struct expr_scan_t*tgt) const
|
||||
{
|
||||
tgt->expr_ufunc(this);
|
||||
|
|
@ -382,6 +394,9 @@ bool emit(ostream&o, const Design*des, const char*type)
|
|||
|
||||
/*
|
||||
* $Log: emit.cc,v $
|
||||
* Revision 1.30 1999/11/27 19:07:57 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.29 1999/11/21 00:13:08 steve
|
||||
* Support memories in continuous assignments.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: expr_synth.cc,v 1.4 1999/11/19 03:00:59 steve Exp $"
|
||||
#ident "$Id: expr_synth.cc,v 1.5 1999/11/27 19:07:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "netlist.h"
|
||||
|
|
@ -45,7 +45,7 @@ NetNet* NetEBAdd::synthesize(Design*des)
|
|||
assert(lsig->pin_count() == rsig->pin_count());
|
||||
unsigned width=lsig->pin_count();
|
||||
|
||||
NetNet*osig = new NetNet(path, NetNet::IMPLICIT, width);
|
||||
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, width);
|
||||
|
||||
string oname = des->local_symbol(path);
|
||||
NetAddSub *adder = new NetAddSub(oname, width);
|
||||
|
|
@ -82,7 +82,7 @@ NetNet* NetEBBits::synthesize(Design*des)
|
|||
NetNet*rsig = right_->synthesize(des);
|
||||
|
||||
assert(lsig->pin_count() == rsig->pin_count());
|
||||
NetNet*osig = new NetNet(path, NetNet::IMPLICIT, lsig->pin_count());
|
||||
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, lsig->pin_count());
|
||||
|
||||
for (unsigned idx = 0 ; idx < osig->pin_count() ; idx += 1) {
|
||||
string oname = des->local_symbol(path);
|
||||
|
|
@ -124,7 +124,7 @@ NetNet* NetEConst::synthesize(Design*des)
|
|||
string path = des->local_symbol("SYNTH");
|
||||
unsigned width=expr_width();
|
||||
|
||||
NetNet*osig = new NetNet(path, NetNet::IMPLICIT, width);
|
||||
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, width);
|
||||
for (unsigned idx = 0 ; idx < width; idx += 1) {
|
||||
string oname = des->local_symbol(path);
|
||||
NetConst *c = new NetConst(oname, value().get(idx));
|
||||
|
|
@ -144,7 +144,7 @@ NetNet* NetEUBits::synthesize(Design*des)
|
|||
string path = des->local_symbol("SYNTH");
|
||||
NetNet*isig = expr_->synthesize(des);
|
||||
|
||||
NetNet*osig = new NetNet(path, NetNet::IMPLICIT, isig->pin_count());
|
||||
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, isig->pin_count());
|
||||
|
||||
for (unsigned idx = 0 ; idx < osig->pin_count() ; idx += 1) {
|
||||
string oname = des->local_symbol(path);
|
||||
|
|
@ -178,7 +178,7 @@ NetNet* NetETernary::synthesize(Design *des)
|
|||
assert(csig->pin_count() == 1);
|
||||
assert(tsig->pin_count() == fsig->pin_count());
|
||||
unsigned width=tsig->pin_count();
|
||||
NetNet*osig = new NetNet(path, NetNet::IMPLICIT, width);
|
||||
NetNet*osig = new NetNet(0, path, NetNet::IMPLICIT, width);
|
||||
|
||||
string oname = des->local_symbol(path);
|
||||
NetMux *mux = new NetMux(oname, width, 2, 1);
|
||||
|
|
@ -195,8 +195,7 @@ NetNet* NetETernary::synthesize(Design *des)
|
|||
|
||||
NetNet* NetESignal::synthesize(Design*des)
|
||||
{
|
||||
//NetNet*sig = new NetNet(name(), NetNet::WIRE, pin_count());
|
||||
NetNet*sig = new NetNet(des->local_symbol(name()),
|
||||
NetNet*sig = new NetNet(0, des->local_symbol(name()),
|
||||
NetNet::WIRE, pin_count());
|
||||
sig->local_flag(true);
|
||||
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1)
|
||||
|
|
@ -207,6 +206,9 @@ NetNet* NetESignal::synthesize(Design*des)
|
|||
|
||||
/*
|
||||
* $Log: expr_synth.cc,v $
|
||||
* Revision 1.5 1999/11/27 19:07:57 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.4 1999/11/19 03:00:59 steve
|
||||
* Whoops, created a signal with a duplicate name.
|
||||
*
|
||||
|
|
|
|||
155
netlist.cc
155
netlist.cc
|
|
@ -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.93 1999/11/24 04:01:59 steve Exp $"
|
||||
#ident "$Id: netlist.cc,v 1.94 1999/11/27 19:07:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <cassert>
|
||||
|
|
@ -368,8 +368,8 @@ NetNode::~NetNode()
|
|||
design_->del_node(this);
|
||||
}
|
||||
|
||||
NetNet::NetNet(const string&n, Type t, unsigned npins)
|
||||
: NetObj(n, npins), sig_next_(0), sig_prev_(0), design_(0),
|
||||
NetNet::NetNet(NetScope*s, const string&n, Type t, unsigned npins)
|
||||
: NetObj(n, npins), sig_next_(0), sig_prev_(0), design_(0), scope_(s),
|
||||
type_(t), port_type_(NOT_A_PORT), msb_(npins-1), lsb_(0),
|
||||
local_flag_(false)
|
||||
{
|
||||
|
|
@ -378,10 +378,10 @@ NetNet::NetNet(const string&n, Type t, unsigned npins)
|
|||
ivalue_[idx] = verinum::Vz;
|
||||
}
|
||||
|
||||
NetNet::NetNet(const string&n, Type t, long ms, long ls)
|
||||
NetNet::NetNet(NetScope*s, const string&n, Type t, long ms, long ls)
|
||||
: NetObj(n, ((ms>ls)?ms-ls:ls-ms) + 1), sig_next_(0),
|
||||
sig_prev_(0), design_(0), type_(t), port_type_(NOT_A_PORT),
|
||||
msb_(ms), lsb_(ls), local_flag_(false)
|
||||
sig_prev_(0), design_(0), scope_(s), type_(t),
|
||||
port_type_(NOT_A_PORT), msb_(ms), lsb_(ls), local_flag_(false)
|
||||
{
|
||||
ivalue_ = new verinum::V[pin_count()];
|
||||
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1)
|
||||
|
|
@ -394,6 +394,16 @@ NetNet::~NetNet()
|
|||
design_->del_signal(this);
|
||||
}
|
||||
|
||||
NetScope* NetNet::scope()
|
||||
{
|
||||
return scope_;
|
||||
}
|
||||
|
||||
const NetScope* NetNet::scope() const
|
||||
{
|
||||
return scope_;
|
||||
}
|
||||
|
||||
unsigned NetNet::sb_to_idx(long sb) const
|
||||
{
|
||||
if (msb_ >= lsb_)
|
||||
|
|
@ -403,7 +413,7 @@ unsigned NetNet::sb_to_idx(long sb) const
|
|||
}
|
||||
|
||||
NetTmp::NetTmp(const string&name, unsigned npins)
|
||||
: NetNet(name, IMPLICIT, npins)
|
||||
: NetNet(0, name, IMPLICIT, npins)
|
||||
{
|
||||
local_flag(true);
|
||||
}
|
||||
|
|
@ -1776,12 +1786,27 @@ NetEParam* NetEParam::dup_expr() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
NetEScope::NetEScope(NetScope*s)
|
||||
: scope_(s)
|
||||
{
|
||||
}
|
||||
|
||||
NetEScope::~NetEScope()
|
||||
{
|
||||
}
|
||||
|
||||
const NetScope* NetEScope::scope() const
|
||||
{
|
||||
return scope_;
|
||||
}
|
||||
|
||||
NetESignal::NetESignal(NetNet*n)
|
||||
: NetExpr(n->pin_count()), NetNode(n->name(), n->pin_count())
|
||||
{
|
||||
set_line(*n);
|
||||
for (unsigned idx = 0 ; idx < n->pin_count() ; idx += 1) {
|
||||
pin(idx).set_name("P", idx);
|
||||
pin(idx).set_dir(NetObj::Link::PASSIVE);
|
||||
connect(pin(idx), n->pin(idx));
|
||||
}
|
||||
}
|
||||
|
|
@ -1790,8 +1815,10 @@ NetESignal::NetESignal(const string&n, unsigned np)
|
|||
: NetExpr(np), NetNode(n, np)
|
||||
{
|
||||
expr_width(pin_count());
|
||||
for(unsigned idx = 0 ; idx < np ; idx += 1)
|
||||
for(unsigned idx = 0 ; idx < np ; idx += 1) {
|
||||
pin(idx).set_name("P", idx);
|
||||
pin(idx).set_dir(NetObj::Link::PASSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
NetESignal::~NetESignal()
|
||||
|
|
@ -1927,12 +1954,12 @@ const NetExpr* NetRepeat::expr() const
|
|||
}
|
||||
|
||||
NetScope::NetScope(const string&n)
|
||||
: name_(n)
|
||||
: type_(NetScope::MODULE), name_(n)
|
||||
{
|
||||
}
|
||||
|
||||
NetScope::NetScope(const string&p, const string&n)
|
||||
: name_(p + "." + n)
|
||||
NetScope::NetScope(const string&p, NetScope::TYPE t)
|
||||
: type_(t), name_(p)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1940,6 +1967,11 @@ NetScope::~NetScope()
|
|||
{
|
||||
}
|
||||
|
||||
NetScope::TYPE NetScope::type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
string NetScope::name() const
|
||||
{
|
||||
return name_;
|
||||
|
|
@ -2246,17 +2278,30 @@ Design::~Design()
|
|||
{
|
||||
}
|
||||
|
||||
string Design::make_root_scope(const string&root)
|
||||
NetScope* Design::make_root_scope(const string&root)
|
||||
{
|
||||
scopes_[root] = new NetScope(root);
|
||||
return root;
|
||||
NetScope*scope = new NetScope(root);
|
||||
scopes_[root] = scope;
|
||||
return scope;
|
||||
}
|
||||
|
||||
string Design::make_scope(const string&path, const string&name)
|
||||
NetScope* Design::make_scope(const string&path,
|
||||
NetScope::TYPE t,
|
||||
const string&name)
|
||||
{
|
||||
string npath = path + "." + name;
|
||||
scopes_[npath] = new NetScope(path, name);
|
||||
return npath;
|
||||
NetScope*scope = new NetScope(npath, t);
|
||||
scopes_[npath] = scope;
|
||||
return scope;
|
||||
}
|
||||
|
||||
NetScope* Design::find_scope(const string&key)
|
||||
{
|
||||
map<string,NetScope*>::const_iterator tmp = scopes_.find(key);
|
||||
if (tmp == scopes_.end())
|
||||
return 0;
|
||||
else
|
||||
return (*tmp).second;
|
||||
}
|
||||
|
||||
void Design::set_parameter(const string&key, NetExpr*expr)
|
||||
|
|
@ -2572,6 +2617,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
|
|||
|
||||
/*
|
||||
* $Log: netlist.cc,v $
|
||||
* Revision 1.94 1999/11/27 19:07:57 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.93 1999/11/24 04:01:59 steve
|
||||
* Detect and list scope names.
|
||||
*
|
||||
|
|
@ -2864,78 +2912,5 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
|
|||
*
|
||||
* Revision 1.15 1999/02/03 04:20:11 steve
|
||||
* Parse and elaborate the Verilog CASE statement.
|
||||
*
|
||||
* Revision 1.14 1998/12/18 05:16:25 steve
|
||||
* Parse more UDP input edge descriptions.
|
||||
*
|
||||
* Revision 1.13 1998/12/17 23:54:58 steve
|
||||
* VVM support for small sequential UDP objects.
|
||||
*
|
||||
* Revision 1.12 1998/12/14 02:01:35 steve
|
||||
* Fully elaborate Sequential UDP behavior.
|
||||
*
|
||||
* Revision 1.11 1998/12/07 04:53:17 steve
|
||||
* Generate OBUF or IBUF attributes (and the gates
|
||||
* to garry them) where a wire is a pad. This involved
|
||||
* figuring out enough of the netlist to know when such
|
||||
* was needed, and to generate new gates and signales
|
||||
* to handle what's missing.
|
||||
*
|
||||
* Revision 1.10 1998/12/02 04:37:13 steve
|
||||
* Add the nobufz function to eliminate bufz objects,
|
||||
* Object links are marked with direction,
|
||||
* constant propagation is more careful will wide links,
|
||||
* Signal folding is aware of attributes, and
|
||||
* the XNF target can dump UDP objects based on LCA
|
||||
* attributes.
|
||||
*
|
||||
* Revision 1.9 1998/12/01 00:42:14 steve
|
||||
* Elaborate UDP devices,
|
||||
* Support UDP type attributes, and
|
||||
* pass those attributes to nodes that
|
||||
* are instantiated by elaboration,
|
||||
* Put modules into a map instead of
|
||||
* a simple list.
|
||||
*
|
||||
* Revision 1.8 1998/11/23 00:20:23 steve
|
||||
* NetAssign handles lvalues as pin links
|
||||
* instead of a signal pointer,
|
||||
* Wire attributes added,
|
||||
* Ability to parse UDP descriptions added,
|
||||
* XNF generates EXT records for signals with
|
||||
* the PAD attribute.
|
||||
*
|
||||
* Revision 1.7 1998/11/18 04:25:22 steve
|
||||
* Add -f flags for generic flag key/values.
|
||||
*
|
||||
* Revision 1.6 1998/11/16 05:03:53 steve
|
||||
* Add the sigfold function that unlinks excess
|
||||
* signal nodes, and add the XNF target.
|
||||
*
|
||||
* Revision 1.5 1998/11/13 06:23:17 steve
|
||||
* Introduce netlist optimizations with the
|
||||
* cprop function to do constant propogation.
|
||||
*
|
||||
* Revision 1.4 1998/11/09 18:55:34 steve
|
||||
* Add procedural while loops,
|
||||
* Parse procedural for loops,
|
||||
* Add procedural wait statements,
|
||||
* Add constant nodes,
|
||||
* Add XNOR logic gate,
|
||||
* Make vvm output look a bit prettier.
|
||||
*
|
||||
* Revision 1.3 1998/11/07 19:17:10 steve
|
||||
* Calculate expression widths at elaboration time.
|
||||
*
|
||||
* Revision 1.2 1998/11/07 17:05:05 steve
|
||||
* Handle procedural conditional, and some
|
||||
* of the conditional expressions.
|
||||
*
|
||||
* Elaborate signals and identifiers differently,
|
||||
* allowing the netlist to hold signal information.
|
||||
*
|
||||
* Revision 1.1 1998/11/03 23:29:00 steve
|
||||
* Introduce verilog to CVS.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
|||
50
netlist.h
50
netlist.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: netlist.h,v 1.94 1999/11/24 04:01:59 steve Exp $"
|
||||
#ident "$Id: netlist.h,v 1.95 1999/11/27 19:07:58 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -39,6 +39,7 @@ class Design;
|
|||
class NetNode;
|
||||
class NetProc;
|
||||
class NetProcTop;
|
||||
class NetScope;
|
||||
class NetExpr;
|
||||
class NetESignal;
|
||||
class ostream;
|
||||
|
|
@ -232,12 +233,14 @@ class NetNet : public NetObj, public LineInfo {
|
|||
|
||||
enum PortType { NOT_A_PORT, PIMPLICIT, PINPUT, POUTPUT, PINOUT };
|
||||
|
||||
explicit NetNet(const string&n, Type t, unsigned npins =1);
|
||||
explicit NetNet(NetScope*s, const string&n, Type t, unsigned npins =1);
|
||||
|
||||
explicit NetNet(const string&n, Type t, long ms, long ls);
|
||||
explicit NetNet(NetScope*s, const string&n, Type t, long ms, long ls);
|
||||
|
||||
virtual ~NetNet();
|
||||
|
||||
NetScope* scope();
|
||||
const NetScope* scope() const;
|
||||
|
||||
Type type() const { return type_; }
|
||||
void type(Type t) { type_ = t; }
|
||||
|
|
@ -274,6 +277,7 @@ class NetNet : public NetObj, public LineInfo {
|
|||
Design*design_;
|
||||
|
||||
private:
|
||||
NetScope*scope_;
|
||||
Type type_;
|
||||
PortType port_type_;
|
||||
|
||||
|
|
@ -1619,6 +1623,29 @@ class NetEParam : public NetExpr {
|
|||
string name_;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* This class is a special (and magical) expression node type that
|
||||
* represents scope names. These can only be found as parameters to
|
||||
* NetSTask objects.
|
||||
*/
|
||||
class NetEScope : public NetExpr {
|
||||
|
||||
public:
|
||||
NetEScope(NetScope*);
|
||||
~NetEScope();
|
||||
|
||||
const NetScope* scope() const;
|
||||
|
||||
virtual void expr_scan(struct expr_scan_t*) const;
|
||||
virtual NetEScope* dup_expr() const;
|
||||
|
||||
virtual void dump(ostream&os) const;
|
||||
|
||||
private:
|
||||
NetScope*scope_;
|
||||
};
|
||||
|
||||
/*
|
||||
* This node represents a system function call in an expression. The
|
||||
* object contains the name of the system function, which the backend
|
||||
|
|
@ -1833,20 +1860,24 @@ class NetESubSignal : public NetExpr {
|
|||
|
||||
/*
|
||||
* This object type is used to contain a logical scope within a
|
||||
* design.
|
||||
* design. The scope doesn't represent any executable hardware, but is
|
||||
* just a handle that netlist processors can use to grab at the design.
|
||||
*/
|
||||
class NetScope {
|
||||
|
||||
public:
|
||||
enum TYPE { MODULE, BEGIN_END, FORK_JOIN };
|
||||
NetScope(const string&root);
|
||||
NetScope(const string&path, const string&n);
|
||||
NetScope(const string&path, TYPE t);
|
||||
~NetScope();
|
||||
|
||||
TYPE type() const;
|
||||
string name() const;
|
||||
|
||||
void dump(ostream&) const;
|
||||
|
||||
private:
|
||||
TYPE type_;
|
||||
string name_;
|
||||
};
|
||||
|
||||
|
|
@ -1872,8 +1903,10 @@ class Design {
|
|||
|
||||
string get_flag(const string&key) const;
|
||||
|
||||
string make_root_scope(const string&name);
|
||||
string make_scope(const string&path, const string&name);
|
||||
NetScope* make_root_scope(const string&name);
|
||||
NetScope* make_scope(const string&path, NetScope::TYPE t,
|
||||
const string&name);
|
||||
NetScope* find_scope(const string&path);
|
||||
|
||||
// PARAMETERS
|
||||
void set_parameter(const string&, NetExpr*);
|
||||
|
|
@ -2003,6 +2036,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
|||
|
||||
/*
|
||||
* $Log: netlist.h,v $
|
||||
* Revision 1.95 1999/11/27 19:07:58 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.94 1999/11/24 04:01:59 steve
|
||||
* Detect and list scope names.
|
||||
*
|
||||
|
|
|
|||
54
t-vvm.cc
54
t-vvm.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: t-vvm.cc,v 1.79 1999/11/24 04:38:49 steve Exp $"
|
||||
#ident "$Id: t-vvm.cc,v 1.80 1999/11/27 19:07:58 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <iostream>
|
||||
|
|
@ -54,6 +54,7 @@ class target_vvm : public target_t {
|
|||
target_vvm();
|
||||
|
||||
virtual void start_design(ostream&os, const Design*);
|
||||
virtual void scope(ostream&os, const NetScope*);
|
||||
virtual void signal(ostream&os, const NetNet*);
|
||||
virtual void memory(ostream&os, const NetMemory*);
|
||||
virtual void task_def(ostream&os, const NetTaskDef*);
|
||||
|
|
@ -483,9 +484,10 @@ class vvm_parm_rval : public expr_scan_t {
|
|||
string result;
|
||||
|
||||
private:
|
||||
virtual void expr_const(const NetEConst*expr);
|
||||
virtual void expr_const(const NetEConst*);
|
||||
virtual void expr_ident(const NetEIdent*);
|
||||
virtual void expr_memory(const NetEMemory*mem);
|
||||
virtual void expr_memory(const NetEMemory*);
|
||||
virtual void expr_scope(const NetEScope*);
|
||||
virtual void expr_signal(const NetESignal*);
|
||||
|
||||
private:
|
||||
|
|
@ -563,6 +565,11 @@ void vvm_parm_rval::expr_memory(const NetEMemory*mem)
|
|||
result = string("&") + mangle(mem->name()) + ".base";
|
||||
}
|
||||
|
||||
void vvm_parm_rval::expr_scope(const NetEScope*escope)
|
||||
{
|
||||
result = string("&") + mangle(escope->scope()->name()) + "_scope.base";
|
||||
}
|
||||
|
||||
void vvm_parm_rval::expr_signal(const NetESignal*expr)
|
||||
{
|
||||
string res = string("&") + mangle(expr->name()) + ".base";
|
||||
|
|
@ -613,6 +620,29 @@ void target_vvm::start_design(ostream&os, const Design*mod)
|
|||
start_code << "{" << endl;
|
||||
}
|
||||
|
||||
void target_vvm::scope(ostream&os, const NetScope*scope)
|
||||
{
|
||||
string hname = mangle(scope->name()) + "_scope";
|
||||
os << "// SCOPE: " << scope->name() << endl;
|
||||
os << "static struct __vpiScope " << hname << ";" << endl;
|
||||
|
||||
string type_code;
|
||||
switch (scope->type()) {
|
||||
case NetScope::MODULE:
|
||||
type_code = "vpiModule";
|
||||
break;
|
||||
case NetScope::BEGIN_END:
|
||||
type_code = "vpiNamedBegin";
|
||||
break;
|
||||
case NetScope::FORK_JOIN:
|
||||
type_code = "vpiNamedFork";
|
||||
break;
|
||||
}
|
||||
|
||||
init_code << " vpip_make_scope(&" << hname << ", " <<
|
||||
type_code << ", \"" << scope->name() << "\");" << endl;
|
||||
}
|
||||
|
||||
void target_vvm::end_design(ostream&os, const Design*mod)
|
||||
{
|
||||
os << "static struct __vpiStringConst string_table[" <<
|
||||
|
|
@ -689,6 +719,9 @@ bool target_vvm::process(ostream&os, const NetProcTop*top)
|
|||
|
||||
void target_vvm::signal(ostream&os, const NetNet*sig)
|
||||
{
|
||||
#if 1
|
||||
os << "// XXXX handle signal " << sig->name() << endl;
|
||||
#endif
|
||||
|
||||
/* Scan the signals of the vector, passing the initial value
|
||||
to the inputs of all the connected devices. */
|
||||
|
|
@ -829,6 +862,7 @@ void target_vvm::emit_gate_outputfun_(const NetNode*gate, unsigned gpin)
|
|||
|
||||
if (dynamic_cast<const NetNet*>(cur)) {
|
||||
// Skip signals
|
||||
|
||||
} else if (cur->pin(pin).get_name() != "") {
|
||||
|
||||
delayed << " " << mangle(cur->name()) << ".set_"
|
||||
|
|
@ -1279,6 +1313,17 @@ void target_vvm::net_esignal(ostream&os, const NetESignal*net)
|
|||
|
||||
init_code << " vpip_make_reg(&" << net_name <<
|
||||
", \"" << net->name() << "\");" << endl;
|
||||
|
||||
#if 0
|
||||
/* If the signal (that I am declaring and initializing) is
|
||||
attached to a scope in the netlist, then attach it to the
|
||||
scope for real here. */
|
||||
if (const NetScope*scope = net->scope()) {
|
||||
init_code << " vpip_attach_to_scope(&" <<
|
||||
mangle(scope->name()) << "_scope, &" << net_name <<
|
||||
".base);" << endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1942,6 +1987,9 @@ extern const struct target tgt_vvm = {
|
|||
};
|
||||
/*
|
||||
* $Log: t-vvm.cc,v $
|
||||
* Revision 1.80 1999/11/27 19:07:58 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.79 1999/11/24 04:38:49 steve
|
||||
* LT and GT fixes from Eric Aardoom.
|
||||
*
|
||||
|
|
|
|||
15
target.cc
15
target.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: target.cc,v 1.26 1999/11/21 00:13:09 steve Exp $"
|
||||
#ident "$Id: target.cc,v 1.27 1999/11/27 19:07:58 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "target.h"
|
||||
|
|
@ -31,6 +31,10 @@ void target_t::start_design(ostream&os, const Design*)
|
|||
{
|
||||
}
|
||||
|
||||
void target_t::scope(ostream&, const NetScope*)
|
||||
{
|
||||
}
|
||||
|
||||
void target_t::signal(ostream&os, const NetNet*)
|
||||
{
|
||||
}
|
||||
|
|
@ -267,6 +271,12 @@ void expr_scan_t::expr_memory(const NetEMemory*)
|
|||
"unhandled expr_memory." << endl;
|
||||
}
|
||||
|
||||
void expr_scan_t::expr_scope(const NetEScope*)
|
||||
{
|
||||
cerr << "expr_scan_t (" << typeid(*this).name() << "): "
|
||||
"unhandled expr_scope." << endl;
|
||||
}
|
||||
|
||||
void expr_scan_t::expr_signal(const NetESignal*)
|
||||
{
|
||||
cerr << "expr_scan_t (" << typeid(*this).name() << "): "
|
||||
|
|
@ -305,6 +315,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex)
|
|||
|
||||
/*
|
||||
* $Log: target.cc,v $
|
||||
* Revision 1.27 1999/11/27 19:07:58 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.26 1999/11/21 00:13:09 steve
|
||||
* Support memories in continuous assignments.
|
||||
*
|
||||
|
|
|
|||
10
target.h
10
target.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: target.h,v 1.25 1999/11/21 00:13:09 steve Exp $"
|
||||
#ident "$Id: target.h,v 1.26 1999/11/27 19:07:58 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "netlist.h"
|
||||
|
|
@ -55,6 +55,10 @@ struct target_t {
|
|||
/* Start the design. */
|
||||
virtual void start_design(ostream&os, const Design*);
|
||||
|
||||
/* This is called once for each scope in the design, before
|
||||
anything else is called. */
|
||||
virtual void scope(ostream&os, const NetScope*);
|
||||
|
||||
/* Output a signal (called for each signal) */
|
||||
virtual void signal(ostream&os, const NetNet*);
|
||||
|
||||
|
|
@ -117,6 +121,7 @@ struct expr_scan_t {
|
|||
virtual void expr_concat(const NetEConcat*);
|
||||
virtual void expr_ident(const NetEIdent*);
|
||||
virtual void expr_memory(const NetEMemory*);
|
||||
virtual void expr_scope(const NetEScope*);
|
||||
virtual void expr_signal(const NetESignal*);
|
||||
virtual void expr_subsignal(const NetESubSignal*);
|
||||
virtual void expr_ternary(const NetETernary*);
|
||||
|
|
@ -142,6 +147,9 @@ extern const struct target *target_table[];
|
|||
|
||||
/*
|
||||
* $Log: target.h,v $
|
||||
* Revision 1.26 1999/11/27 19:07:58 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.25 1999/11/21 00:13:09 steve
|
||||
* Support memories in continuous assignments.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_user.h,v 1.7 1999/11/10 02:52:24 steve Exp $"
|
||||
#ident "$Id: vpi_user.h,v 1.8 1999/11/27 19:07:58 steve Exp $"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -98,6 +98,9 @@ typedef struct t_vpi_value {
|
|||
#define vpiIterator 27
|
||||
#define vpiMemory 29
|
||||
#define vpiMemoryWord 30
|
||||
#define vpiModule 32
|
||||
#define vpiNamedBegin 33
|
||||
#define vpiNamedFork 35
|
||||
#define vpiNet 36
|
||||
#define vpiReg 48
|
||||
#define vpiSysTaskCall 57
|
||||
|
|
@ -207,6 +210,9 @@ extern void (*vlog_startup_routines[])();
|
|||
|
||||
/*
|
||||
* $Log: vpi_user.h,v $
|
||||
* Revision 1.8 1999/11/27 19:07:58 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.7 1999/11/10 02:52:24 steve
|
||||
* Create the vpiMemory handle type.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
# 59 Temple Place - Suite 330
|
||||
# Boston, MA 02111-1307, USA
|
||||
#
|
||||
#ident "$Id: Makefile.in,v 1.13 1999/11/22 00:30:52 steve Exp $"
|
||||
#ident "$Id: Makefile.in,v 1.14 1999/11/27 19:07:58 steve Exp $"
|
||||
#
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
|
|
@ -63,7 +63,7 @@ vvm_simulation.o vvm_thread.o vpip.o
|
|||
|
||||
P = vpi_callback.o \
|
||||
vpi_const.o vpi_iter.o vpi_memory.o vpi_null.o \
|
||||
vpi_priv.o vpi_signal.o vpi_simulation.o vpi_systask.o vpi_time.o
|
||||
vpi_priv.o vpi_scope.o vpi_signal.o vpi_simulation.o vpi_systask.o vpi_time.o
|
||||
|
||||
libvvm.a: $O
|
||||
rm -f $@
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_priv.h,v 1.6 1999/11/10 02:52:24 steve Exp $"
|
||||
#ident "$Id: vpi_priv.h,v 1.7 1999/11/27 19:07:58 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -113,6 +113,20 @@ struct __vpiNull {
|
|||
};
|
||||
extern struct __vpiNull vpip_null;
|
||||
|
||||
/*
|
||||
* This type represents the handle to a Verilog scope. These include
|
||||
* module instantiations and name begin-end blocks. The attach
|
||||
* function is used to attach handles to the scope by the runtime
|
||||
* initializaiton.
|
||||
*/
|
||||
struct __vpiScope {
|
||||
struct __vpiHandle base;
|
||||
/* The scope has a name. (this points to static memory.) */
|
||||
const char*name;
|
||||
};
|
||||
extern void vpip_attach_to_scope(struct __vpiScope*scope, vpiHandle obj);
|
||||
|
||||
|
||||
/*
|
||||
* This structure represents nets and registers. You can tell which by
|
||||
* the type_code in the base. The bits member points to the actual
|
||||
|
|
@ -181,6 +195,9 @@ struct __vpiNumberConst {
|
|||
*/
|
||||
extern vpiHandle vpip_make_iterator(unsigned nargs, vpiHandle*args);
|
||||
extern vpiHandle vpip_make_net(struct __vpiSignal*ref, const char*name);
|
||||
extern vpiHandle vpip_make_scope(struct __vpiScope*ref,
|
||||
int type_code,
|
||||
const char*name);
|
||||
extern vpiHandle vpip_make_string_const(struct __vpiStringConst*ref,
|
||||
const char*val);
|
||||
extern vpiHandle vpip_make_number_const(struct __vpiNumberConst*ref,
|
||||
|
|
@ -254,6 +271,9 @@ extern int vpip_finished();
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.h,v $
|
||||
* Revision 1.7 1999/11/27 19:07:58 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.6 1999/11/10 02:52:24 steve
|
||||
* Create the vpiMemory handle type.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 1999 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)
|
||||
#ident "$Id: vpi_scope.c,v 1.1 1999/11/27 19:07:58 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
# include <assert.h>
|
||||
|
||||
static const struct __vpirt vpip_module_rt = {
|
||||
vpiModule,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
vpiHandle vpip_make_scope(struct __vpiScope*ref, int type, const char*name)
|
||||
{
|
||||
switch (type) {
|
||||
case vpiModule:
|
||||
ref->base.vpi_type = &vpip_module_rt;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
return &ref->base;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: vpi_scope.c,v $
|
||||
* Revision 1.1 1999/11/27 19:07:58 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
*/
|
||||
|
||||
9
xnfio.cc
9
xnfio.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: xnfio.cc,v 1.8 1999/11/19 05:02:15 steve Exp $"
|
||||
#ident "$Id: xnfio.cc,v 1.9 1999/11/27 19:07:58 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "functor.h"
|
||||
|
|
@ -135,7 +135,7 @@ static NetLogic* make_obuf(Design*des, NetNet*net)
|
|||
// of the netlist, to create a ring without a signal. Detect
|
||||
// this case and create a new signal.
|
||||
if (count_signals(buf->pin(1)) == 0) {
|
||||
NetNet*tmp = new NetNet(des->local_symbol("$"), NetNet::WIRE);
|
||||
NetNet*tmp = new NetNet(0, des->local_symbol("$"), NetNet::WIRE);
|
||||
tmp->local_flag(true);
|
||||
connect(buf->pin(1), tmp->pin(0));
|
||||
des->add_signal(tmp);
|
||||
|
|
@ -238,7 +238,7 @@ static void make_ibuf(Design*des, NetNet*net)
|
|||
// of the netlist, to create a ring without a signal. Detect
|
||||
// this case and create a new signal.
|
||||
if (count_signals(buf->pin(0)) == 0) {
|
||||
NetNet*tmp = new NetNet(des->local_symbol("$"), NetNet::WIRE);
|
||||
NetNet*tmp = new NetNet(0, des->local_symbol("$"), NetNet::WIRE);
|
||||
connect(buf->pin(0), tmp->pin(0));
|
||||
des->add_signal(tmp);
|
||||
}
|
||||
|
|
@ -282,6 +282,9 @@ void xnfio(Design*des)
|
|||
|
||||
/*
|
||||
* $Log: xnfio.cc,v $
|
||||
* Revision 1.9 1999/11/27 19:07:58 steve
|
||||
* Support the creation of scopes.
|
||||
*
|
||||
* Revision 1.8 1999/11/19 05:02:15 steve
|
||||
* Handle inverted clock into OUTFF.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue