1998-11-04 00:28:49 +01:00
|
|
|
/*
|
2000-02-23 03:56:53 +01:00
|
|
|
* Copyright (c) 1999-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
|
|
|
|
|
*/
|
2000-02-23 03:56:53 +01:00
|
|
|
#if !defined(WINNT) && !defined(macintosh)
|
2001-07-25 05:10:48 +02:00
|
|
|
#ident "$Id: functor.cc,v 1.25 2001/07/25 03:10:49 steve Exp $"
|
1998-11-04 00:28:49 +01:00
|
|
|
#endif
|
|
|
|
|
|
2001-07-25 05:10:48 +02:00
|
|
|
# include "config.h"
|
|
|
|
|
|
|
|
|
|
# include <iostream>
|
|
|
|
|
|
1999-07-18 00:01:13 +02:00
|
|
|
# include "functor.h"
|
1998-11-04 00:28:49 +01:00
|
|
|
# include "netlist.h"
|
|
|
|
|
|
1999-07-18 00:01:13 +02:00
|
|
|
functor_t::~functor_t()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-18 06:50:19 +02:00
|
|
|
void functor_t::event(class Design*, class NetEvent*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-18 00:01:13 +02:00
|
|
|
void functor_t::signal(class Design*, class NetNet*)
|
|
|
|
|
{
|
|
|
|
|
}
|
1998-11-04 00:28:49 +01:00
|
|
|
|
1999-07-18 00:01:13 +02:00
|
|
|
void functor_t::process(class Design*, class NetProcTop*)
|
1998-11-04 00:28:49 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-30 05:19:12 +01:00
|
|
|
void functor_t::lpm_add_sub(class Design*, class NetAddSub*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-20 02:28:03 +02:00
|
|
|
void functor_t::lpm_compare(class Design*, class NetCompare*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-17 07:18:15 +01:00
|
|
|
void functor_t::lpm_const(class Design*, class NetConst*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-01 23:40:22 +02:00
|
|
|
void functor_t::lpm_divide(class Design*, class NetDivide*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-17 23:26:15 +02:00
|
|
|
void functor_t::lpm_modulo(class Design*, class NetModulo*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-01 03:07:40 +01:00
|
|
|
void functor_t::lpm_ff(class Design*, class NetFF*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-17 07:18:15 +01:00
|
|
|
void functor_t::lpm_logic(class Design*, class NetLogic*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-13 04:35:35 +01:00
|
|
|
void functor_t::lpm_mult(class Design*, class NetMult*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-15 07:13:43 +02:00
|
|
|
void functor_t::lpm_mux(class Design*, class NetMux*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-04-18 06:50:19 +02:00
|
|
|
void NetScope::run_functor(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
for (NetScope*cur = sub_ ; cur ; cur = cur->sib_) {
|
|
|
|
|
cur->run_functor(des, fun);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (NetEvent*cur = events_ ; cur ; /* */) {
|
|
|
|
|
NetEvent*tmp = cur;
|
|
|
|
|
cur = cur->snext_;
|
|
|
|
|
fun->event(des, tmp);
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-19 21:48:30 +01:00
|
|
|
// apply to signals. Each iteration, allow for the possibility
|
|
|
|
|
// that the current signal deletes itself.
|
1999-07-18 00:01:13 +02:00
|
|
|
if (signals_) {
|
2000-11-19 21:48:30 +01:00
|
|
|
unsigned count = 0;
|
1999-07-18 00:01:13 +02:00
|
|
|
NetNet*cur = signals_->sig_next_;
|
|
|
|
|
do {
|
2000-11-19 21:48:30 +01:00
|
|
|
count += 1;
|
|
|
|
|
cur = cur->sig_next_;
|
|
|
|
|
} while (cur != signals_->sig_next_);
|
|
|
|
|
|
|
|
|
|
cur = signals_->sig_next_;
|
|
|
|
|
for (unsigned idx = 0 ; idx < count ; idx += 1) {
|
1999-11-18 04:52:19 +01:00
|
|
|
NetNet*tmp = cur->sig_next_;
|
2000-05-02 02:58:11 +02:00
|
|
|
fun->signal(des, cur);
|
1999-11-18 04:52:19 +01:00
|
|
|
cur = tmp;
|
2000-11-19 21:48:30 +01:00
|
|
|
}
|
1999-07-18 00:01:13 +02:00
|
|
|
}
|
2000-05-02 02:58:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Design::functor(functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
// Scan the scopes
|
|
|
|
|
root_scope_->run_functor(this, fun);
|
1999-07-18 00:01:13 +02:00
|
|
|
|
|
|
|
|
// apply to processes
|
1999-07-18 07:52:46 +02:00
|
|
|
procs_idx_ = procs_;
|
|
|
|
|
while (procs_idx_) {
|
|
|
|
|
NetProcTop*idx = procs_idx_;
|
|
|
|
|
procs_idx_ = idx->next_;
|
1999-07-18 00:01:13 +02:00
|
|
|
fun->process(this, idx);
|
1999-07-18 07:52:46 +02:00
|
|
|
}
|
1999-11-01 03:07:40 +01:00
|
|
|
|
|
|
|
|
// apply to nodes
|
|
|
|
|
if (nodes_) {
|
2000-07-16 06:56:07 +02:00
|
|
|
/* Scan the circular list of nodes, starting with the
|
|
|
|
|
front of the list. (nodes_ points to the *end* of the
|
|
|
|
|
list.) The bar is the end point. At the end of the
|
|
|
|
|
do-while loop, I know that the bar has been
|
|
|
|
|
processed or (if bar == 0) no undeleted node has been
|
|
|
|
|
processed. */
|
1999-11-01 03:07:40 +01:00
|
|
|
NetNode*cur = nodes_->node_next_;
|
2000-07-16 06:56:07 +02:00
|
|
|
NetNode*bar = 0;
|
1999-11-01 03:07:40 +01:00
|
|
|
do {
|
|
|
|
|
NetNode*tmp = cur->node_next_;
|
|
|
|
|
cur->functor_node(this, fun);
|
2000-07-16 06:56:07 +02:00
|
|
|
|
|
|
|
|
/* Detect the case that cur has been deleted by
|
|
|
|
|
noticing if tmp->node_prev_ no longer points to
|
|
|
|
|
cur. If that's the case, clear the bar. */
|
|
|
|
|
if (tmp->node_prev_ != cur) {
|
|
|
|
|
if (cur == bar)
|
|
|
|
|
bar = 0;
|
|
|
|
|
} else if (bar == 0) {
|
|
|
|
|
bar = cur;
|
|
|
|
|
}
|
1999-11-01 03:07:40 +01:00
|
|
|
cur = tmp;
|
2000-07-16 06:56:07 +02:00
|
|
|
|
|
|
|
|
} while (nodes_ && (cur != bar));
|
1999-11-01 03:07:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void NetNode::functor_node(Design*, functor_t*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-30 05:19:12 +01:00
|
|
|
void NetAddSub::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_add_sub(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-20 02:28:03 +02:00
|
|
|
void NetCompare::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_compare(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-17 07:18:15 +01:00
|
|
|
void NetConst::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_const(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-01 23:40:22 +02:00
|
|
|
void NetDivide::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_divide(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-01 03:07:40 +01:00
|
|
|
void NetFF::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_ff(des, this);
|
1999-07-18 00:01:13 +02:00
|
|
|
}
|
|
|
|
|
|
1999-12-17 07:18:15 +01:00
|
|
|
void NetLogic::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_logic(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-17 23:26:15 +02:00
|
|
|
void NetModulo::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_modulo(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-13 04:35:35 +01:00
|
|
|
void NetMult::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_mult(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-15 07:13:43 +02:00
|
|
|
void NetMux::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_mux(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-01 07:06:16 +01:00
|
|
|
proc_match_t::~proc_match_t()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NetProc::match_proc(proc_match_t*that)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int proc_match_t::assign(NetAssign*)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NetAssign::match_proc(proc_match_t*that)
|
|
|
|
|
{
|
|
|
|
|
return that->assign(this);
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-01 04:48:41 +02:00
|
|
|
int proc_match_t::assign_nb(NetAssignNB*)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NetAssignNB::match_proc(proc_match_t*that)
|
|
|
|
|
{
|
|
|
|
|
return that->assign_nb(this);
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-05 03:24:08 +01:00
|
|
|
int proc_match_t::assign_mem(NetAssignMem*)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NetAssignMem::match_proc(proc_match_t*that)
|
|
|
|
|
{
|
|
|
|
|
return that->assign_mem(this);
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-01 04:48:41 +02:00
|
|
|
int proc_match_t::assign_mem_nb(NetAssignMemNB*)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NetAssignMemNB::match_proc(proc_match_t*that)
|
|
|
|
|
{
|
|
|
|
|
return that->assign_mem_nb(this);
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-13 05:35:43 +01:00
|
|
|
int proc_match_t::block(NetBlock*)
|
|
|
|
|
{
|
|
|
|
|
cerr << "default (failing) match for block" << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NetBlock::match_proc(proc_match_t*that)
|
|
|
|
|
{
|
|
|
|
|
cerr << "NetBlock::match_proc" << endl;
|
|
|
|
|
return that->block(this);
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-01 07:06:16 +01:00
|
|
|
int proc_match_t::condit(NetCondit*)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NetCondit::match_proc(proc_match_t*that)
|
|
|
|
|
{
|
|
|
|
|
return that->condit(this);
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-12 22:02:52 +02:00
|
|
|
int NetEvWait::match_proc(proc_match_t*that)
|
1999-12-01 07:06:16 +01:00
|
|
|
{
|
2000-04-12 22:02:52 +02:00
|
|
|
return that->event_wait(this);
|
1999-12-01 07:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
2000-04-12 22:02:52 +02:00
|
|
|
int proc_match_t::event_wait(NetEvWait*)
|
1999-12-01 07:06:16 +01:00
|
|
|
{
|
2000-04-12 22:02:52 +02:00
|
|
|
return 0;
|
1999-12-01 07:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
/*
|
1999-07-18 00:01:13 +02:00
|
|
|
* $Log: functor.cc,v $
|
2001-07-25 05:10:48 +02:00
|
|
|
* Revision 1.25 2001/07/25 03:10:49 steve
|
|
|
|
|
* Create a config.h.in file to hold all the config
|
|
|
|
|
* junk, and support gcc 3.0. (Stephan Boettcher)
|
|
|
|
|
*
|
2000-11-19 21:48:30 +01:00
|
|
|
* Revision 1.24 2000/11/19 20:48:30 steve
|
|
|
|
|
* Fix cases where signal iteration might die early.
|
|
|
|
|
*
|
2000-11-18 05:53:04 +01:00
|
|
|
* Revision 1.23 2000/11/18 04:53:04 steve
|
|
|
|
|
* Watch out in functor, it may delete the last signal.
|
|
|
|
|
*
|
2000-09-17 23:26:15 +02:00
|
|
|
* Revision 1.22 2000/09/17 21:26:15 steve
|
|
|
|
|
* Add support for modulus (Eric Aardoom)
|
|
|
|
|
*
|
2000-08-01 04:48:41 +02:00
|
|
|
* Revision 1.21 2000/08/01 02:48:41 steve
|
|
|
|
|
* Support <= in synthesis of DFF and ram devices.
|
|
|
|
|
*
|
2000-07-16 06:56:07 +02:00
|
|
|
* Revision 1.20 2000/07/16 04:56:07 steve
|
|
|
|
|
* Handle some edge cases during node scans.
|
|
|
|
|
*
|
2000-07-15 07:13:43 +02:00
|
|
|
* Revision 1.19 2000/07/15 05:13:43 steve
|
|
|
|
|
* Detect muxing Vz as a bufufN.
|
|
|
|
|
*
|
2000-05-02 02:58:11 +02:00
|
|
|
* Revision 1.18 2000/05/02 00:58:12 steve
|
|
|
|
|
* Move signal tables to the NetScope class.
|
|
|
|
|
*
|
2000-04-20 02:28:03 +02:00
|
|
|
* Revision 1.17 2000/04/20 00:28:03 steve
|
|
|
|
|
* Catch some simple identity compareoptimizations.
|
|
|
|
|
*
|
2000-04-18 06:50:19 +02:00
|
|
|
* Revision 1.16 2000/04/18 04:50:19 steve
|
|
|
|
|
* Clean up unneeded NetEvent objects.
|
|
|
|
|
*
|
2000-04-17 01:32:18 +02:00
|
|
|
* Revision 1.15 2000/04/16 23:32:18 steve
|
|
|
|
|
* Synthesis of comparator in expressions.
|
|
|
|
|
*
|
|
|
|
|
* Connect the NetEvent and related classes
|
|
|
|
|
* together better.
|
|
|
|
|
*
|
2000-04-12 22:02:52 +02:00
|
|
|
* Revision 1.14 2000/04/12 20:02:53 steve
|
|
|
|
|
* Finally remove the NetNEvent and NetPEvent classes,
|
|
|
|
|
* Get synthesis working with the NetEvWait class,
|
|
|
|
|
* and get started supporting multiple events in a
|
|
|
|
|
* wait in vvm.
|
|
|
|
|
*
|
2000-04-01 23:40:22 +02:00
|
|
|
* Revision 1.13 2000/04/01 21:40:22 steve
|
|
|
|
|
* Add support for integer division.
|
|
|
|
|
*
|
2000-02-23 03:56:53 +01:00
|
|
|
* Revision 1.12 2000/02/23 02:56:54 steve
|
|
|
|
|
* Macintosh compilers do not support ident.
|
|
|
|
|
*
|
2000-02-13 05:35:43 +01:00
|
|
|
* Revision 1.11 2000/02/13 04:35:43 steve
|
|
|
|
|
* Include some block matching from Larry.
|
|
|
|
|
*
|
2000-01-13 04:35:35 +01:00
|
|
|
* Revision 1.10 2000/01/13 03:35:35 steve
|
|
|
|
|
* Multiplication all the way to simulation.
|
|
|
|
|
*
|
2000-01-02 18:57:20 +01:00
|
|
|
* Revision 1.9 2000/01/02 17:57:20 steve
|
|
|
|
|
* Handle nodes running out during node scan.
|
|
|
|
|
*
|
1999-12-30 05:19:12 +01:00
|
|
|
* Revision 1.8 1999/12/30 04:19:12 steve
|
|
|
|
|
* Propogate constant 0 in low bits of adders.
|
|
|
|
|
*
|
1999-12-17 07:18:15 +01:00
|
|
|
* Revision 1.7 1999/12/17 06:18:16 steve
|
|
|
|
|
* Rewrite the cprop functor to use the functor_t interface.
|
|
|
|
|
*
|
1999-12-05 03:24:08 +01:00
|
|
|
* Revision 1.6 1999/12/05 02:24:08 steve
|
|
|
|
|
* Synthesize LPM_RAM_DQ for writes into memories.
|
|
|
|
|
*
|
1999-12-01 07:06:16 +01:00
|
|
|
* Revision 1.5 1999/12/01 06:06:16 steve
|
|
|
|
|
* Redo synth to use match_proc_t scanner.
|
|
|
|
|
*
|
1999-11-18 04:52:19 +01:00
|
|
|
* Revision 1.4 1999/11/18 03:52:19 steve
|
|
|
|
|
* Turn NetTmp objects into normal local NetNet objects,
|
|
|
|
|
* and add the nodangle functor to clean up the local
|
|
|
|
|
* symbols generated by elaboration and other steps.
|
|
|
|
|
*
|
1999-11-01 03:07:40 +01:00
|
|
|
* Revision 1.3 1999/11/01 02:07:40 steve
|
|
|
|
|
* Add the synth functor to do generic synthesis
|
|
|
|
|
* and add the LPM_FF device to handle rows of
|
|
|
|
|
* flip-flops.
|
|
|
|
|
*
|
1999-07-18 07:52:46 +02:00
|
|
|
* Revision 1.2 1999/07/18 05:52:46 steve
|
|
|
|
|
* xnfsyn generates DFF objects for XNF output, and
|
|
|
|
|
* properly rewrites the Design netlist in the process.
|
|
|
|
|
*
|
1999-07-18 00:01:13 +02:00
|
|
|
* Revision 1.1 1999/07/17 22:01:13 steve
|
|
|
|
|
* Add the functor interface for functor transforms.
|
1998-11-04 00:28:49 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|