1998-11-04 00:28:49 +01:00
|
|
|
/*
|
2012-02-12 22:21:30 +01:00
|
|
|
* Copyright (c) 1999-2012 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
|
2012-08-29 03:41:23 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1998-11-04 00:28:49 +01:00
|
|
|
*/
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::event(Design*, NetEvent*)
|
2000-04-18 06:50:19 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::signal(Design*, NetNet*)
|
1999-07-18 00:01:13 +02:00
|
|
|
{
|
|
|
|
|
}
|
1998-11-04 00:28:49 +01:00
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::process(Design*, NetProcTop*)
|
1998-11-04 00:28:49 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_abs(Design*, NetAbs*)
|
2008-05-06 07:00:39 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_add_sub(Design*, NetAddSub*)
|
1999-12-30 05:19:12 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_compare(Design*, NetCompare*)
|
2000-04-20 02:28:03 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_const(Design*, NetConst*)
|
1999-12-17 07:18:15 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_divide(Design*, NetDivide*)
|
2000-04-01 23:40:22 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_literal(Design*, NetLiteral*)
|
2005-07-07 18:22:49 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_modulo(Design*, NetModulo*)
|
2000-09-17 23:26:15 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_ff(Design*, NetFF*)
|
1999-11-01 03:07:40 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_logic(Design*, NetLogic*)
|
1999-12-17 07:18:15 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_mult(Design*, NetMult*)
|
2000-01-13 04:35:35 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_mux(Design*, NetMux*)
|
2000-07-15 07:13:43 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_pow(Design*, NetPow*)
|
2008-01-31 02:53:06 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::sign_extend(Design*, NetSignExtend*)
|
2005-05-24 03:44:27 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 22:21:30 +01:00
|
|
|
void functor_t::lpm_ureduce(Design*, NetUReduce*)
|
2005-02-03 05:56:20 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-15 07:13:43 +02:00
|
|
|
|
2000-04-18 06:50:19 +02:00
|
|
|
void NetScope::run_functor(Design*des, functor_t*fun)
|
|
|
|
|
{
|
2009-12-09 00:14:55 +01:00
|
|
|
for (map<hname_t,NetScope*>::const_iterator cur = children_.begin()
|
2010-10-23 23:57:59 +02:00
|
|
|
; cur != children_.end() ; ++ cur )
|
2009-12-09 00:14:55 +01:00
|
|
|
cur->second->run_functor(des, fun);
|
2000-04-18 06:50:19 +02:00
|
|
|
|
|
|
|
|
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.
|
2008-10-27 04:42:11 +01:00
|
|
|
|
|
|
|
|
signals_map_iter_t cur = signals_map_.begin();
|
|
|
|
|
while (cur != signals_map_.end()) {
|
|
|
|
|
signals_map_iter_t tmp = cur;
|
2011-01-05 02:41:19 +01:00
|
|
|
++ cur;
|
2008-10-27 04:42:11 +01:00
|
|
|
fun->signal(des, tmp->second);
|
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
|
2004-10-04 03:10:51 +02:00
|
|
|
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
|
2010-10-23 23:57:59 +02:00
|
|
|
scope != root_scopes_.end(); ++ scope )
|
2001-10-19 23:53:24 +02:00
|
|
|
(*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_) {
|
2002-08-16 07:18:27 +02:00
|
|
|
assert(nodes_functor_cur_ == 0);
|
|
|
|
|
assert(nodes_functor_nxt_ == 0);
|
|
|
|
|
|
2000-07-16 06:56:07 +02:00
|
|
|
/* Scan the circular list of nodes, starting with the
|
2002-08-16 07:18:27 +02:00
|
|
|
front of the list.
|
|
|
|
|
|
|
|
|
|
This loop interacts with the Design::del_node method
|
|
|
|
|
so that the functor is free to delete any nodes it
|
|
|
|
|
choose. The destructors of the NetNode objects call
|
|
|
|
|
the del_node method, which checks with the
|
|
|
|
|
nodes_functor_* members, to keep the iterator
|
|
|
|
|
operating safely. */
|
|
|
|
|
nodes_functor_cur_ = nodes_;
|
1999-11-01 03:07:40 +01:00
|
|
|
do {
|
2002-08-16 07:18:27 +02:00
|
|
|
nodes_functor_nxt_ = nodes_functor_cur_->node_next_;
|
|
|
|
|
nodes_functor_cur_->functor_node(this, fun);
|
|
|
|
|
|
|
|
|
|
if (nodes_functor_nxt_ == 0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
nodes_functor_cur_ = nodes_functor_nxt_;
|
|
|
|
|
} while (nodes_ && (nodes_functor_cur_ != nodes_));
|
|
|
|
|
nodes_functor_cur_ = 0;
|
|
|
|
|
nodes_functor_nxt_ = 0;
|
2000-07-16 06:56:07 +02:00
|
|
|
|
1999-11-01 03:07:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void NetNode::functor_node(Design*, functor_t*)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-06 07:00:39 +02:00
|
|
|
void NetAbs::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_abs(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2005-07-07 18:22:49 +02:00
|
|
|
void NetLiteral::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_literal(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-31 02:53:06 +01:00
|
|
|
void NetPow::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_pow(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-24 03:44:27 +02:00
|
|
|
void NetSignExtend::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->sign_extend(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-03 05:56:20 +01:00
|
|
|
void NetUReduce::functor_node(Design*des, functor_t*fun)
|
|
|
|
|
{
|
|
|
|
|
fun->lpm_ureduce(des, this);
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-01 07:06:16 +01:00
|
|
|
proc_match_t::~proc_match_t()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-01 22:37:06 +01:00
|
|
|
int NetProc::match_proc(proc_match_t*)
|
1999-12-01 07:06:16 +01:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-13 05:35:43 +01:00
|
|
|
int proc_match_t::block(NetBlock*)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NetBlock::match_proc(proc_match_t*that)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
}
|