Merge similar probes within a module.
[iverilog.git] / netlist.h
bloba7c648039d8659cb663ae053f63a128f0be80641
1 #ifndef __netlist_H
2 #define __netlist_H
3 /*
4 * Copyright (c) 1998-2000 Stephen Williams (steve@icarus.com)
6 * This source code is free software; you can redistribute it
7 * and/or modify it in source code form under the terms of the GNU
8 * General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 #if !defined(WINNT) && !defined(macintosh)
22 #ident "$Id: netlist.h,v 1.139 2000/05/27 19:33:23 steve Exp $"
23 #endif
26 * The netlist types, as described in this header file, are intended
27 * to be the output from elaboration of the source design. The design
28 * can be passed around in this form to the various stages and design
29 * processors.
31 # include <string>
32 # include <map>
33 # include "verinum.h"
34 # include "LineInfo.h"
35 # include "svector.h"
37 class Design;
38 class Link;
39 class NetNode;
40 class NetProc;
41 class NetProcTop;
42 class NetScope;
43 class NetExpr;
44 class NetESignal;
45 class ostream;
48 struct target;
49 struct functor_t;
51 /* =========
52 * A NetObj is anything that has any kind of behavior in the
53 * netlist. Nodes can be gates, registers, etc. and are linked
54 * together to form a design web.
56 * The web of nodes that makes up a circuit is held together by the
57 * Link class. There is a link for each pin. All mutually connected
58 * pins form a ring of links.
60 * A link can be INPUT, OUTPUT or PASSIVE. An input never drives the
61 * signal, and PASSIVE never receives the value of the signal. Wires
62 * are PASSIVE, for example.
64 * A NetObj also has delays specified as rise_time, fall_time and
65 * decay_time. The rise and fall time are the times to transition to 1
66 * or 0 values. The decay_time is the time needed to decay to a 'bz
67 * value, or to decay of the net is a trireg. The exact and precise
68 * interpretation of the rise/fall/decay times is typically left to
69 * the target to properly interpret.
71 class NetObj {
73 public:
74 public:
75 explicit NetObj(const string&n, unsigned npins);
76 virtual ~NetObj();
78 const string& name() const { return name_; }
80 unsigned pin_count() const { return npins_; }
82 unsigned rise_time() const { return delay1_; }
83 unsigned fall_time() const { return delay2_; }
84 unsigned decay_time() const { return delay3_; }
86 void rise_time(unsigned d) { delay1_ = d; }
87 void fall_time(unsigned d) { delay2_ = d; }
88 void decay_time(unsigned d) { delay3_ = d; }
90 void set_attributes(const map<string,string>&);
91 string attribute(const string&key) const;
92 void attribute(const string&key, const string&value);
94 // Return true if this has all the attributes in that and they
95 // all have the same values.
96 bool has_compat_attributes(const NetObj&that) const;
98 bool test_mark() const { return mark_; }
99 void set_mark(bool flag=true) { mark_ = flag; }
101 Link&pin(unsigned idx);
102 const Link&pin(unsigned idx) const;
104 void dump_node_pins(ostream&, unsigned) const;
105 void dump_obj_attr(ostream&, unsigned) const;
107 private:
108 string name_;
109 Link*pins_;
110 const unsigned npins_;
111 unsigned delay1_;
112 unsigned delay2_;
113 unsigned delay3_;
115 map<string,string> attributes_;
117 bool mark_;
120 class Link {
121 friend void connect(Link&, Link&);
122 friend class NetObj;
124 public:
125 enum DIR { PASSIVE, INPUT, OUTPUT };
127 enum strength_t { HIGHZ, WEAK, PULL, STRONG, SUPPLY };
129 Link();
130 ~Link();
132 // Manipulate the link direction.
133 void set_dir(DIR d);
134 DIR get_dir() const;
136 void drive0(strength_t);
137 void drive1(strength_t);
139 strength_t drive0() const;
140 strength_t drive1() const;
142 void cur_link(NetObj*&net, unsigned &pin);
144 void next_link(NetObj*&net, unsigned&pin);
145 void next_link(const NetObj*&net, unsigned&pin) const;
147 Link* next_link();
148 const Link* next_link() const;
150 // Remove this link from the set of connected pins. The
151 // destructor will automatically do this if needed.
152 void unlink();
154 // Return true if this link is connected to anything else.
155 bool is_linked() const;
157 // Return true if these pins are connected.
158 bool is_linked(const Link&that) const;
160 // Return true if this link is connected to any pin of r.
161 bool is_linked(const NetObj&r) const;
163 // Return true if this is the same pin of the same object of
164 // that link.
165 bool is_equal(const Link&that) const;
167 // Return information about the object that this link is
168 // a part of.
169 const NetObj*get_obj() const;
170 NetObj*get_obj();
171 unsigned get_pin() const;
173 void set_name(const string&, unsigned inst =0);
174 const string& get_name() const;
175 unsigned get_inst() const;
177 private:
178 // The NetNode manages these. They point back to the
179 // NetNode so that following the links can get me here.
180 NetObj *node_;
181 unsigned pin_;
183 DIR dir_;
184 strength_t drive0_, drive1_;
186 // These members name the pin of the link. If the name
187 // has width, then the ninst_ member is the index of the
188 // pin.
189 string name_;
190 unsigned inst_;
192 private:
193 Link *next_;
194 Link *prev_;
196 private: // not implemented
197 Link(const Link&);
198 Link& operator= (const Link&);
202 * A NetNode is a device of some sort, where each pin has a different
203 * meaning. (i.e. pin(0) is the output to an and gate.) NetNode
204 * objects are listed in the nodes_ of the Design object.
206 class NetNode : public NetObj {
208 public:
209 explicit NetNode(const string&n, unsigned npins);
211 virtual ~NetNode();
213 // This method locates the next node that has all its pins
214 // connected to the same of my own pins.
215 NetNode*next_node();
217 virtual void emit_node(ostream&, struct target_t*) const;
218 virtual void dump_node(ostream&, unsigned) const;
220 virtual void functor_node(Design*, functor_t*);
222 private:
223 friend class Design;
224 NetNode*node_next_, *node_prev_;
225 Design*design_;
230 * NetNet is a special kind of NetObj that doesn't really do anything,
231 * but carries the properties of the wire/reg/trireg, including its
232 * name. A scaler wire is a NetNet with one pin, a vector a wider
233 * NetNet. NetNet objects also appear as side effects of synthesis or
234 * other abstractions.
236 * NetNet objects have a name and exist within a scope, so the
237 * constructor takes a pointer to the containing scope. The object
238 * automatically adds itself to the scope.
240 * NetNet objects are located by searching NetScope objects.
242 class NetNet : public NetObj, public LineInfo {
244 public:
245 enum Type { IMPLICIT, IMPLICIT_REG, WIRE, TRI, TRI1, SUPPLY0,
246 WAND, TRIAND, TRI0, SUPPLY1, WOR, TRIOR, REG, INTEGER };
248 enum PortType { NOT_A_PORT, PIMPLICIT, PINPUT, POUTPUT, PINOUT };
250 explicit NetNet(NetScope*s, const string&n, Type t, unsigned npins =1);
252 explicit NetNet(NetScope*s, const string&n, Type t, long ms, long ls);
254 virtual ~NetNet();
256 NetScope* scope();
257 const NetScope* scope() const;
259 Type type() const { return type_; }
260 void type(Type t) { type_ = t; }
262 PortType port_type() const { return port_type_; }
263 void port_type(PortType t) { port_type_ = t; }
265 /* These methods return the msb and lsb indices for the most
266 significant and least significant bits. These are signed
267 longs, and may be different from pin numbers. For example,
268 reg [1:8] has 8 bits, msb==1 and lsb==8. */
269 long msb() const { return msb_; }
270 long lsb() const { return lsb_; }
272 /* This method converts a signed index (the type that might be
273 found in the verilog source) to a pin number. It accounts
274 for variation in the definition of the reg/wire/whatever. */
275 unsigned sb_to_idx(long sb) const;
277 bool local_flag() const { return local_flag_; }
278 void local_flag(bool f) { local_flag_ = f; }
280 /* NetESignal objects may reference this object. Keep a
281 reference count so that I keep track of them. */
282 void incr_eref();
283 void decr_eref();
284 unsigned get_eref() const;
286 verinum::V get_ival(unsigned pin) const
287 { return ivalue_[pin]; }
288 void set_ival(unsigned pin, verinum::V val)
289 { ivalue_[pin] = val; }
291 virtual void dump_net(ostream&, unsigned) const;
293 private:
294 // The NetScope class uses this for listing signals.
295 friend class NetScope;
296 NetNet*sig_next_, *sig_prev_;
298 private:
299 NetScope*scope_;
300 Type type_;
301 PortType port_type_;
303 long msb_, lsb_;
305 bool local_flag_;
306 unsigned eref_count_;
308 verinum::V*ivalue_;
312 * This class implements the LPM_ADD_SUB component as described in the
313 * EDIF LPM Version 2 1 0 standard. It is used as a structural
314 * implementation of the + and - operators.
316 class NetAddSub : public NetNode {
318 public:
319 NetAddSub(const string&n, unsigned width);
320 ~NetAddSub();
322 // Get the width of the device (that is, the width of the
323 // operands and results.)
324 unsigned width() const;
326 Link& pin_Aclr();
327 Link& pin_Add_Sub();
328 Link& pin_Clock();
329 Link& pin_Cin();
330 Link& pin_Cout();
331 Link& pin_Overflow();
333 Link& pin_DataA(unsigned idx);
334 Link& pin_DataB(unsigned idx);
335 Link& pin_Result(unsigned idx);
337 const Link& pin_Cout() const;
338 const Link& pin_DataA(unsigned idx) const;
339 const Link& pin_DataB(unsigned idx) const;
340 const Link& pin_Result(unsigned idx) const;
342 virtual void dump_node(ostream&, unsigned ind) const;
343 virtual void emit_node(ostream&, struct target_t*) const;
344 virtual void functor_node(Design*des, functor_t*fun);
348 * This type represents the LPM_CLSHIFT device.
350 class NetCLShift : public NetNode {
352 public:
353 NetCLShift(const string&n, unsigned width, unsigned width_dist);
354 ~NetCLShift();
356 unsigned width() const;
357 unsigned width_dist() const;
359 Link& pin_Direction();
360 Link& pin_Underflow();
361 Link& pin_Overflow();
362 Link& pin_Data(unsigned idx);
363 Link& pin_Result(unsigned idx);
364 Link& pin_Distance(unsigned idx);
366 const Link& pin_Direction() const;
367 const Link& pin_Underflow() const;
368 const Link& pin_Overflow() const;
369 const Link& pin_Data(unsigned idx) const;
370 const Link& pin_Result(unsigned idx) const;
371 const Link& pin_Distance(unsigned idx) const;
373 virtual void dump_node(ostream&, unsigned ind) const;
374 virtual void emit_node(ostream&, struct target_t*) const;
376 private:
377 unsigned width_;
378 unsigned width_dist_;
382 * This class supports the LPM_COMPARE device.
384 * NOTE: This is not the same as the device used to support case
385 * compare. Case comparisons handle Vx and Vz values, whereas this
386 * device need not.
388 class NetCompare : public NetNode {
390 public:
391 NetCompare(const string&n, unsigned width);
392 ~NetCompare();
394 unsigned width() const;
396 Link& pin_Aclr();
397 Link& pin_Clock();
398 Link& pin_AGB();
399 Link& pin_AGEB();
400 Link& pin_AEB();
401 Link& pin_ANEB();
402 Link& pin_ALB();
403 Link& pin_ALEB();
405 Link& pin_DataA(unsigned idx);
406 Link& pin_DataB(unsigned idx);
408 const Link& pin_Aclr() const;
409 const Link& pin_Clock() const;
410 const Link& pin_AGB() const;
411 const Link& pin_AGEB() const;
412 const Link& pin_AEB() const;
413 const Link& pin_ANEB() const;
414 const Link& pin_ALB() const;
415 const Link& pin_ALEB() const;
417 const Link& pin_DataA(unsigned idx) const;
418 const Link& pin_DataB(unsigned idx) const;
420 virtual void functor_node(Design*, functor_t*);
421 virtual void dump_node(ostream&, unsigned ind) const;
422 virtual void emit_node(ostream&, struct target_t*) const;
424 private:
425 unsigned width_;
429 * This class represents a theoretical (though not necessarily
430 * practical) integer divider gate. This is not to represent any real
431 * hardware, but to support the / operator in Verilog, when it shows
432 * up in structural contexts.
434 * The operands of the operation are the DataA<i> and DataB<i> inputs,
435 * and the Result<i> output reflects the value DataA/DataB.
438 class NetDivide : public NetNode {
440 public:
441 NetDivide(const string&n, unsigned width, unsigned wa, unsigned wb);
442 ~NetDivide();
444 unsigned width_r() const;
445 unsigned width_a() const;
446 unsigned width_b() const;
448 Link& pin_DataA(unsigned idx);
449 Link& pin_DataB(unsigned idx);
450 Link& pin_Result(unsigned idx);
452 const Link& pin_DataA(unsigned idx) const;
453 const Link& pin_DataB(unsigned idx) const;
454 const Link& pin_Result(unsigned idx) const;
456 virtual void dump_node(ostream&, unsigned ind) const;
457 virtual void emit_node(ostream&, struct target_t*) const;
458 virtual void functor_node(Design*des, functor_t*fun);
460 private:
461 unsigned width_r_;
462 unsigned width_a_;
463 unsigned width_b_;
467 * This class represents an LPM_FF device. There is no literal gate
468 * type in Verilog that maps, but gates of this type can be inferred.
470 class NetFF : public NetNode {
472 public:
473 NetFF(const string&n, unsigned width);
474 ~NetFF();
476 unsigned width() const;
478 Link& pin_Clock();
479 Link& pin_Enable();
480 Link& pin_Aload();
481 Link& pin_Aset();
482 Link& pin_Aclr();
483 Link& pin_Sload();
484 Link& pin_Sset();
485 Link& pin_Sclr();
487 Link& pin_Data(unsigned);
488 Link& pin_Q(unsigned);
490 const Link& pin_Clock() const;
491 const Link& pin_Enable() const;
492 const Link& pin_Data(unsigned) const;
493 const Link& pin_Q(unsigned) const;
495 virtual void dump_node(ostream&, unsigned ind) const;
496 virtual void emit_node(ostream&, struct target_t*) const;
497 virtual void functor_node(Design*des, functor_t*fun);
502 * This class represents the declared memory object. The parser
503 * creates one of these for each declared memory in the elaborated
504 * design. A reference to one of these is handled by the NetEMemory
505 * object, which is derived from NetExpr. This is not a node because
506 * memory objects can only be accessed by behavioral code.
508 class NetMemory {
510 public:
511 NetMemory(NetScope*sc, const string&n, long w, long s, long e);
512 ~NetMemory();
514 const string&name() const { return name_; }
516 // This is the width (in bits) of a single memory position.
517 unsigned width() const { return width_; }
519 NetScope*scope();
520 const NetScope*scope() const;
522 // This is the number of memory positions.
523 unsigned count() const;
525 // This method returns a 0 based address of a memory entry as
526 // indexed by idx. The Verilog source may give index ranges
527 // that are not zero based.
528 unsigned index_to_address(long idx) const;
530 void set_attributes(const map<string,string>&a);
532 void dump(ostream&o, unsigned lm) const;
534 private:
535 string name_;
536 unsigned width_;
537 long idxh_;
538 long idxl_;
540 map<string,string> attributes_;
542 friend class NetRamDq;
543 NetRamDq* ram_list_;
545 friend class NetScope;
546 NetMemory*snext_, *sprev_;
547 NetScope*scope_;
549 private: // not implemented
550 NetMemory(const NetMemory&);
551 NetMemory& operator= (const NetMemory&);
555 * This class implements the LPM_MULT component as described in the
556 * EDIF LPM Version 2 1 0 standard. It is used as a structural
557 * implementation of the * operator. The device has inputs DataA and
558 * DataB that can have independent widths, as can the result. If the
559 * result is smaller then the widths of a and b together, then the
560 * device drops the least significant bits of the product.
562 class NetMult : public NetNode {
564 public:
565 NetMult(const string&n, unsigned width, unsigned wa, unsigned wb,
566 unsigned width_s =0);
567 ~NetMult();
569 // Get the width of the device bussed inputs. There are these
570 // parameterized widths:
571 unsigned width_r() const; // Result
572 unsigned width_a() const; // DataA
573 unsigned width_b() const; // DataB
574 unsigned width_s() const; // Sum (my be 0)
576 Link& pin_Aclr();
577 Link& pin_Clock();
579 Link& pin_DataA(unsigned idx);
580 Link& pin_DataB(unsigned idx);
581 Link& pin_Result(unsigned idx);
582 Link& pin_Sum(unsigned idx);
584 const Link& pin_Aclr() const;
585 const Link& pin_Clock() const;
587 const Link& pin_DataA(unsigned idx) const;
588 const Link& pin_DataB(unsigned idx) const;
589 const Link& pin_Result(unsigned idx) const;
590 const Link& pin_Sum(unsigned idx) const;
592 virtual void dump_node(ostream&, unsigned ind) const;
593 virtual void emit_node(ostream&, struct target_t*) const;
594 virtual void functor_node(Design*des, functor_t*fun);
596 private:
597 unsigned width_r_;
598 unsigned width_a_;
599 unsigned width_b_;
600 unsigned width_s_;
605 * This class represents an LPM_MUX device. This device has some
606 * number of Result points (the width of the device) and some number
607 * of input choices. There is also a selector of some width. The
608 * parameters are:
610 * width -- Width of the result and each possible Data input
611 * size -- Number of Data input (each of width)
612 * selw -- Width in bits of the select input
614 class NetMux : public NetNode {
616 public:
617 NetMux(const string&n, unsigned width, unsigned size, unsigned selw);
618 ~NetMux();
620 unsigned width() const;
621 unsigned size() const;
622 unsigned sel_width() const;
624 Link& pin_Aclr();
625 Link& pin_Clock();
627 Link& pin_Result(unsigned);
628 Link& pin_Data(unsigned wi, unsigned si);
629 Link& pin_Sel(unsigned);
631 const Link& pin_Aclr() const;
632 const Link& pin_Clock() const;
634 const Link& pin_Result(unsigned) const;
635 const Link& pin_Data(unsigned, unsigned) const;
636 const Link& pin_Sel(unsigned) const;
638 virtual void dump_node(ostream&, unsigned ind) const;
639 virtual void emit_node(ostream&, struct target_t*) const;
641 private:
642 unsigned width_;
643 unsigned size_;
644 unsigned swidth_;
648 * This device represents an LPM_RAM_DQ device. The actual content is
649 * represented by a NetMemory object allocated elsewhere, but that
650 * object fixes the width and size of the device. The pin count of the
651 * address input is given in the constructor.
653 class NetRamDq : public NetNode {
655 public:
656 NetRamDq(const string&name, NetMemory*mem, unsigned awid);
657 ~NetRamDq();
659 unsigned width() const;
660 unsigned awidth() const;
661 unsigned size() const;
662 const NetMemory*mem() const;
664 Link& pin_InClock();
665 Link& pin_OutClock();
666 Link& pin_WE();
668 Link& pin_Address(unsigned idx);
669 Link& pin_Data(unsigned idx);
670 Link& pin_Q(unsigned idx);
672 const Link& pin_InClock() const;
673 const Link& pin_OutClock() const;
674 const Link& pin_WE() const;
676 const Link& pin_Address(unsigned idx) const;
677 const Link& pin_Data(unsigned idx) const;
678 const Link& pin_Q(unsigned idx) const;
680 virtual void dump_node(ostream&, unsigned ind) const;
681 virtual void emit_node(ostream&, struct target_t*) const;
683 // Use this method to absorb other NetRamDq objects that are
684 // connected to the same memory, and have compatible pin
685 // connections.
686 void absorb_partners();
688 // Use this method to count the partners (including myself)
689 // that are ports to the attached memory.
690 unsigned count_partners() const;
692 private:
693 NetMemory*mem_;
694 NetRamDq*next_;
695 unsigned awidth_;
699 /* =========
700 * There are cases where expressions need to be represented. The
701 * NetExpr class is the root of a heirarchy that serves that purpose.
703 * The expr_width() is the width of the expression, that accounts
704 * for the widths of the sub-expressions I might have. It is up to the
705 * derived classes to properly set the expr width, if need be. The
706 * set_width() method is used to compel an expression to have a
707 * certain width, and is used particulary when the expression is an
708 * rvalue in an assignment statement.
710 class NetExpr : public LineInfo {
711 public:
712 explicit NetExpr(unsigned w =0);
713 virtual ~NetExpr() =0;
715 virtual void expr_scan(struct expr_scan_t*) const =0;
716 virtual void dump(ostream&) const;
718 // How wide am I?
719 unsigned expr_width() const { return width_; }
721 // Coerce the expression to have a specific width. If the
722 // coersion works, then return true. Otherwise, return false.
723 virtual bool set_width(unsigned);
725 // This method evaluates the expression and returns an
726 // equivilent expression that is reduced as far as compile
727 // time knows how. Essentially, this is designed to fold
728 // constants.
729 virtual NetExpr*eval_tree();
731 // Make a duplicate of myself, and subexpressions if I have
732 // any. This is a deep copy operation.
733 virtual NetExpr*dup_expr() const =0;
735 // Return a version of myself that is structural. This is used
736 // for converting expressions to gates.
737 virtual NetNet*synthesize(Design*);
740 protected:
741 void expr_width(unsigned w) { width_ = w; }
743 private:
744 unsigned width_;
746 private: // not implemented
747 NetExpr(const NetExpr&);
748 NetExpr& operator=(const NetExpr&);
752 * The expression constant is slightly special, and is sometimes
753 * returned from other classes that can be evaluated at compile
754 * time. This class represents constant values in expressions.
756 class NetEConst : public NetExpr {
758 public:
759 explicit NetEConst(const verinum&val);
760 ~NetEConst();
762 const verinum&value() const { return value_; }
764 virtual bool set_width(unsigned w);
765 virtual void expr_scan(struct expr_scan_t*) const;
766 virtual void dump(ostream&) const;
768 virtual NetEConst* dup_expr() const;
769 virtual NetNet*synthesize(Design*);
771 private:
772 verinum value_;
776 * The NetTmp object is a network that is only used momentarily by
777 * elaboration to carry links around. A completed netlist should not
778 * have any of these within. This is a kind of wire, so it is NetNet
779 * type. The constructor for this class also marks the NetNet as
780 * local, so that it is not likely to suppress a real symbol.
782 class NetTmp : public NetNet {
784 public:
785 explicit NetTmp(NetScope*s, const string&name, unsigned npins =1);
790 * The NetBUFZ is a magic device that represents the continuous
791 * assign, with the output being the target register and the input
792 * the logic that feeds it. The netlist preserves the directional
793 * nature of that assignment with the BUFZ. The target may elide it if
794 * that makes sense for the technology.
796 class NetBUFZ : public NetNode {
798 public:
799 explicit NetBUFZ(const string&n);
800 ~NetBUFZ();
802 virtual void dump_node(ostream&, unsigned ind) const;
803 virtual void emit_node(ostream&, struct target_t*) const;
807 * This node is used to represent case equality in combinational
808 * logic. Although this is not normally synthesizeable, it makes sense
809 * to support an abstract gate that can compare x and z.
811 * This pins are assigned as:
813 * 0 -- Output (always returns 0 or 1)
814 * 1 -- Input
815 * 2 -- Input
817 class NetCaseCmp : public NetNode {
819 public:
820 explicit NetCaseCmp(const string&n);
821 ~NetCaseCmp();
823 virtual void dump_node(ostream&, unsigned ind) const;
824 virtual void emit_node(ostream&, struct target_t*) const;
828 * This class represents instances of the LPM_CONSTANT device. The
829 * node has only outputs and a constant value. The width is available
830 * by getting the pin_count(), and the value bits are available one at
831 * a time. There is no meaning to the aggregation of bits to form a
832 * wide NetConst object, although some targets may have an easier time
833 * detecting interesting constructs if they are combined.
835 class NetConst : public NetNode {
837 public:
838 explicit NetConst(const string&n, verinum::V v);
839 explicit NetConst(const string&n, const verinum&val);
840 ~NetConst();
842 verinum::V value(unsigned idx) const;
844 virtual void emit_node(ostream&, struct target_t*) const;
845 virtual void functor_node(Design*, functor_t*);
846 virtual void dump_node(ostream&, unsigned ind) const;
848 private:
849 verinum::V*value_;
853 * This class represents all manner of logic gates. Pin 0 is OUTPUT and
854 * all the remaining pins are INPUT. The BUFIF[01] gates have the
855 * more specific pinout as follows:
857 * bufif<N>
858 * 0 -- output
859 * 1 -- input data
860 * 2 -- enable
862 class NetLogic : public NetNode {
864 public:
865 enum TYPE { AND, BUF, BUFIF0, BUFIF1, NAND, NOR, NOT, NOTIF0,
866 NOTIF1, OR, XNOR, XOR };
868 explicit NetLogic(const string&n, unsigned pins, TYPE t);
870 TYPE type() const { return type_; }
872 virtual void dump_node(ostream&, unsigned ind) const;
873 virtual void emit_node(ostream&, struct target_t*) const;
874 virtual void functor_node(Design*, functor_t*);
876 private:
877 const TYPE type_;
881 * The UDP is a User Defined Primitive from the Verilog source. Do not
882 * expand it out any further then this in the netlist, as this can be
883 * used to represent target device primitives.
885 * The UDP can be combinational or sequential. The sequential UDP
886 * includes the current output in the truth table, and supports edges,
887 * whereas the combinational does not and is entirely level sensitive.
888 * In any case, pin 0 is an output, and all the remaining pins are
889 * inputs.
891 * The sequential truth table is canonically represented as a finite state
892 * machine with the current state representing the inputs and the
893 * current output, and the next state carrying the new output value to
894 * use. All the outgoing transitions from a state represent a single
895 * edge.
897 * Set_table takes as input a string with one letter per pin. The
898 * parser translates the written sequences to one of these. The
899 * valid characters are:
901 * 0, 1, x -- The levels
902 * r -- (01)
903 * R -- (x1)
904 * f -- (10)
905 * F -- (x0)
906 * P -- (0x)
907 * N -- (1x)
909 * It also takes one of the following glob letters to represent more
910 * then one item.
912 * p -- 01, 0x or x1
913 * n -- 10, 1x or x0
914 * ? -- 0, 1, or x
915 * * -- any edge
916 * + -- 01 or x1
917 * _ -- 10 or x0 (Note that this is not the output '-'.)
918 * % -- 0x or 1x
920 * SEQUENTIAL
921 * These objects have a single bit of memory. The logic table includes
922 * an entry for the current value, and allows edges on the inputs. In
923 * canonical form, inly then entries that generate 0, 1 or - (no change)
924 * are listed.
926 * COMBINATIONAL
927 * The logic table is a map between the input levels and the
928 * output. Each input pin can have the value 0, 1 or x and the output
929 * can have the values 0 or 1. If the input matches nothing, the
930 * output is x. In canonical form, only the entries that generate 0 or
931 * 1 are listed.
934 class NetUDP : public NetNode {
936 public:
937 explicit NetUDP(const string&n, unsigned pins, bool sequ =false);
939 virtual void emit_node(ostream&, struct target_t*) const;
940 virtual void dump_node(ostream&, unsigned ind) const;
942 /* return false if the entry conflicts with an existing
943 entry. In any case, the new output overrides. */
944 bool set_table(const string&input, char output);
945 void cleanup_table();
947 /* Return the next output from the passed state. Each letter
948 of the input string represents the pin of the same
949 position. */
950 char table_lookup(const string&from, char to, unsigned pin) const;
952 void set_initial(char);
953 char get_initial() const { return init_; }
955 bool is_sequential() const { return sequential_; }
957 private:
958 bool sequential_;
959 char init_;
961 struct state_t_;
962 struct pin_t_ {
963 state_t_*zer;
964 state_t_*one;
965 state_t_*xxx;
967 explicit pin_t_() : zer(0), one(0), xxx(0) { }
970 struct state_t_ {
971 char out;
972 pin_t_*pins;
974 state_t_(unsigned n) : out(0), pins(new pin_t_[n]) {}
975 ~state_t_() { delete[]pins; }
978 typedef map<string,state_t_*> FSM_;
979 FSM_ fsm_;
980 bool set_sequ_(const string&in, char out);
981 bool sequ_glob_(string, char out);
983 state_t_*find_state_(const string&);
985 // A combinational primitive is more simply represented as a
986 // simple map of input signals to a single output.
987 typedef map<string,char> CM_;
988 CM_ cm_;
990 void dump_sequ_(ostream&o, unsigned ind) const;
991 void dump_comb_(ostream&o, unsigned ind) const;
994 class NetUDP_COMB : public NetNode {
996 public:
997 explicit NetUDP_COMB(const string&n, unsigned pins);
999 virtual void emit_node(ostream&, struct target_t*) const;
1000 virtual void dump_node(ostream&, unsigned ind) const;
1002 /* append a new truth table row. */
1003 void set_table(const string&input, char output);
1005 /* After the primitive is built up, this method is called to
1006 clean up redundancies, and possibly optimize the table. */
1007 void cleanup_table();
1009 /* Use these methods to scan the truth table of the
1010 device. "first" returns the first item in the table, and
1011 "next" returns the next item in the table. The method will
1012 return false when the scan is done. */
1013 bool first(string&inp, char&out) const;
1014 bool next(string&inp, char&out) const;
1016 private:
1018 // A combinational primitive is more simply represented as a
1019 // simple map of input signals to a single output.
1020 map<string,char> cm_;
1022 mutable map<string,char>::const_iterator idx_;
1027 /* =========
1028 * A process is a behavioral-model description. A process is a
1029 * statement that may be compound. the various statement types may
1030 * refer to places in a netlist (by pointing to nodes) but is not
1031 * linked into the netlist. However, elaborating a process may cause
1032 * special nodes to be created to handle things like events.
1034 class NetProc : public LineInfo {
1036 public:
1037 explicit NetProc();
1038 virtual ~NetProc();
1040 // This method is called to emit the statement to the
1041 // target. The target returns true if OK, false for errors.
1042 virtual bool emit_proc(ostream&, struct target_t*) const;
1044 // This method is called by functors that want to scan a
1045 // process in search of matchable patterns.
1046 virtual int match_proc(struct proc_match_t*);
1048 virtual void dump(ostream&, unsigned ind) const;
1050 private:
1051 friend class NetBlock;
1052 NetProc*next_;
1054 private: // not implemented
1055 NetProc(const NetProc&);
1056 NetProc& operator= (const NetProc&);
1060 * This is a procedural assignment. The lval is a register, and the
1061 * assignment happens when the code is executed by the design. The
1062 * node part of the NetAssign has as many pins as the width of the
1063 * lvalue object and represents the elaborated lvalue. Thus, this
1064 * appears as a procedural statement AND a structural node. The
1065 * LineInfo is the location of the assignment statement in the source.
1067 * NOTE: The elaborator will make an effort to match the width of the
1068 * r-value to the with of the assign node, but targets and functions
1069 * should know that this is not a guarantee.
1072 class NetAssign_ : public NetProc, public NetNode {
1074 public:
1076 // This is the (procedural) value that is to be assigned when
1077 // the assignment is executed.
1078 NetExpr*rval();
1079 const NetExpr*rval() const;
1081 // If this expression exists, then only a single bit is to be
1082 // set from the rval, and the value of this expression selects
1083 // the pin that gets the value.
1084 const NetExpr*bmux() const;
1086 void set_rval(NetExpr*);
1088 protected:
1089 NetAssign_(const string&n, unsigned w);
1090 virtual ~NetAssign_() =0;
1092 void set_bmux(NetExpr*);
1094 private:
1095 NetExpr*rval_;
1096 NetExpr*bmux_;
1099 class NetAssign : public NetAssign_ {
1100 public:
1101 explicit NetAssign(const string&, Design*des, unsigned w, NetExpr*rv);
1102 explicit NetAssign(const string&, Design*des, unsigned w,
1103 NetExpr*mux, NetExpr*rv);
1104 ~NetAssign();
1106 virtual bool emit_proc(ostream&, struct target_t*) const;
1107 virtual void emit_node(ostream&, struct target_t*) const;
1108 virtual int match_proc(struct proc_match_t*);
1109 virtual void dump(ostream&, unsigned ind) const;
1110 virtual void dump_node(ostream&, unsigned ind) const;
1112 private:
1116 * ... and this is a non-blocking version of above.
1118 class NetAssignNB : public NetAssign_ {
1119 public:
1120 explicit NetAssignNB(const string&, Design*des, unsigned w, NetExpr*rv);
1121 explicit NetAssignNB(const string&, Design*des, unsigned w,
1122 NetExpr*mux, NetExpr*rv);
1123 ~NetAssignNB();
1126 virtual bool emit_proc(ostream&, struct target_t*) const;
1127 virtual void emit_node(ostream&, struct target_t*) const;
1128 virtual void dump(ostream&, unsigned ind) const;
1129 virtual void dump_node(ostream&, unsigned ind) const;
1131 private:
1135 * Assignment to memory is handled separately because memory is
1136 * not a node. There are blocking and non-blocking variants, just like
1137 * regular assign, and the NetAssignMem_ base class takes care of all
1138 * the common stuff.
1140 class NetAssignMem_ : public NetProc {
1142 public:
1143 explicit NetAssignMem_(NetMemory*, NetNet*idx, NetExpr*rv);
1144 ~NetAssignMem_();
1146 NetMemory*memory() { return mem_; }
1147 NetNet*index() { return index_; }
1148 NetExpr*rval() { return rval_; }
1150 const NetMemory*memory()const { return mem_; }
1151 const NetNet*index()const { return index_; }
1152 const NetExpr*rval()const { return rval_; }
1154 private:
1155 NetMemory*mem_;
1156 NetNet * index_;
1157 NetExpr* rval_;
1160 class NetAssignMem : public NetAssignMem_ {
1162 public:
1163 explicit NetAssignMem(NetMemory*, NetNet*idx, NetExpr*rv);
1164 ~NetAssignMem();
1166 virtual int match_proc(struct proc_match_t*);
1167 virtual bool emit_proc(ostream&, struct target_t*) const;
1168 virtual void dump(ostream&, unsigned ind) const;
1170 private:
1173 class NetAssignMemNB : public NetAssignMem_ {
1175 public:
1176 explicit NetAssignMemNB(NetMemory*, NetNet*idx, NetExpr*rv);
1177 ~NetAssignMemNB();
1179 virtual bool emit_proc(ostream&, struct target_t*) const;
1180 virtual void dump(ostream&, unsigned ind) const;
1182 private:
1186 * A block is stuff like begin-end blocks, that contain an ordered
1187 * list of NetProc statements.
1189 * NOTE: The emit method calls the target->proc_block function but
1190 * does not recurse. It is up to the target-supplied proc_block
1191 * function to call emit_recurse.
1193 class NetBlock : public NetProc {
1195 public:
1196 enum Type { SEQU, PARA };
1198 NetBlock(Type t) : type_(t), last_(0) { }
1199 ~NetBlock();
1201 const Type type() const { return type_; }
1203 void append(NetProc*);
1205 const NetProc*proc_first() const;
1206 const NetProc*proc_next(const NetProc*cur) const;
1208 // This version of emit_recurse scans all the statements of
1209 // the begin-end block sequentially. It is typically of use
1210 // for sequential blocks.
1211 void emit_recurse(ostream&, struct target_t*) const;
1213 virtual bool emit_proc(ostream&, struct target_t*) const;
1214 virtual int match_proc(struct proc_match_t*);
1215 virtual void dump(ostream&, unsigned ind) const;
1217 private:
1218 const Type type_;
1220 NetProc*last_;
1224 * A CASE statement in the verilog source leads, eventually, to one of
1225 * these. This is different from a simple conditional because of the
1226 * way the comparisons are performed. Also, it is likely that the
1227 * target may be able to optimize differently.
1229 * Case cane be one of three types:
1230 * EQ -- All bits must exactly match
1231 * EQZ -- z bits are don't care
1232 * EQX -- x and z bits are don't care.
1234 class NetCase : public NetProc {
1236 public:
1237 enum TYPE { EQ, EQX, EQZ };
1238 NetCase(TYPE c, NetExpr*ex, unsigned cnt);
1239 ~NetCase();
1241 void set_case(unsigned idx, NetExpr*ex, NetProc*st);
1243 TYPE type() const;
1244 const NetExpr*expr() const { return expr_; }
1245 unsigned nitems() const { return nitems_; }
1247 const NetExpr*expr(unsigned idx) const { return items_[idx].guard;}
1248 const NetProc*stat(unsigned idx) const { return items_[idx].statement; }
1250 virtual bool emit_proc(ostream&, struct target_t*) const;
1251 virtual void dump(ostream&, unsigned ind) const;
1253 private:
1255 TYPE type_;
1257 struct Item {
1258 NetExpr*guard;
1259 NetProc*statement;
1262 NetExpr* expr_;
1263 unsigned nitems_;
1264 Item*items_;
1268 * The cassign statement causes the r-val net to be forced onto the
1269 * l-val reg when it is executed. The code generator is expected to
1270 * know what that means. All the expressions are structural and behave
1271 * like nets.
1273 * This class is a NetProc because it it turned on by procedural
1274 * behavior. However, it is also a NetNode because it connects to
1275 * nets, and when activated follows the net values.
1277 class NetCAssign : public NetProc, public NetNode {
1279 public:
1280 explicit NetCAssign(const string&n, NetNet*l);
1281 ~NetCAssign();
1283 const Link& lval_pin(unsigned) const;
1285 virtual void dump(ostream&, unsigned ind) const;
1286 virtual bool emit_proc(ostream&, struct target_t*) const;
1287 virtual void dump_node(ostream&, unsigned ind) const;
1288 virtual void emit_node(ostream&, struct target_t*) const;
1290 private:
1291 NetNet*lval_;
1293 private: // not implemented
1294 NetCAssign(const NetCAssign&);
1295 NetCAssign& operator= (const NetCAssign&);
1299 /* A condit represents a conditional. It has an expression to test,
1300 and a pair of statements to select from. */
1301 class NetCondit : public NetProc {
1303 public:
1304 explicit NetCondit(NetExpr*ex, NetProc*i, NetProc*e);
1305 ~NetCondit();
1307 const NetExpr*expr() const;
1308 NetExpr*expr();
1310 NetProc* if_clause();
1311 NetProc* else_clause();
1313 // Replace the condition expression.
1314 void set_expr(NetExpr*ex);
1316 void emit_recurse_if(ostream&, struct target_t*) const;
1317 void emit_recurse_else(ostream&, struct target_t*) const;
1319 virtual bool emit_proc(ostream&, struct target_t*) const;
1320 virtual int match_proc(struct proc_match_t*);
1321 virtual void dump(ostream&, unsigned ind) const;
1323 private:
1324 NetExpr* expr_;
1325 NetProc*if_;
1326 NetProc*else_;
1330 * The procedural deassign statement (the opposite of assign) releases
1331 * any assign expressions attached to the bits of the reg. The
1332 * lval is the expression of the "deassign <expr>;" statement with the
1333 * expr elaborated to a net.
1335 class NetDeassign : public NetProc {
1337 public:
1338 explicit NetDeassign(NetNet*l);
1339 ~NetDeassign();
1341 const NetNet*lval() const;
1343 virtual bool emit_proc(ostream&, struct target_t*) const;
1344 virtual void dump(ostream&, unsigned ind) const;
1346 private:
1347 NetNet*lval_;
1349 private: // not implemented
1350 NetDeassign(const NetDeassign&);
1351 NetDeassign& operator= (const NetDeassign&);
1355 * A NetEvent is an object that represents an event object, that is
1356 * objects declared like so in Verilog:
1358 * event foo;
1360 * Once an object of this type exists, behavioral code can wait on the
1361 * event or trigger the event. Event waits refer to this object, as do
1362 * the event trigger statements.
1364 * The NetEvWait class represents a thread wait for an event. When
1365 * this statement is executed, it starts waiting on the
1366 * event. Conceptually, it puts itself on the event list for the
1367 * referenced event. When the event is triggered, the wit ends its
1368 * block and starts the associated statement.
1370 * The NetEvTrig class represents trigger statements. Executing this
1371 * statement causes the referenced event to be triggered, which it
1372 * turn awakens the waiting threads. Each NetEvTrig object references
1373 * exactly one event object.
1375 * The NetEvProbe class is the structural equivilent of the NetEvTrig,
1376 * in that it is a node and watches bit values that it receives. It
1377 * checks for edges then if appropriate triggers the associated
1378 * NetEvent. Each NetEvProbe references exactly one event object, and
1379 * the NetEvent objects have a list of NetEvProbe objects that
1380 * reference it.
1382 class NetEvent : public LineInfo {
1384 friend class NetScope;
1385 friend class NetEvProbe;
1386 friend class NetEvTrig;
1387 friend class NetEvWait;
1389 public:
1390 explicit NetEvent (const string&n);
1391 ~NetEvent();
1393 string name() const;
1394 string full_name() const;
1396 // Get information about probes connected to me.
1397 unsigned nprobe() const;
1398 NetEvProbe* probe(unsigned);
1400 // Return the number of NetEvWait nodes that reference me.
1401 unsigned nwait() const;
1403 unsigned ntrig() const;
1405 NetScope* scope();
1406 const NetScope* scope() const;
1408 NetEvent* find_similar_event();
1410 private:
1411 string name_;
1413 // The NetScope class uses these to list the events.
1414 NetScope*scope_;
1415 NetEvent*snext_;
1417 // Use these methods to list the probes attached to me.
1418 NetEvProbe*probes_;
1420 // Use these methods to list the triggers attached to me.
1421 NetEvTrig* trig_;
1423 // Use This member to count references by NetEvWait objects.
1424 unsigned waitref_;
1426 private: // not implemented
1427 NetEvent(const NetEvent&);
1428 NetEvent& operator= (const NetEvent&);
1431 class NetEvTrig : public NetProc {
1433 friend class NetEvent;
1435 public:
1436 explicit NetEvTrig(NetEvent*tgt);
1437 ~NetEvTrig();
1439 const NetEvent*event() const;
1441 virtual bool emit_proc(ostream&, struct target_t*) const;
1442 virtual void dump(ostream&, unsigned ind) const;
1444 private:
1445 NetEvent*event_;
1446 // This is used to place me in the NetEvents lists of triggers.
1447 NetEvTrig*enext_;
1450 class NetEvWait : public NetProc {
1452 public:
1453 explicit NetEvWait(NetProc*st);
1454 ~NetEvWait();
1456 void add_event(NetEvent*tgt);
1458 unsigned nevents() const;
1459 const NetEvent*event(unsigned) const;
1460 NetEvent*event(unsigned);
1462 NetProc*statement();
1464 virtual bool emit_proc(ostream&, struct target_t*) const;
1465 bool emit_recurse(ostream&, struct target_t*) const;
1466 virtual int match_proc(struct proc_match_t*);
1467 virtual void dump(ostream&, unsigned ind) const;
1469 private:
1470 NetProc*statement_;
1472 unsigned nevents_;
1473 NetEvent**events_;
1476 class NetEvProbe : public NetNode {
1478 friend class NetEvent;
1480 public:
1481 enum edge_t { ANYEDGE, POSEDGE, NEGEDGE };
1483 explicit NetEvProbe(const string&n, NetEvent*tgt,
1484 edge_t t, unsigned p);
1485 ~NetEvProbe();
1487 edge_t edge() const;
1488 NetEvent* event();
1489 const NetEvent* event() const;
1491 virtual void emit_node(ostream&, struct target_t*) const;
1492 virtual void dump_node(ostream&, unsigned ind) const;
1494 private:
1495 NetEvent*event_;
1496 edge_t edge_;
1497 // The NetEvent class uses this to list me.
1498 NetEvProbe*enext_;
1502 * The force statement causes the r-val net to be forced onto the
1503 * l-val net when it is executed. The code generator is expected to
1504 * know what that means. All the expressions are structural and behave
1505 * like nets.
1507 * This class is a NetProc because it it turned on by procedural
1508 * behavior. However, it is also a NetNode because it connects to
1509 * nets, and when activated follows the net values.
1511 class NetForce : public NetProc, public NetNode {
1513 public:
1514 explicit NetForce(const string&n, NetNet*l);
1515 ~NetForce();
1517 const Link& lval_pin(unsigned) const;
1519 virtual void dump(ostream&, unsigned ind) const;
1520 virtual bool emit_proc(ostream&, struct target_t*) const;
1521 virtual void dump_node(ostream&, unsigned ind) const;
1522 virtual void emit_node(ostream&, struct target_t*) const;
1524 private:
1525 NetNet*lval_;
1529 * A forever statement is executed over and over again forever. Or
1530 * until its block is disabled.
1532 class NetForever : public NetProc {
1534 public:
1535 explicit NetForever(NetProc*s);
1536 ~NetForever();
1538 void emit_recurse(ostream&, struct target_t*) const;
1540 virtual bool emit_proc(ostream&, struct target_t*) const;
1541 virtual void dump(ostream&, unsigned ind) const;
1543 private:
1544 NetProc*statement_;
1548 * A funciton definition is elaborated just like a task, though by now
1549 * it is certain that the first parameter (a phantom parameter) is the
1550 * output and all the remaining parameters are the inputs. This makes
1551 * for easy code generation in targets that support behavioral descriptions.
1553 class NetFuncDef {
1555 public:
1556 NetFuncDef(NetScope*, const svector<NetNet*>&po);
1557 ~NetFuncDef();
1559 void set_proc(NetProc*st);
1561 const string name() const;
1562 const NetProc*proc() const;
1563 NetScope*scope();
1565 unsigned port_count() const;
1566 const NetNet*port(unsigned idx) const;
1568 virtual void dump(ostream&, unsigned ind) const;
1570 private:
1571 NetScope*scope_;
1572 NetProc*statement_;
1573 svector<NetNet*>ports_;
1576 class NetPDelay : public NetProc {
1578 public:
1579 NetPDelay(unsigned long d, NetProc*st)
1580 : delay_(d), statement_(st) { }
1582 unsigned long delay() const { return delay_; }
1584 virtual bool emit_proc(ostream&, struct target_t*) const;
1585 virtual void dump(ostream&, unsigned ind) const;
1587 void emit_proc_recurse(ostream&, struct target_t*) const;
1589 private:
1590 unsigned long delay_;
1591 NetProc*statement_;
1595 * A repeat statement is executed some fixed number of times.
1597 class NetRepeat : public NetProc {
1599 public:
1600 explicit NetRepeat(NetExpr*e, NetProc*s);
1601 ~NetRepeat();
1603 const NetExpr*expr() const;
1604 void emit_recurse(ostream&, struct target_t*) const;
1606 virtual bool emit_proc(ostream&, struct target_t*) const;
1607 virtual void dump(ostream&, unsigned ind) const;
1609 private:
1610 NetExpr*expr_;
1611 NetProc*statement_;
1615 * The procedural release statement (the opposite of force) releases
1616 * any force expressions attached to the bits of the wire or reg. The
1617 * lval is the expression of the "release <expr>;" statement with the
1618 * expr elaborated to a net.
1620 class NetRelease : public NetProc {
1622 public:
1623 explicit NetRelease(NetNet*l);
1624 ~NetRelease();
1626 const NetNet*lval() const;
1628 virtual bool emit_proc(ostream&, struct target_t*) const;
1629 virtual void dump(ostream&, unsigned ind) const;
1631 private:
1632 NetNet*lval_;
1637 * The NetSTask class is a call to a system task. These kinds of tasks
1638 * are generally handled very simply in the target. They certainly are
1639 * handled differently from user defined tasks because ivl knows all
1640 * about the user defined tasks.
1642 class NetSTask : public NetProc {
1644 public:
1645 NetSTask(const string&na, const svector<NetExpr*>&);
1646 ~NetSTask();
1648 const string& name() const { return name_; }
1650 unsigned nparms() const { return parms_.count(); }
1652 const NetExpr* parm(unsigned idx) const;
1654 virtual bool emit_proc(ostream&, struct target_t*) const;
1655 virtual void dump(ostream&, unsigned ind) const;
1657 private:
1658 string name_;
1659 svector<NetExpr*>parms_;
1663 * This class represents an elaborated class definition. NetUTask
1664 * classes may refer to objects of this type to get the meaning of the
1665 * defined task.
1667 * The task also introduces a scope, and the parameters are actually
1668 * reg objects in the new scope. The task is called by the calling
1669 * thread assigning (blocking assignment) to the in and inout
1670 * paramters, then invoking the thread, and finally assigning out the
1671 * output and inout variables. The variables accessable as ports are
1672 * also elaborated and accessible as ordinary reg objects.
1674 class NetTaskDef {
1676 public:
1677 NetTaskDef(const string&n, const svector<NetNet*>&po);
1678 ~NetTaskDef();
1680 void set_proc(NetProc*p);
1682 const string& name() const;
1683 const NetProc*proc() const;
1685 unsigned port_count() const;
1686 NetNet*port(unsigned idx);
1688 void dump(ostream&, unsigned) const;
1690 private:
1691 string name_;
1692 NetProc*proc_;
1693 svector<NetNet*>ports_;
1695 private: // not implemented
1696 NetTaskDef(const NetTaskDef&);
1697 NetTaskDef& operator= (const NetTaskDef&);
1701 * This node represents a function call in an expression. The object
1702 * contains a pointer to the function definition, which is used to
1703 * locate the value register and input expressions.
1705 * The NetNet parameter to the constructor is the *register* NetNet
1706 * that receives the result of the function, and the NetExpr list is
1707 * the paraneters passed to the function.
1709 class NetEUFunc : public NetExpr {
1711 public:
1712 NetEUFunc(NetFuncDef*, NetESignal*, svector<NetExpr*>&);
1713 ~NetEUFunc();
1715 const string name() const;
1717 const NetESignal*result() const;
1718 unsigned parm_count() const;
1719 const NetExpr* parm(unsigned idx) const;
1721 const NetFuncDef* definition() const;
1723 virtual bool set_width(unsigned);
1724 virtual void dump(ostream&) const;
1726 virtual void expr_scan(struct expr_scan_t*) const;
1727 virtual NetEUFunc*dup_expr() const;
1729 private:
1730 NetFuncDef*func_;
1731 NetESignal*result_;
1732 svector<NetExpr*> parms_;
1734 private: // not implemented
1735 NetEUFunc(const NetEUFunc&);
1736 NetEUFunc& operator= (const NetEUFunc&);
1740 * A call to a user defined task is elaborated into this object. This
1741 * contains a pointer to the elaborated task definition, but is a
1742 * NetProc object so that it can be linked into statements.
1744 class NetUTask : public NetProc {
1746 public:
1747 NetUTask(NetTaskDef*);
1748 ~NetUTask();
1750 const string& name() const { return task_->name(); }
1752 virtual bool emit_proc(ostream&, struct target_t*) const;
1753 virtual void dump(ostream&, unsigned ind) const;
1755 private:
1756 NetTaskDef*task_;
1760 * The while statement is a condition that is tested in the front of
1761 * each iteration, and a statement (a NetProc) that is executed as
1762 * long as the condition is true.
1764 class NetWhile : public NetProc {
1766 public:
1767 NetWhile(NetExpr*c, NetProc*p)
1768 : cond_(c), proc_(p) { }
1770 const NetExpr*expr() const { return cond_; }
1772 void emit_proc_recurse(ostream&, struct target_t*) const;
1774 virtual bool emit_proc(ostream&, struct target_t*) const;
1775 virtual void dump(ostream&, unsigned ind) const;
1777 private:
1778 NetExpr* cond_;
1779 NetProc*proc_;
1784 * The is the top of any process. It carries the type (initial or
1785 * always) and a pointer to the statement, probably a block, that
1786 * makes up the process.
1788 class NetProcTop : public LineInfo {
1790 public:
1791 enum Type { KINITIAL, KALWAYS };
1793 NetProcTop(Type t, class NetProc*st);
1794 ~NetProcTop();
1796 Type type() const { return type_; }
1797 NetProc*statement();
1798 const NetProc*statement() const;
1800 void dump(ostream&, unsigned ind) const;
1801 bool emit(ostream&, struct target_t*tgt) const;
1803 private:
1804 const Type type_;
1805 NetProc*const statement_;
1807 friend class Design;
1808 NetProcTop*next_;
1812 * This class represents a binary operator, with the left and right
1813 * operands and a single character for the operator. The operator
1814 * values are:
1816 * ^ -- Bit-wise exclusive OR
1817 * + -- Arithmetic add
1818 * - -- Arithmetic minus
1819 * * -- Arithmetic multiply
1820 * / -- Arithmetic divide
1821 * % -- Arithmetic modulus
1822 * & -- Bit-wise AND
1823 * | -- Bit-wise OR
1824 * < -- Less then
1825 * > -- Greater then
1826 * e -- Logical equality (==)
1827 * E -- Case equality (===)
1828 * L -- Less or equal
1829 * G -- Greater or equal
1830 * n -- Logical inequality (!=)
1831 * N -- Case inequality (!==)
1832 * a -- Logical AND (&&)
1833 * o -- Logical OR (||)
1834 * O -- Bit-wise NOR
1835 * l -- Left shift (<<)
1836 * r -- Right shift (>>)
1837 * X -- Bitwise exclusive NOR (~^)
1839 class NetEBinary : public NetExpr {
1841 public:
1842 NetEBinary(char op, NetExpr*l, NetExpr*r);
1843 ~NetEBinary();
1845 const NetExpr*left() const { return left_; }
1846 const NetExpr*right() const { return right_; }
1848 char op() const { return op_; }
1850 virtual bool set_width(unsigned w);
1852 virtual NetEBinary* dup_expr() const;
1854 virtual void expr_scan(struct expr_scan_t*) const;
1855 virtual void dump(ostream&) const;
1857 protected:
1858 char op_;
1859 NetExpr* left_;
1860 NetExpr* right_;
1862 virtual void eval_sub_tree_();
1866 * The addition operators have slightly more complex width
1867 * calculations because there is the optional carry bit that can be
1868 * used. The operators covered by this class are:
1869 * + -- Arithmetic add
1870 * - -- Arithmetic minus
1872 class NetEBAdd : public NetEBinary {
1874 public:
1875 NetEBAdd(char op, NetExpr*l, NetExpr*r);
1876 ~NetEBAdd();
1878 virtual bool set_width(unsigned w);
1879 virtual NetEBAdd* dup_expr() const;
1880 virtual NetEConst* eval_tree();
1881 virtual NetNet* synthesize(Design*);
1885 * This class represents the integer division operators.
1886 * / -- Divide
1887 * % -- Modulus
1889 class NetEBDiv : public NetEBinary {
1891 public:
1892 NetEBDiv(char op, NetExpr*l, NetExpr*r);
1893 ~NetEBDiv();
1895 virtual bool set_width(unsigned w);
1896 virtual NetEBDiv* dup_expr() const;
1897 virtual NetEConst* eval_tree();
1898 virtual NetNet* synthesize(Design*);
1902 * The bitwise binary operators are represented by this class. This is
1903 * a specialization of the binary operator, so is derived from
1904 * NetEBinary. The particular constraints on these operators are that
1905 * operand and result widths match exactly, and each bit slice of the
1906 * operation can be represented by a simple gate. The operators
1907 * covered by this class are:
1909 * ^ -- Bit-wise exclusive OR
1910 * & -- Bit-wise AND
1911 * | -- Bit-wise OR
1912 * O -- Bit-wise NOR
1913 * X -- Bit-wise XNOR (~^)
1915 class NetEBBits : public NetEBinary {
1917 public:
1918 NetEBBits(char op, NetExpr*l, NetExpr*r);
1919 ~NetEBBits();
1921 virtual bool set_width(unsigned w);
1922 virtual NetEBBits* dup_expr() const;
1924 virtual NetNet* synthesize(Design*);
1928 * The binary comparison operators are handled by this class. This
1929 * this case the bit width of the expression is 1 bit, and the
1930 * operands take their natural widths. The supported operators are:
1932 * < -- Less then
1933 * > -- Greater then
1934 * e -- Logical equality (==)
1935 * E -- Case equality (===)
1936 * L -- Less or equal (<=)
1937 * G -- Greater or equal (>=)
1938 * n -- Logical inequality (!=)
1939 * N -- Case inequality (!==)
1941 class NetEBComp : public NetEBinary {
1943 public:
1944 NetEBComp(char op, NetExpr*l, NetExpr*r);
1945 ~NetEBComp();
1947 virtual bool set_width(unsigned w);
1948 virtual NetEBComp* dup_expr() const;
1949 virtual NetEConst* eval_tree();
1951 virtual NetNet* synthesize(Design*);
1953 private:
1954 NetEConst*eval_eqeq_();
1955 NetEConst*eval_leeq_();
1960 * The binary logical operators are those that return boolean
1961 * results. The supported operators are:
1963 * a -- Logical AND (&&)
1965 class NetEBLogic : public NetEBinary {
1967 public:
1968 NetEBLogic(char op, NetExpr*l, NetExpr*r);
1969 ~NetEBLogic();
1971 virtual bool set_width(unsigned w);
1972 virtual NetEBLogic* dup_expr() const;
1973 virtual NetEConst* eval_tree();
1975 private:
1980 * Support the binary multiplication (*) operator.
1982 class NetEBMult : public NetEBinary {
1984 public:
1985 NetEBMult(char op, NetExpr*l, NetExpr*r);
1986 ~NetEBMult();
1988 virtual bool set_width(unsigned w);
1989 virtual NetEBMult* dup_expr() const;
1990 virtual NetEConst* eval_tree();
1992 private:
1997 * The binary logical operators are those that return boolean
1998 * results. The supported operators are:
2000 * l -- left shift (<<)
2001 * r -- right shift (>>)
2003 class NetEBShift : public NetEBinary {
2005 public:
2006 NetEBShift(char op, NetExpr*l, NetExpr*r);
2007 ~NetEBShift();
2009 virtual bool set_width(unsigned w);
2010 virtual NetEBShift* dup_expr() const;
2011 virtual NetEConst* eval_tree();
2013 private:
2018 * This expression node supports the concat expression. This is an
2019 * operator that just glues the results of many expressions into a
2020 * single value.
2022 * Note that the class stores the parameter expressions in source code
2023 * order. That is, the parm(0) is placed in the most significant
2024 * position of the result.
2026 class NetEConcat : public NetExpr {
2028 public:
2029 NetEConcat(unsigned cnt, unsigned repeat =1);
2030 ~NetEConcat();
2032 // Manipulate the parameters.
2033 void set(unsigned idx, NetExpr*e);
2035 unsigned repeat() const { return repeat_; }
2036 unsigned nparms() const { return parms_.count() ; }
2037 NetExpr* parm(unsigned idx) const { return parms_[idx]; }
2039 virtual bool set_width(unsigned w);
2040 virtual NetEConcat* dup_expr() const;
2041 virtual NetExpr* eval_tree();
2042 virtual NetNet*synthesize(Design*);
2043 virtual void expr_scan(struct expr_scan_t*) const;
2044 virtual void dump(ostream&) const;
2046 private:
2047 svector<NetExpr*>parms_;
2048 unsigned repeat_;
2052 * This clas is a placeholder for a parameter expression. When
2053 * parameters are first created, an instance of this object is used to
2054 * hold the place where the parameter exression goes. Then, when the
2055 * parameters are resolved, these objects are removed.
2057 * If the parameter object is created with a path and name, then the
2058 * object represents a reference to a parameter that is known to exist.
2060 class NetEParam : public NetExpr {
2061 public:
2062 NetEParam();
2063 NetEParam(class Design*des, NetScope*scope, const string&name);
2064 ~NetEParam();
2066 virtual bool set_width(unsigned w);
2067 virtual void expr_scan(struct expr_scan_t*) const;
2068 virtual NetExpr* eval_tree();
2069 virtual NetEParam* dup_expr() const;
2071 virtual void dump(ostream&) const;
2073 private:
2074 Design*des_;
2075 NetScope*scope_;
2076 string name_;
2081 * This class is a special (and magical) expression node type that
2082 * represents scope names. These can only be found as parameters to
2083 * NetSTask objects.
2085 class NetEScope : public NetExpr {
2087 public:
2088 NetEScope(NetScope*);
2089 ~NetEScope();
2091 const NetScope* scope() const;
2093 virtual void expr_scan(struct expr_scan_t*) const;
2094 virtual NetEScope* dup_expr() const;
2096 virtual void dump(ostream&os) const;
2098 private:
2099 NetScope*scope_;
2103 * This node represents a system function call in an expression. The
2104 * object contains the name of the system function, which the backend
2105 * uses to do VPI matching.
2107 class NetESFunc : public NetExpr {
2109 public:
2110 NetESFunc(const string&name, unsigned width, unsigned nprms);
2111 ~NetESFunc();
2113 const string& name() const;
2115 unsigned nparms() const;
2116 void parm(unsigned idx, NetExpr*expr);
2117 NetExpr* parm(unsigned idx);
2118 const NetExpr* parm(unsigned idx) const;
2120 virtual bool set_width(unsigned);
2121 virtual void dump(ostream&) const;
2123 virtual void expr_scan(struct expr_scan_t*) const;
2124 virtual NetESFunc*dup_expr() const;
2126 private:
2127 string name_;
2128 unsigned nparms_;
2129 NetExpr**parms_;
2131 private: // not implemented
2132 NetESFunc(const NetESFunc&);
2133 NetESFunc& operator= (const NetESFunc&);
2137 * This class represents the ternary (?:) operator. It has 3
2138 * expressions, one of which is a condition used to select which of
2139 * the other two expressions is the result.
2141 class NetETernary : public NetExpr {
2143 public:
2144 NetETernary(NetExpr*c, NetExpr*t, NetExpr*f);
2145 ~NetETernary();
2147 virtual bool set_width(unsigned w);
2149 const NetExpr*cond_expr() const;
2150 const NetExpr*true_expr() const;
2151 const NetExpr*false_expr() const;
2153 virtual NetETernary* dup_expr() const;
2155 virtual void expr_scan(struct expr_scan_t*) const;
2156 virtual void dump(ostream&) const;
2157 virtual NetNet*synthesize(Design*);
2159 private:
2160 NetExpr*cond_;
2161 NetExpr*true_val_;
2162 NetExpr*false_val_;
2166 * This class represents a unary operator, with the single operand
2167 * and a single character for the operator. The operator values are:
2169 * ~ -- Bit-wise negation
2170 * ! -- Logical negation
2171 * & -- Reduction AND
2172 * | -- Reduction OR
2173 * ^ -- Reduction XOR
2174 * + --
2175 * - --
2176 * A -- Reduction NAND (~&)
2177 * N -- Reduction NOR (~|)
2178 * X -- Reduction NXOR (~^ or ^~)
2180 class NetEUnary : public NetExpr {
2182 public:
2183 NetEUnary(char op, NetExpr*ex);
2184 ~NetEUnary();
2186 char op() const { return op_; }
2187 const NetExpr* expr() const { return expr_; }
2189 virtual bool set_width(unsigned w);
2191 virtual NetEUnary* dup_expr() const;
2193 virtual void expr_scan(struct expr_scan_t*) const;
2194 virtual void dump(ostream&) const;
2196 protected:
2197 char op_;
2198 NetExpr* expr_;
2201 class NetEUBits : public NetEUnary {
2203 public:
2204 NetEUBits(char op, NetExpr*ex);
2205 ~NetEUBits();
2207 virtual NetNet* synthesize(Design*);
2211 /* System identifiers are represented here. */
2212 class NetEIdent : public NetExpr {
2214 public:
2215 NetEIdent(const string&n, unsigned w)
2216 : NetExpr(w), name_(n) { }
2218 const string& name() const { return name_; }
2220 NetEIdent* dup_expr() const;
2222 virtual void expr_scan(struct expr_scan_t*) const;
2223 virtual void dump(ostream&) const;
2225 private:
2226 string name_;
2230 * A reference to a memory is represented by this expression. If the
2231 * index is not supplied, then the node is only valid in certain
2232 * specific contexts.
2234 class NetEMemory : public NetExpr {
2236 public:
2237 NetEMemory(NetMemory*mem, NetExpr*idx =0);
2238 virtual ~NetEMemory();
2240 const string& name () const { return mem_->name(); }
2241 const NetExpr* index() const { return idx_; }
2243 virtual bool set_width(unsigned);
2245 virtual NetEMemory*dup_expr() const;
2247 virtual void expr_scan(struct expr_scan_t*) const;
2248 virtual void dump(ostream&) const;
2250 private:
2251 NetMemory*mem_;
2252 NetExpr* idx_;
2256 * When a signal shows up in an expression, this type represents
2257 * it. From this the expression can get any kind of access to the
2258 * structural signal.
2260 * A signal shows up as a node in the netlist so that structural
2261 * activity can invoke the expression.
2263 class NetESignal : public NetExpr {
2265 public:
2266 NetESignal(NetNet*n);
2267 ~NetESignal();
2269 const string& name() const;
2270 virtual bool set_width(unsigned);
2272 virtual NetESignal* dup_expr() const;
2273 NetNet* synthesize(Design*des);
2275 // These methods actually reference the properties of the
2276 // NetNet object that I point to.
2277 unsigned pin_count() const;
2278 Link& pin(unsigned idx);
2280 virtual void expr_scan(struct expr_scan_t*) const;
2281 virtual void dump(ostream&) const;
2283 private:
2284 NetNet*net_;
2288 * An expression that takes a portion of a signal is represented as
2289 * one of these. For example, ``foo[x+5]'' is a signal and x+5 is an
2290 * expression to select a single bit from that signal. I can't just
2291 * make a new NetESignal node connected to the single net because the
2292 * expression may vary during execution, so the structure is not known
2293 * at compile (elaboration) time.
2295 class NetESubSignal : public NetExpr {
2297 public:
2298 NetESubSignal(NetESignal*sig, NetExpr*ex);
2299 ~NetESubSignal();
2301 const string&name() const { return sig_->name(); }
2302 const NetExpr*index() const { return idx_; }
2304 virtual bool set_width(unsigned);
2306 NetESubSignal* dup_expr() const;
2308 virtual void expr_scan(struct expr_scan_t*) const;
2309 virtual void dump(ostream&) const;
2311 private:
2312 // For now, only support single-bit selects of a signal.
2313 NetESignal*sig_;
2314 NetExpr* idx_;
2319 * This object type is used to contain a logical scope within a
2320 * design. The scope doesn't represent any executable hardware, but is
2321 * just a handle that netlist processors can use to grab at the design.
2323 class NetScope {
2325 public:
2326 enum TYPE { MODULE, TASK, FUNC, BEGIN_END, FORK_JOIN };
2327 NetScope(const string&root);
2328 NetScope(NetScope*up, const string&name, TYPE t);
2329 ~NetScope();
2331 /* Parameters exist within a scope, and these methods allow
2332 one to manipulate the set. In these cases, the name is the
2333 *simple* name of the paramter, the heirarchy is implicit in
2334 the scope. The return value from set_parameter is the
2335 previous expression, if there was one. */
2337 NetExpr* set_parameter(const string&name, NetExpr*val);
2338 NetExpr* set_localparam(const string&name, NetExpr*val);
2339 const NetExpr*get_parameter(const string&name) const;
2341 /* These methods set or access events that live in this
2342 scope. */
2344 void add_event(NetEvent*);
2345 void rem_event(NetEvent*);
2346 NetEvent*find_event(const string&name);
2349 /* These methods manage signals. The add_ and rem_signal
2350 methods are used by the NetNet objects to make themselves
2351 available to the scope, and the find_signal method can be
2352 used to locate signals within a scope. */
2354 void add_signal(NetNet*);
2355 void rem_signal(NetNet*);
2357 NetNet* find_signal(const string&name);
2360 /* ... and these methods manage memory the same way as signals
2361 are managed above. */
2363 void add_memory(NetMemory*);
2364 void rem_memory(NetMemory*);
2366 NetMemory* find_memory(const string&name);
2369 /* The parent and child() methods allow users of NetScope
2370 objects to locate nearby scopes. */
2371 NetScope* parent();
2372 NetScope* child(const string&name);
2373 const NetScope* parent() const;
2374 const NetScope* child(const string&name) const;
2376 TYPE type() const;
2378 /* The name of the scope is the fully qualified hierarchical
2379 name, whereas the basename is just my name within my parent
2380 scope. */
2381 string basename() const;
2382 string name() const;
2384 void run_defparams(class Design*);
2385 void evaluate_parameters(class Design*);
2387 /* This method generates a non-hierarchical name that is
2388 guaranteed to be unique within this scope. */
2389 string local_symbol();
2391 void dump(ostream&) const;
2392 void emit_scope(ostream&o, struct target_t*tgt) const;
2394 /* This method runs the functor on me. Recurse through the
2395 children of this node as well. */
2396 void run_functor(Design*des, functor_t*fun);
2399 /* This member is used during elaboration to pass defparam
2400 assignments from the scope pass to the parameter evaluation
2401 step. After that, it is not used. */
2403 map<string,NetExpr*>defparams;
2405 private:
2406 TYPE type_;
2407 string name_;
2409 map<string,NetExpr*>parameters_;
2410 map<string,NetExpr*>localparams_;
2412 NetEvent *events_;
2413 NetNet *signals_;
2414 NetMemory*memories_;
2416 NetScope*up_;
2417 NetScope*sib_;
2418 NetScope*sub_;
2420 unsigned lcounter_;
2424 * This class contains an entire design. It includes processes and a
2425 * netlist, and can be passed around from function to function.
2427 class Design {
2429 public:
2430 Design();
2431 ~Design();
2434 /* The flags are a generic way of accepting command line
2435 parameters/flags and passing them to the processing steps
2436 that deal with the design. The compilation driver sets the
2437 entire flags map after elaboration is done. Subsequent
2438 steps can then use the get_flag() function to get the value
2439 of an interesting key. */
2441 void set_flags(const map<string,string>&f) { flags_ = f; }
2443 string get_flag(const string&key) const;
2445 NetScope* make_root_scope(const string&name);
2446 NetScope* find_root_scope();
2448 /* look up a scope. If no starting scope is passed, then the
2449 path name string is taken as an absolute scope
2450 name. Otherwise, the scope is located starting at the
2451 passed scope and working up if needed. */
2452 NetScope* find_scope(const string&path) const;
2453 NetScope* find_scope(NetScope*, const string&path) const;
2455 // PARAMETERS
2457 /* This method searches for a parameter, starting in the given
2458 scope. This method handles the upward searches that the
2459 NetScope class itself does not support. */
2460 const NetExpr*find_parameter(const NetScope*, const string&name) const;
2462 void run_defparams();
2463 void evaluate_parameters();
2465 /* This method locates a signal, starting at a given
2466 scope. The name parameter may be partially hierarchical, so
2467 this method, unlike the NetScope::find_signal method,
2468 handles global name binding. */
2470 NetNet*find_signal(NetScope*scope, const string&name);
2472 // Memories
2473 NetMemory* find_memory(NetScope*scope, const string&name);
2475 /* This is a more general lookup that finds the named signal
2476 or memory, whichever is first in the search path. */
2477 void find_symbol(NetScope*,const string&key,
2478 NetNet*&sig, NetMemory*&mem);
2480 // Functions
2481 void add_function(const string&n, NetFuncDef*);
2482 NetFuncDef* find_function(const string&path, const string&key);
2483 NetFuncDef* find_function(const string&path);
2485 // Tasks
2486 void add_task(const string&n, NetTaskDef*);
2487 NetTaskDef* find_task(const string&path, const string&name);
2488 NetTaskDef* find_task(const string&key);
2490 // NODES
2491 void add_node(NetNode*);
2492 void del_node(NetNode*);
2494 // PROCESSES
2495 void add_process(NetProcTop*);
2496 void delete_process(NetProcTop*);
2498 // Iterate over the design...
2499 void dump(ostream&) const;
2500 void functor(struct functor_t*);
2501 bool emit(ostream&, struct target_t*) const;
2503 void clear_node_marks();
2504 NetNode*find_node(bool (*test)(const NetNode*));
2506 // This is incremented by elaboration when an error is
2507 // detected. It prevents code being emitted.
2508 unsigned errors;
2510 public:
2511 string local_symbol(const string&path);
2513 private:
2514 // Keep a tree of scopes. The NetScope class handles the wide
2515 // tree and per-hop searches for me.
2516 NetScope*root_scope_;
2518 // List the function definitions in the design.
2519 map<string,NetFuncDef*> funcs_;
2521 // List the task definitions in the design.
2522 map<string,NetTaskDef*> tasks_;
2524 // List the nodes in the design
2525 NetNode*nodes_;
2527 // List the processes in the design.
2528 NetProcTop*procs_;
2529 NetProcTop*procs_idx_;
2531 map<string,string> flags_;
2533 unsigned lcounter_;
2535 private: // not implemented
2536 Design(const Design&);
2537 Design& operator= (const Design&);
2541 /* =======
2544 inline bool operator == (const Link&l, const Link&r)
2545 { return l.is_equal(r); }
2547 inline bool operator != (const Link&l, const Link&r)
2548 { return ! l.is_equal(r); }
2550 /* Connect the pins of two nodes together. Either may already be
2551 connected to other things, connect is transitive. */
2552 extern void connect(Link&, Link&);
2554 /* Return true if l and r are connected. */
2555 inline bool connected(const Link&l, const Link&r)
2556 { return l.is_linked(r); }
2558 /* Return true if l is fully connected to r. This means, every pin in
2559 l is connected to a pin in r. This is expecially useful for
2560 checking signal vectors. */
2561 extern bool connected(const NetObj&l, const NetObj&r);
2563 /* return the number of links in the ring that are of the specified
2564 type. */
2565 extern unsigned count_inputs(const Link&pin);
2566 extern unsigned count_outputs(const Link&pin);
2567 extern unsigned count_signals(const Link&pin);
2569 /* Find the next link that is an output into the nexus. */
2570 extern Link* find_next_output(Link*lnk);
2572 /* Find the signal connected to the given node pin. There should
2573 always be exactly one signal. The bidx parameter get filled with
2574 the signal index of the Net, in case it is a vector. */
2575 const NetNet* find_link_signal(const NetObj*net, unsigned pin,
2576 unsigned&bidx);
2578 inline ostream& operator << (ostream&o, const NetExpr&exp)
2579 { exp.dump(o); return o; }
2581 extern ostream& operator << (ostream&, NetNet::Type);
2584 * $Log: netlist.h,v $
2585 * Revision 1.139 2000/05/27 19:33:23 steve
2586 * Merge similar probes within a module.
2588 * Revision 1.138 2000/05/11 23:37:27 steve
2589 * Add support for procedural continuous assignment.
2591 * Revision 1.137 2000/05/07 18:20:07 steve
2592 * Import MCD support from Stephen Tell, and add
2593 * system function parameter support to the IVL core.
2595 * Revision 1.136 2000/05/07 04:37:56 steve
2596 * Carry strength values from Verilog source to the
2597 * pform and netlist for gates.
2599 * Change vvm constants to use the driver_t to drive
2600 * a constant value. This works better if there are
2601 * multiple drivers on a signal.
2603 * Revision 1.135 2000/05/04 03:37:58 steve
2604 * Add infrastructure for system functions, move
2605 * $time to that structure and add $random.
2607 * Revision 1.134 2000/05/02 03:13:31 steve
2608 * Move memories to the NetScope object.
2610 * Revision 1.133 2000/05/02 00:58:12 steve
2611 * Move signal tables to the NetScope class.
2613 * Revision 1.132 2000/04/28 18:43:23 steve
2614 * integer division in expressions properly get width.
2616 * Revision 1.131 2000/04/28 16:50:53 steve
2617 * Catch memory word parameters to tasks.
2619 * Revision 1.130 2000/04/23 21:17:31 steve
2620 * Better comments about bufif devices.
2622 * Revision 1.129 2000/04/23 21:15:07 steve
2623 * Emit code for the bufif devices.
2625 * Revision 1.128 2000/04/23 03:45:24 steve
2626 * Add support for the procedural release statement.
2628 * Revision 1.127 2000/04/22 04:20:19 steve
2629 * Add support for force assignment.
2631 * Revision 1.126 2000/04/20 00:28:03 steve
2632 * Catch some simple identity compareoptimizations.
2634 * Revision 1.125 2000/04/18 04:50:20 steve
2635 * Clean up unneeded NetEvent objects.
2637 * Revision 1.124 2000/04/18 01:02:54 steve
2638 * Minor cleanup of NetTaskDef.
2640 * Revision 1.123 2000/04/16 23:32:19 steve
2641 * Synthesis of comparator in expressions.
2643 * Connect the NetEvent and related classes
2644 * together better.
2646 * Revision 1.122 2000/04/15 19:51:30 steve
2647 * fork-join support in vvm.
2649 * Revision 1.121 2000/04/12 20:02:53 steve
2650 * Finally remove the NetNEvent and NetPEvent classes,
2651 * Get synthesis working with the NetEvWait class,
2652 * and get started supporting multiple events in a
2653 * wait in vvm.
2655 * Revision 1.120 2000/04/12 04:23:58 steve
2656 * Named events really should be expressed with PEIdent
2657 * objects in the pform,
2659 * Handle named events within the mix of net events
2660 * and edges. As a unified lot they get caught together.
2661 * wait statements are broken into more complex statements
2662 * that include a conditional.
2664 * Do not generate NetPEvent or NetNEvent objects in
2665 * elaboration. NetEvent, NetEvWait and NetEvProbe
2666 * take over those functions in the netlist.
2668 * Revision 1.119 2000/04/10 05:26:06 steve
2669 * All events now use the NetEvent class.
2671 * Revision 1.118 2000/04/04 03:20:15 steve
2672 * Simulate named event trigger and waits.
2674 * Revision 1.117 2000/04/02 04:26:06 steve
2675 * Remove the useless sref template.
2677 * Revision 1.116 2000/04/01 21:40:22 steve
2678 * Add support for integer division.
2680 * Revision 1.115 2000/03/29 04:37:11 steve
2681 * New and improved combinational primitives.
2683 * Revision 1.114 2000/03/12 17:09:41 steve
2684 * Support localparam.
2686 * Revision 1.113 2000/03/11 03:25:52 steve
2687 * Locate scopes in statements.
2689 * Revision 1.112 2000/03/10 06:20:48 steve
2690 * Handle defparam to partial hierarchical names.
2692 * Revision 1.111 2000/03/08 04:36:54 steve
2693 * Redesign the implementation of scopes and parameters.
2694 * I now generate the scopes and notice the parameters
2695 * in a separate pass over the pform. Once the scopes
2696 * are generated, I can process overrides and evalutate
2697 * paremeters before elaboration begins.
2699 * Revision 1.110 2000/02/23 02:56:55 steve
2700 * Macintosh compilers do not support ident.
2702 * Revision 1.109 2000/02/13 04:35:43 steve
2703 * Include some block matching from Larry.
2705 * Revision 1.108 2000/01/13 03:35:35 steve
2706 * Multiplication all the way to simulation.
2708 * Revision 1.107 2000/01/10 01:35:24 steve
2709 * Elaborate parameters afer binding of overrides.
2711 * Revision 1.106 2000/01/01 06:18:00 steve
2712 * Handle synthesis of concatenation.
2714 * Revision 1.105 1999/12/30 04:19:12 steve
2715 * Propogate constant 0 in low bits of adders.
2717 * Revision 1.104 1999/12/17 06:18:16 steve
2718 * Rewrite the cprop functor to use the functor_t interface.
2720 * Revision 1.103 1999/12/17 03:38:46 steve
2721 * NetConst can now hold wide constants.
2723 #endif