Logic gates can take part select inputs
[iverilog.git] / net_proc.cc
blob90592d9749faf757cb6e910f7b0c462fbf3e90b0
1 /*
2 * Copyright (c) 2000-2002 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: net_proc.cc,v 1.7 2006/08/08 05:11:37 steve Exp $"
21 #endif
23 # include "config.h"
25 # include "netlist.h"
26 # include <assert.h>
28 NetBlock::NetBlock(Type t, NetScope*ss)
29 : type_(t), subscope_(ss), last_(0)
33 NetBlock::~NetBlock()
35 while (last_ != 0) {
36 if (last_->next_ == last_) {
37 delete last_;
38 last_ = 0;
39 } else {
40 NetProc*cur = last_->next_;
41 last_->next_ = cur->next_;
42 cur->next_ = cur;
43 delete cur;
48 void NetBlock::append(NetProc*cur)
50 if (last_ == 0) {
51 last_ = cur;
52 cur->next_ = cur;
53 } else {
54 cur->next_ = last_->next_;
55 last_->next_ = cur;
56 last_ = cur;
60 const NetProc* NetBlock::proc_first() const
62 if (last_ == 0)
63 return 0;
65 return last_->next_;
68 const NetProc* NetBlock::proc_next(const NetProc*cur) const
70 if (cur == last_)
71 return 0;
73 return cur->next_;
76 NetCase::NetCase(NetCase::TYPE c, NetExpr*ex, unsigned cnt)
77 : type_(c), expr_(ex), nitems_(cnt)
79 assert(expr_);
80 items_ = new Item[nitems_];
81 for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) {
82 items_[idx].statement = 0;
86 NetCase::~NetCase()
88 delete expr_;
89 for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) {
90 delete items_[idx].guard;
91 if (items_[idx].statement) delete items_[idx].statement;
93 delete[]items_;
96 NetCase::TYPE NetCase::type() const
98 return type_;
101 void NetCase::set_case(unsigned idx, NetExpr*e, NetProc*p)
103 assert(idx < nitems_);
104 items_[idx].guard = e;
105 items_[idx].statement = p;
106 if (items_[idx].guard)
107 items_[idx].guard->set_width(expr_->expr_width());
110 NetDisable::NetDisable(NetScope*tgt)
111 : target_(tgt)
115 NetDisable::~NetDisable()
119 const NetScope* NetDisable::target() const
121 return target_;
124 NetForever::NetForever(NetProc*p)
125 : statement_(p)
129 NetForever::~NetForever()
131 delete statement_;
134 NetPDelay::NetPDelay(uint64_t d, NetProc*st)
135 : delay_(d), expr_(0), statement_(st)
139 NetPDelay::NetPDelay(NetExpr*d, NetProc*st)
140 : delay_(0), expr_(d), statement_(st)
144 NetPDelay::~NetPDelay()
146 if (expr_) delete expr_;
149 uint64_t NetPDelay::delay() const
151 assert(expr_ == 0);
152 return delay_;
155 const NetExpr* NetPDelay::expr() const
157 return expr_;
160 NetRepeat::NetRepeat(NetExpr*e, NetProc*p)
161 : expr_(e), statement_(p)
165 NetRepeat::~NetRepeat()
167 delete expr_;
168 delete statement_;
171 const NetExpr* NetRepeat::expr() const
173 return expr_;
179 * $Log: net_proc.cc,v $
180 * Revision 1.7 2006/08/08 05:11:37 steve
181 * Handle 64bit delay constants.
183 * Revision 1.6 2002/08/12 01:34:59 steve
184 * conditional ident string using autoconfig.
186 * Revision 1.5 2002/07/28 23:58:45 steve
187 * Fix NetBlock destructor to delete substatements.
189 * Revision 1.4 2002/04/21 04:59:08 steve
190 * Add support for conbinational events by finding
191 * the inputs to expressions and some statements.
192 * Get case and assignment statements working.
194 * Revision 1.3 2001/07/25 03:10:49 steve
195 * Create a config.h.in file to hold all the config
196 * junk, and support gcc 3.0. (Stephan Boettcher)
198 * Revision 1.2 2000/07/27 05:13:44 steve
199 * Support elaboration of disable statements.
201 * Revision 1.1 2000/07/07 04:53:54 steve
202 * Add support for non-constant delays in delay statements,
203 * Support evaluating ! in constant expressions, and
204 * move some code from netlist.cc to net_proc.cc.