Document the predefined __ICARUS__ macro
[iverilog.git] / target.cc
blob674ff156a5d0be702824b6e3128323b85bfb133a
1 /*
2 * Copyright (c) 1998-2003 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)
8 * any later version.
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
19 #ifdef HAVE_CVS_IDENT
20 #ident "$Id: target.cc,v 1.81 2007/06/02 03:42:13 steve Exp $"
21 #endif
23 # include "config.h"
25 # include <iostream>
27 # include "target.h"
28 # include <typeinfo>
30 target_t::~target_t()
34 void target_t::scope(const NetScope*)
38 void target_t::event(const NetEvent*ev)
40 cerr << ev->get_line() << ": error: target (" << typeid(*this).name()
41 << "): Unhandled event <" << ev->name() << ">." << endl;
44 bool target_t::signal_paths(const NetNet*)
46 return true;
48 bool target_t::func_def(const NetScope*)
50 cerr << "target (" << typeid(*this).name() << "): "
51 "Unhandled function definition." << endl;
52 return false;
55 void target_t::task_def(const NetScope*)
57 cerr << "target (" << typeid(*this).name() << "): "
58 "Unhandled task definition." << endl;
61 void target_t::logic(const NetLogic*)
63 cerr << "target (" << typeid(*this).name() << "): "
64 "Unhandled logic gate" << endl;
67 bool target_t::bufz(const NetBUFZ*)
69 cerr << "target (" << typeid(*this).name() << "): "
70 "Unhandled continuous assign (BUFZ)." << endl;
71 return false;
74 void target_t::udp(const NetUDP*)
76 cerr << "target (" << typeid(*this).name() << "): "
77 "Unhandled UDP." << endl;
80 bool target_t::ureduce(const NetUReduce*)
82 cerr << "target (" << typeid(*this).name() << "): "
83 "Unhandled unary reduction logic gate." << endl;
84 return false;
87 void target_t::lpm_add_sub(const NetAddSub*)
89 cerr << "target (" << typeid(*this).name() << "): "
90 "Unhandled NetAddSub." << endl;
93 bool target_t::lpm_array_dq(const NetArrayDq*)
95 cerr << "target (" << typeid(*this).name() << "): "
96 "Unhandled NetArrayDq." << endl;
97 return false;
100 void target_t::lpm_clshift(const NetCLShift*)
102 cerr << "target (" << typeid(*this).name() << "): "
103 "Unhandled NetCLShift." << endl;
106 void target_t::lpm_compare(const NetCompare*)
108 cerr << "target (" << typeid(*this).name() << "): "
109 "Unhandled NetCompare." << endl;
112 void target_t::lpm_divide(const NetDivide*)
114 cerr << "target (" << typeid(*this).name() << "): "
115 "Unhandled NetDivide." << endl;
118 void target_t::lpm_modulo(const NetModulo*)
120 cerr << "target (" << typeid(*this).name() << "): "
121 "Unhandled NetModulo." << endl;
124 void target_t::lpm_ff(const NetFF*)
126 cerr << "target (" << typeid(*this).name() << "): "
127 "Unhandled NetFF." << endl;
130 void target_t::lpm_mult(const NetMult*)
132 cerr << "target (" << typeid(*this).name() << "): "
133 "Unhandled NetMult." << endl;
136 void target_t::lpm_mux(const NetMux*)
138 cerr << "target (" << typeid(*this).name() << "): "
139 "Unhandled NetMux." << endl;
141 bool target_t::concat(const NetConcat*)
143 cerr << "target (" << typeid(*this).name() << "): "
144 "Unhandled NetConcat." << endl;
145 return false;
148 bool target_t::part_select(const NetPartSelect*)
150 cerr << "target (" << typeid(*this).name() << "): "
151 "Unhandled NetPartSelect." << endl;
152 return false;
155 bool target_t::replicate(const NetReplicate*)
157 cerr << "target (" << typeid(*this).name() << "): "
158 "Unhandled NetReplicate." << endl;
159 return false;
162 void target_t::net_case_cmp(const NetCaseCmp*)
164 cerr << "target (" << typeid(*this).name() << "): "
165 "Unhandled case compare node." << endl;
168 bool target_t::net_const(const NetConst*)
170 cerr << "target (" << typeid(*this).name() << "): "
171 "Unhandled CONSTANT node." << endl;
172 return false;
175 bool target_t::net_sysfunction(const NetSysFunc*net)
177 cerr << "target (" << typeid(*this).name() << "): "
178 "Unhandled NetSysFunc node." << endl;
179 return false;
182 bool target_t::net_function(const NetUserFunc*net)
184 cerr << "target (" << typeid(*this).name() << "): "
185 "Unhandled NetUserFunc node." << endl;
186 return false;
189 bool target_t::net_literal(const NetLiteral*)
191 cerr << "target (" << typeid(*this).name() << "): "
192 "Unhandled LITERAL node." << endl;
193 return false;
196 void target_t::net_probe(const NetEvProbe*net)
198 cerr << "target (" << typeid(*this).name() << "): "
199 "Unhandled probe trigger node" << endl;
200 net->dump_node(cerr, 4);
203 bool target_t::sign_extend(const NetSignExtend*net)
205 cerr << "target (" << typeid(*this).name() << "): "
206 "Unhandled NetSignExtend node." << endl;
207 return false;
210 bool target_t::process(const NetProcTop*top)
212 return top->statement()->emit_proc(this);
215 void target_t::proc_assign(const NetAssign*)
217 cerr << "target (" << typeid(*this).name() << "): "
218 "Unhandled procedural assignment." << endl;
221 void target_t::proc_assign_nb(const NetAssignNB*)
223 cerr << "target (" << typeid(*this).name() << "): "
224 "Unhandled non-blocking assignment." << endl;
227 bool target_t::proc_block(const NetBlock*)
229 cerr << "target (" << typeid(*this).name() << "): "
230 "Unhandled proc_block." << endl;
231 return false;
234 void target_t::proc_case(const NetCase*cur)
236 cerr << "target (" << typeid(*this).name() << "): "
237 "Unhandled case:" << endl;
238 cur->dump(cerr, 6);
241 bool target_t::proc_cassign(const NetCAssign*dev)
243 cerr << "target (" << typeid(*this).name() << "): ";
244 cerr << dev->get_line();
245 cerr << ": Target does not support procedural continuous assignment." << endl;
246 return false;
249 bool target_t::proc_condit(const NetCondit*condit)
251 cerr << "target (" << typeid(*this).name() << "): "
252 "Unhandled conditional:" << endl;
253 condit->dump(cerr, 6);
254 return false;
257 bool target_t::proc_deassign(const NetDeassign*dev)
259 cerr << dev->get_line() << ": internal error: "
260 << "target (" << typeid(*this).name() << "): "
261 << "Unhandled proc_deassign." << endl;
262 return false;
265 bool target_t::proc_delay(const NetPDelay*)
267 cerr << "target (" << typeid(*this).name() << "): "
268 "Unhandled proc_delay." << endl;
269 return false;
272 bool target_t::proc_disable(const NetDisable*obj)
274 cerr << obj->get_line() << ": internal error: "
275 << "target (" << typeid(*this).name() << "): "
276 << "does not support disable statements." << endl;
277 return false;
280 bool target_t::proc_force(const NetForce*dev)
282 cerr << "target (" << typeid(*this).name() << "): "
283 "Unhandled proc_force." << endl;
284 return false;
287 void target_t::proc_forever(const NetForever*)
289 cerr << "target (" << typeid(*this).name() << "): "
290 "Unhandled proc_forever." << endl;
293 bool target_t::proc_release(const NetRelease*dev)
295 cerr << dev->get_line() << ": internal error: "
296 << "target (" << typeid(*this).name() << "): "
297 << "Unhandled proc_release." << endl;
298 return false;
301 void target_t::proc_repeat(const NetRepeat*)
303 cerr << "target (" << typeid(*this).name() << "): "
304 "Unhandled proc_repeat." << endl;
307 bool target_t::proc_trigger(const NetEvTrig*tr)
309 cerr << tr->get_line() << ": error: target (" << typeid(*this).name()
310 << "): Unhandled event trigger." << endl;
311 return false;
314 void target_t::proc_stask(const NetSTask*)
316 cerr << "target (" << typeid(*this).name() << "): "
317 "Unhandled proc_stask." << endl;
320 void target_t::proc_utask(const NetUTask*)
322 cerr << "target (" << typeid(*this).name() << "): "
323 "Unhandled proc_utask." << endl;
326 bool target_t::proc_wait(const NetEvWait*tr)
328 cerr << tr->get_line() << ": error: target (" << typeid(*this).name()
329 << "): Unhandled event wait." << endl;
330 return false;
333 void target_t::proc_while(const NetWhile*net)
335 cerr << "target (" << typeid(*this).name() << "): "
336 "Unhandled while:" << endl;
337 net->dump(cerr, 6);
340 int target_t::end_design(const Design*)
342 return 0;
345 expr_scan_t::~expr_scan_t()
349 void expr_scan_t::expr_const(const NetEConst*)
351 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
352 "unhandled expr_const." << endl;
355 void expr_scan_t::expr_param(const NetEConstParam*that)
357 expr_const(that);
360 void expr_scan_t::expr_creal(const NetECReal*)
362 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
363 "unhandled expr_creal." << endl;
366 void expr_scan_t::expr_rparam(const NetECRealParam*that)
368 expr_creal(that);
371 void expr_scan_t::expr_concat(const NetEConcat*that)
373 cerr << that->get_line() << ": expr_scan_t (" <<
374 typeid(*this).name() << "): unhandled expr_concat." << endl;
376 void expr_scan_t::expr_event(const NetEEvent*)
378 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
379 "unhandled expr_event." << endl;
382 void expr_scan_t::expr_scope(const NetEScope*)
384 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
385 "unhandled expr_scope." << endl;
388 void expr_scan_t::expr_select(const NetESelect*)
390 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
391 "unhandled expr_select." << endl;
394 void expr_scan_t::expr_sfunc(const NetESFunc*)
396 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
397 "unhandled expr_sfunc." << endl;
400 void expr_scan_t::expr_signal(const NetESignal*)
402 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
403 "unhandled expr_signal." << endl;
406 void expr_scan_t::expr_ternary(const NetETernary*)
408 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
409 "unhandled expr_ternary." << endl;
412 void expr_scan_t::expr_ufunc(const NetEUFunc*)
414 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
415 "unhandled function call." << endl;
418 void expr_scan_t::expr_unary(const NetEUnary*)
420 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
421 "unhandled expr_unary." << endl;
424 void expr_scan_t::expr_binary(const NetEBinary*ex)
426 cerr << "expr_scan_t (" << typeid(*this).name() << "): "
427 "unhandled expr_binary: " <<*ex << endl;
431 * $Log: target.cc,v $
432 * Revision 1.81 2007/06/02 03:42:13 steve
433 * Properly evaluate scope path expressions.
435 * Revision 1.80 2007/01/16 05:44:16 steve
436 * Major rework of array handling. Memories are replaced with the
437 * more general concept of arrays. The NetMemory and NetEMemory
438 * classes are removed from the ivl core program, and the IVL_LPM_RAM
439 * lpm type is removed from the ivl_target API.
441 * Revision 1.79 2006/11/10 05:44:45 steve
442 * Process delay paths in second path over signals.
444 * Revision 1.78 2006/06/18 04:15:50 steve
445 * Add support for system functions in continuous assignments.
447 * Revision 1.77 2005/07/11 16:56:51 steve
448 * Remove NetVariable and ivl_variable_t structures.
450 * Revision 1.76 2005/07/07 16:22:49 steve
451 * Generalize signals to carry types.
453 * Revision 1.75 2005/05/24 01:44:28 steve
454 * Do sign extension of structuran nets.
456 * Revision 1.74 2005/02/08 00:12:36 steve
457 * Add the NetRepeat node, and code generator support.
459 * Revision 1.73 2005/02/03 04:56:21 steve
460 * laborate reduction gates into LPM_RED_ nodes.
462 * Revision 1.72 2005/01/24 05:28:31 steve
463 * Remove the NetEBitSel and combine all bit/part select
464 * behavior into the NetESelect node and IVL_EX_SELECT
465 * ivl_target expression type.
467 * Revision 1.71 2004/12/29 23:55:43 steve
468 * Unify elaboration of l-values for all proceedural assignments,
469 * including assing, cassign and force.
471 * Generate NetConcat devices for gate outputs that feed into a
472 * vector results. Use this to hande gate arrays. Also let gate
473 * arrays handle vectors of gates when the outputs allow for it.
475 * Revision 1.70 2004/12/11 02:31:28 steve
476 * Rework of internals to carry vectors through nexus instead
477 * of single bits. Make the ivl, tgt-vvp and vvp initial changes
478 * down this path.
480 * Revision 1.69 2004/05/31 23:34:39 steve
481 * Rewire/generalize parsing an elaboration of
482 * function return values to allow for better
483 * speed and more type support.
485 * Revision 1.68 2003/05/30 02:55:32 steve
486 * Support parameters in real expressions and
487 * as real expressions, and fix multiply and
488 * divide with real results.
490 * Revision 1.67 2003/04/22 04:48:30 steve
491 * Support event names as expressions elements.
493 * Revision 1.66 2003/03/10 23:40:54 steve
494 * Keep parameter constants for the ivl_target API.
496 * Revision 1.65 2003/01/30 16:23:08 steve
497 * Spelling fixes.
499 * Revision 1.64 2003/01/26 21:15:59 steve
500 * Rework expression parsing and elaboration to
501 * accommodate real/realtime values and expressions.
503 * Revision 1.63 2002/08/12 01:35:01 steve
504 * conditional ident string using autoconfig.
506 * Revision 1.62 2002/06/05 03:44:25 steve
507 * Add support for memory words in l-value of
508 * non-blocking assignments, and remove the special
509 * NetAssignMem_ and NetAssignMemNB classes.
511 * Revision 1.61 2002/06/04 05:38:44 steve
512 * Add support for memory words in l-value of
513 * blocking assignments, and remove the special
514 * NetAssignMem class.
516 * Revision 1.60 2002/03/09 02:10:22 steve
517 * Add the NetUserFunc netlist node.
519 * Revision 1.59 2002/01/28 00:52:41 steve
520 * Add support for bit select of parameters.
521 * This leads to a NetESelect node and the
522 * vvp code generator to support that.
524 * Revision 1.58 2002/01/19 19:02:08 steve
525 * Pass back target errors processing conditionals.
527 * Revision 1.57 2001/08/25 23:50:03 steve
528 * Change the NetAssign_ class to refer to the signal
529 * instead of link into the netlist. This is faster
530 * and uses less space. Make the NetAssignNB carry
531 * the delays instead of the NetAssign_ lval objects.
533 * Change the vvp code generator to support multiple
534 * l-values, i.e. concatenations of part selects.
536 * Revision 1.56 2001/07/27 04:51:44 steve
537 * Handle part select expressions as variants of
538 * NetESignal/IVL_EX_SIGNAL objects, instead of
539 * creating new and useless temporary signals.
541 * Revision 1.55 2001/07/25 03:10:50 steve
542 * Create a config.h.in file to hold all the config
543 * junk, and support gcc 3.0. (Stephan Boettcher)
545 * Revision 1.54 2001/06/27 18:34:43 steve
546 * Report line of unsupported cassign.
548 * Revision 1.53 2001/04/22 23:09:46 steve
549 * More UDP consolidation from Stephan Boettcher.
551 * Revision 1.52 2001/04/06 02:28:02 steve
552 * Generate vvp code for functions with ports.
554 * Revision 1.51 2001/04/02 02:28:13 steve
555 * Generate code for task calls.
557 * Revision 1.50 2001/03/27 03:31:06 steve
558 * Support error code from target_t::end_design method.
560 * Revision 1.49 2000/09/26 01:35:42 steve
561 * Remove the obsolete NetEIdent class.
563 * Revision 1.48 2000/09/17 21:26:16 steve
564 * Add support for modulus (Eric Aardoom)
566 * Revision 1.47 2000/09/03 17:57:53 steve
567 * Slightly more helpful warning.
569 * Revision 1.46 2000/09/02 20:54:21 steve
570 * Rearrange NetAssign to make NetAssign_ separate.
572 * Revision 1.45 2000/08/27 15:51:51 steve
573 * t-dll iterates signals, and passes them to the
574 * target module.
576 * Some of NetObj should return char*, not string.
578 * Revision 1.44 2000/08/14 04:39:57 steve
579 * add th t-dll functions for net_const, net_bufz and processes.
581 * Revision 1.43 2000/08/09 03:43:45 steve
582 * Move all file manipulation out of target class.
584 * Revision 1.42 2000/08/08 01:50:42 steve
585 * target methods need not take a file stream.
587 * Revision 1.41 2000/07/29 16:21:08 steve
588 * Report code generation errors through proc_delay.
590 * Revision 1.40 2000/07/27 05:13:44 steve
591 * Support elaboration of disable statements.
593 * Revision 1.39 2000/05/11 23:37:27 steve
594 * Add support for procedural continuous assignment.
596 * Revision 1.38 2000/05/04 03:37:59 steve
597 * Add infrastructure for system functions, move
598 * $time to that structure and add $random.
600 * Revision 1.37 2000/04/23 03:45:24 steve
601 * Add support for the procedural release statement.
603 * Revision 1.36 2000/04/22 04:20:19 steve
604 * Add support for force assignment.
606 * Revision 1.35 2000/04/12 04:23:58 steve
607 * Named events really should be expressed with PEIdent
608 * objects in the pform,
610 * Handle named events within the mix of net events
611 * and edges. As a unified lot they get caught together.
612 * wait statements are broken into more complex statements
613 * that include a conditional.
615 * Do not generate NetPEvent or NetNEvent objects in
616 * elaboration. NetEvent, NetEvWait and NetEvProbe
617 * take over those functions in the netlist.
619 * Revision 1.34 2000/04/10 05:26:06 steve
620 * All events now use the NetEvent class.
622 * Revision 1.33 2000/04/04 03:20:15 steve
623 * Simulate named event trigger and waits.
625 * Revision 1.32 2000/04/01 21:40:23 steve
626 * Add support for integer division.