2 * Copyright (c) 1998-2008 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
27 /* n is a permallocated string. */
28 Module::Module(perm_string n
)
32 default_nettype
= NetNet::NONE
;
39 void Module::add_gate(PGate
*gate
)
41 gates_
.push_back(gate
);
44 void Module::add_task(perm_string name
, PTask
*task
)
49 void Module::add_function(perm_string name
, PFunction
*func
)
54 unsigned Module::port_count() const
60 * Return the array of PEIdent object that are at this port of the
61 * module. If the port is internally unconnected, return an empty
64 const svector
<PEIdent
*>& Module::get_port(unsigned idx
) const
66 assert(idx
< ports
.count());
67 static svector
<PEIdent
*> zero
;
70 return ports
[idx
]->expr
;
75 unsigned Module::find_port(const char*name
) const
78 for (unsigned idx
= 0 ; idx
< ports
.count() ; idx
+= 1) {
79 if (ports
[idx
] == 0) {
80 /* It is possible to have undeclared ports. These
81 are ports that are skipped in the declaration,
82 for example like so: module foo(x ,, y); The
83 port between x and y is unnamed and thus
84 inaccessible to binding by name. */
88 if (ports
[idx
]->name
== name
)
96 PGate
* Module::get_gate(perm_string name
)
98 for (list
<PGate
*>::iterator cur
= gates_
.begin()
102 if ((*cur
)->get_name() == name
)
109 const list
<PGate
*>& Module::get_gates() const