2 * Copyright (c) 1999-2005 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 #ident "$Id: functor.cc,v 1.35 2005/07/07 16:22:49 steve Exp $"
30 functor_t::~functor_t()
34 void functor_t::event(class Design
*, class NetEvent
*)
38 void functor_t::signal(class Design
*, class NetNet
*)
42 void functor_t::process(class Design
*, class NetProcTop
*)
46 void functor_t::lpm_add_sub(class Design
*, class NetAddSub
*)
50 void functor_t::lpm_compare(class Design
*, class NetCompare
*)
54 void functor_t::lpm_const(class Design
*, class NetConst
*)
58 void functor_t::lpm_divide(class Design
*, class NetDivide
*)
62 void functor_t::lpm_literal(class Design
*, class NetLiteral
*)
66 void functor_t::lpm_modulo(class Design
*, class NetModulo
*)
70 void functor_t::lpm_ff(class Design
*, class NetFF
*)
74 void functor_t::lpm_logic(class Design
*, class NetLogic
*)
78 void functor_t::lpm_mult(class Design
*, class NetMult
*)
82 void functor_t::lpm_mux(class Design
*, class NetMux
*)
86 void functor_t::sign_extend(class Design
*, class NetSignExtend
*)
90 void functor_t::lpm_ureduce(class Design
*, class NetUReduce
*)
95 void NetScope::run_functor(Design
*des
, functor_t
*fun
)
97 for (NetScope
*cur
= sub_
; cur
; cur
= cur
->sib_
) {
98 cur
->run_functor(des
, fun
);
101 for (NetEvent
*cur
= events_
; cur
; /* */) {
104 fun
->event(des
, tmp
);
107 // apply to signals. Each iteration, allow for the possibility
108 // that the current signal deletes itself.
111 NetNet
*cur
= signals_
->sig_next_
;
114 cur
= cur
->sig_next_
;
115 } while (cur
!= signals_
->sig_next_
);
117 cur
= signals_
->sig_next_
;
118 for (unsigned idx
= 0 ; idx
< count
; idx
+= 1) {
119 NetNet
*tmp
= cur
->sig_next_
;
120 fun
->signal(des
, cur
);
126 void Design::functor(functor_t
*fun
)
129 for (list
<NetScope
*>::const_iterator scope
= root_scopes_
.begin();
130 scope
!= root_scopes_
.end(); scope
++)
131 (*scope
)->run_functor(this, fun
);
133 // apply to processes
136 NetProcTop
*idx
= procs_idx_
;
137 procs_idx_
= idx
->next_
;
138 fun
->process(this, idx
);
143 assert(nodes_functor_cur_
== 0);
144 assert(nodes_functor_nxt_
== 0);
146 /* Scan the circular list of nodes, starting with the
149 This loop interacts with the Design::del_node method
150 so that the functor is free to delete any nodes it
151 choose. The destructors of the NetNode objects call
152 the del_node method, which checks with the
153 nodes_functor_* members, to keep the iterator
155 nodes_functor_cur_
= nodes_
;
157 nodes_functor_nxt_
= nodes_functor_cur_
->node_next_
;
158 nodes_functor_cur_
->functor_node(this, fun
);
160 if (nodes_functor_nxt_
== 0)
163 nodes_functor_cur_
= nodes_functor_nxt_
;
164 } while (nodes_
&& (nodes_functor_cur_
!= nodes_
));
165 nodes_functor_cur_
= 0;
166 nodes_functor_nxt_
= 0;
172 void NetNode::functor_node(Design
*, functor_t
*)
176 void NetAddSub::functor_node(Design
*des
, functor_t
*fun
)
178 fun
->lpm_add_sub(des
, this);
181 void NetCompare::functor_node(Design
*des
, functor_t
*fun
)
183 fun
->lpm_compare(des
, this);
186 void NetConst::functor_node(Design
*des
, functor_t
*fun
)
188 fun
->lpm_const(des
, this);
191 void NetDivide::functor_node(Design
*des
, functor_t
*fun
)
193 fun
->lpm_divide(des
, this);
196 void NetFF::functor_node(Design
*des
, functor_t
*fun
)
198 fun
->lpm_ff(des
, this);
201 void NetLiteral::functor_node(Design
*des
, functor_t
*fun
)
203 fun
->lpm_literal(des
, this);
206 void NetLogic::functor_node(Design
*des
, functor_t
*fun
)
208 fun
->lpm_logic(des
, this);
211 void NetModulo::functor_node(Design
*des
, functor_t
*fun
)
213 fun
->lpm_modulo(des
, this);
216 void NetMult::functor_node(Design
*des
, functor_t
*fun
)
218 fun
->lpm_mult(des
, this);
221 void NetMux::functor_node(Design
*des
, functor_t
*fun
)
223 fun
->lpm_mux(des
, this);
226 void NetSignExtend::functor_node(Design
*des
, functor_t
*fun
)
228 fun
->sign_extend(des
, this);
231 void NetUReduce::functor_node(Design
*des
, functor_t
*fun
)
233 fun
->lpm_ureduce(des
, this);
236 proc_match_t::~proc_match_t()
240 int NetProc::match_proc(proc_match_t
*that
)
245 int proc_match_t::assign(NetAssign
*)
250 int NetAssign::match_proc(proc_match_t
*that
)
252 return that
->assign(this);
255 int proc_match_t::assign_nb(NetAssignNB
*)
260 int NetAssignNB::match_proc(proc_match_t
*that
)
262 return that
->assign_nb(this);
265 int proc_match_t::block(NetBlock
*)
270 int NetBlock::match_proc(proc_match_t
*that
)
272 return that
->block(this);
275 int proc_match_t::condit(NetCondit
*)
280 int NetCondit::match_proc(proc_match_t
*that
)
282 return that
->condit(this);
285 int NetEvWait::match_proc(proc_match_t
*that
)
287 return that
->event_wait(this);
290 int proc_match_t::event_wait(NetEvWait
*)
296 * $Log: functor.cc,v $
297 * Revision 1.35 2005/07/07 16:22:49 steve
298 * Generalize signals to carry types.
300 * Revision 1.34 2005/05/24 01:44:27 steve
301 * Do sign extension of structuran nets.
303 * Revision 1.33 2005/02/03 04:56:20 steve
304 * laborate reduction gates into LPM_RED_ nodes.
306 * Revision 1.32 2004/10/04 01:10:53 steve
307 * Clean up spurious trailing white space.
309 * Revision 1.31 2002/08/16 05:18:27 steve
310 * Fix intermix of node functors and node delete.
312 * Revision 1.30 2002/08/12 01:34:59 steve
313 * conditional ident string using autoconfig.
315 * Revision 1.29 2002/08/10 22:07:38 steve
316 * Remove useless error messages.
318 * Revision 1.28 2002/06/05 03:44:25 steve
319 * Add support for memory words in l-value of
320 * non-blocking assignments, and remove the special
321 * NetAssignMem_ and NetAssignMemNB classes.
323 * Revision 1.27 2002/06/04 05:38:44 steve
324 * Add support for memory words in l-value of
325 * blocking assignments, and remove the special
326 * NetAssignMem class.
328 * Revision 1.26 2001/10/19 21:53:24 steve
329 * Support multiple root modules (Philip Blundell)
331 * Revision 1.25 2001/07/25 03:10:49 steve
332 * Create a config.h.in file to hold all the config
333 * junk, and support gcc 3.0. (Stephan Boettcher)
335 * Revision 1.24 2000/11/19 20:48:30 steve
336 * Fix cases where signal iteration might die early.
338 * Revision 1.23 2000/11/18 04:53:04 steve
339 * Watch out in functor, it may delete the last signal.
341 * Revision 1.22 2000/09/17 21:26:15 steve
342 * Add support for modulus (Eric Aardoom)
344 * Revision 1.21 2000/08/01 02:48:41 steve
345 * Support <= in synthesis of DFF and ram devices.