diff --git a/Makefile.in b/Makefile.in index f6320061a..7580e80d0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -18,7 +18,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.7 1999/07/03 20:50:28 steve Exp $" +#ident "$Id: Makefile.in,v 1.8 1999/07/17 22:01:13 steve Exp $" # # SHELL = /bin/sh @@ -53,11 +53,12 @@ clean: cd ivlpp ; make clean TT = t-null.o t-verilog.o t-vvm.o t-xnf.o -FF = nobufz.o propinit.o sigfold.o stupid.o xnfio.o +FF = nobufz.o propinit.o sigfold.o xnfio.o -O = main.o cprop.o design_dump.o elaborate.o emit.o eval.o lexor.o mangle.o \ -netlist.o parse.o parse_misc.o pform.o pform_dump.o verinum.o verireal.o \ -target.o targets.o Module.o PExpr.o PGate.o PTask.o PWire.o Statement.o \ +O = main.o cprop.o design_dump.o elaborate.o emit.o eval.o functor.o \ +lexor.o mangle.o netlist.o parse.o parse_misc.o pform.o pform_dump.o \ +verinum.o verireal.o target.o targets.o Module.o PExpr.o PGate.o \ +PTask.o PWire.o Statement.o \ $(FF) $(TT) Makefile: Makefile.in config.status diff --git a/stupid.cc b/functor.cc similarity index 52% rename from stupid.cc rename to functor.cc index f254fb10a..841598f28 100644 --- a/stupid.cc +++ b/functor.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998 Stephen Williams (steve@icarus.com) + * 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 @@ -17,24 +17,44 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: stupid.cc,v 1.2 1998/11/13 06:23:17 steve Exp $" +#ident "$Id: functor.cc,v 1.1 1999/07/17 22:01:13 steve Exp $" #endif +# include "functor.h" # include "netlist.h" - -void stupid(Design*des) +functor_t::~functor_t() { } +void functor_t::signal(class Design*, class NetNet*) +{ +} + +void functor_t::process(class Design*, class NetProcTop*) +{ +} + +void Design::functor(functor_t*fun) +{ + // apply to signals + if (signals_) { + NetNet*cur = signals_->sig_next_; + do { + fun->signal(this, cur); + cur = cur->sig_next_; + } while (cur != signals_->sig_next_); + } + + // apply to processes + for (NetProcTop*idx = procs_ ; idx ; idx = idx->next_) + fun->process(this, idx); +} + /* - * $Log: stupid.cc,v $ - * Revision 1.2 1998/11/13 06:23:17 steve - * Introduce netlist optimizations with the - * cprop function to do constant propogation. - * - * Revision 1.1 1998/11/03 23:29:05 steve - * Introduce verilog to CVS. + * $Log: functor.cc,v $ + * Revision 1.1 1999/07/17 22:01:13 steve + * Add the functor interface for functor transforms. * */ diff --git a/functor.h b/functor.h new file mode 100644 index 000000000..3882a4dd6 --- /dev/null +++ b/functor.h @@ -0,0 +1,53 @@ +#ifndef __functor_H +#define __functor_H +/* + * 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: functor.h,v 1.1 1999/07/17 22:01:13 steve Exp $" +#endif + +/* + * The functor is an object that can be applied to a design to + * transform it. This is different from the target_t, which can only + * scan the design but not transform it in any way. + */ + +class Design; +class NetNet; +class NetProcTop; + +struct functor_t { + virtual ~functor_t(); + + /* Signals are scanned first. This is called once for each + signal in the design. */ + virtual void signal(class Design*des, class NetNet*); + + /* This method is called for each process in the design. */ + virtual void process(class Design*des, class NetProcTop*); + +}; + +/* + * $Log: functor.h,v $ + * Revision 1.1 1999/07/17 22:01:13 steve + * Add the functor interface for functor transforms. + * + */ +#endif diff --git a/main.cc b/main.cc index 52f0e7576..d63b20858 100644 --- a/main.cc +++ b/main.cc @@ -19,7 +19,7 @@ const char COPYRIGHT[] = * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: main.cc,v 1.19 1999/07/10 23:29:21 steve Exp $" +#ident "$Id: main.cc,v 1.20 1999/07/17 22:01:13 steve Exp $" #endif const char NOTICE[] = @@ -80,7 +80,6 @@ extern void emit(ostream&o, const Design*, const char*); extern void cprop(Design*des); extern void propinit(Design*des); extern void sigfold(Design*des); -extern void stupid(Design*des); extern void nobufz(Design*des); extern void xnfio(Design*des); @@ -93,7 +92,6 @@ static struct net_func_map { { "nobufz", &nobufz }, { "propinit", &propinit }, { "sigfold", &sigfold }, - { "stupid", &stupid }, { "xnfio", &xnfio }, { 0, 0 } }; @@ -272,6 +270,9 @@ int main(int argc, char*argv[]) /* * $Log: main.cc,v $ + * Revision 1.20 1999/07/17 22:01:13 steve + * Add the functor interface for functor transforms. + * * Revision 1.19 1999/07/10 23:29:21 steve * pform even on parse errors. * diff --git a/netlist.h b/netlist.h index c4b3d75ba..c3c2b3609 100644 --- a/netlist.h +++ b/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.47 1999/07/17 19:51:00 steve Exp $" +#ident "$Id: netlist.h,v 1.48 1999/07/17 22:01:13 steve Exp $" #endif /* @@ -44,6 +44,7 @@ class ostream; struct target; +struct functor_t; /* ========= * A NetObj is anything that has any kind of behavior in the @@ -1278,6 +1279,7 @@ class Design { // Iterate over the design... void dump(ostream&) const; + void functor(struct functor_t*); void emit(ostream&, struct target_t*) const; void clear_node_marks(); @@ -1366,6 +1368,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.48 1999/07/17 22:01:13 steve + * Add the functor interface for functor transforms. + * * Revision 1.47 1999/07/17 19:51:00 steve * netlist support for ternary operator. * diff --git a/xnfio.cc b/xnfio.cc index e76783485..71582563a 100644 --- a/xnfio.cc +++ b/xnfio.cc @@ -17,11 +17,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: xnfio.cc,v 1.1 1998/12/07 04:53:17 steve Exp $" +#ident "$Id: xnfio.cc,v 1.2 1999/07/17 22:01:14 steve Exp $" #endif +# include "functor.h" # include "netlist.h" +class xnfio_f : public functor_t { + + public: + void signal(Design*des, NetNet*sig); + + private: +}; + static bool is_a_pad(const NetNet*net) { if (net->attribute("PAD") == "") @@ -153,35 +162,42 @@ static void make_ibuf(Design*des, NetNet*net) } } +void xnfio_f::signal(Design*des, NetNet*net) +{ + if (! is_a_pad(net)) + return; + + assert(net->pin_count() == 1); + string pattr = net->attribute("PAD"); + + switch (pattr[0]) { + case 'i': + case 'I': + make_ibuf(des, net); + break; + case 'o': + case 'O': + make_obuf(des, net); + break; + // FIXME: Only IPAD and OPAD supported. Need to + // add support for IOPAD. + default: + assert(0); + break; + } +} + void xnfio(Design*des) { - des->clear_signal_marks(); - while (NetNet*net = des->find_signal(&is_a_pad)) { - - assert(net->pin_count() == 1); - string pattr = net->attribute("PAD"); - - switch (pattr[0]) { - case 'i': - case 'I': - make_ibuf(des, net); - break; - case 'o': - case 'O': - make_obuf(des, net); - break; - // FIXME: Only IPAD and OPAD supported. Need to - // add support for IOPAD. - default: - assert(0); - break; - } - net->set_mark(); - } + xnfio_f xnfio_obj; + des->functor(&xnfio_obj); } /* * $Log: xnfio.cc,v $ + * Revision 1.2 1999/07/17 22:01:14 steve + * Add the functor interface for functor transforms. + * * Revision 1.1 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