2 * Copyright (c) 1999-2007 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 #ident "$Id: PWire.cc,v 1.14 2007/05/24 04:07:11 steve Exp $"
28 PWire::PWire(const pform_name_t
&n
,
31 ivl_variable_type_t dt
)
32 : hname_(n
), type_(t
), port_type_(pt
), data_type_(dt
),
33 signed_(false), isint_(false), port_set_(false), net_set_(false),
34 port_msb_(0), port_lsb_(0), net_msb_(0), net_lsb_(0), error_cnt_(0),
37 if (t
== NetNet::INTEGER
) {
44 NetNet::Type
PWire::get_wire_type() const
49 const pform_name_t
& PWire::path() const
54 bool PWire::set_wire_type(NetNet::Type t
)
56 assert(t
!= NetNet::IMPLICIT
);
59 case NetNet::IMPLICIT
:
62 case NetNet::IMPLICIT_REG
:
63 if (t
== NetNet::REG
) { type_
= t
; return true; }
66 if (t
== NetNet::INTEGER
) {
70 if (t
== NetNet::REG
) return true;
80 NetNet::PortType
PWire::get_port_type() const
85 bool PWire::set_port_type(NetNet::PortType pt
)
87 assert(pt
!= NetNet::NOT_A_PORT
);
88 assert(pt
!= NetNet::PIMPLICIT
);
91 case NetNet::PIMPLICIT
:
95 case NetNet::NOT_A_PORT
:
106 bool PWire::set_data_type(ivl_variable_type_t dt
)
108 if (data_type_
!= IVL_VT_NO_TYPE
)
109 if (data_type_
!= dt
)
114 assert(data_type_
== IVL_VT_NO_TYPE
);
119 void PWire::set_signed(bool flag
)
124 bool PWire::get_signed() const
129 bool PWire::get_isint() const
135 * Since implicitly defined list of port declarations are no longer
136 * considered fully defined we no longer need this routine to force
137 * them to be fully defined.
139 void PWire::set_net_range()
141 net_msb_ = port_msb_;
142 net_lsb_ = port_lsb_;
147 void PWire::set_range(PExpr
*m
, PExpr
*l
, PWSRType type
)
152 cerr
<< get_line() << ": error: Port ``" << hname_
153 << "'' has already been declared a port." << endl
;
164 cerr
<< get_line() << ": error: Net ``" << hname_
165 << "'' has already been declared." << endl
;
175 if (port_set_
|| net_set_
) {
177 cerr
<< get_line() << ": error: Port ``" << hname_
178 << "'' has already been declared a port." << endl
;
182 cerr
<< get_line() << ": error: Net ``" << hname_
183 << "'' has already been declared." << endl
;
198 void PWire::set_memory_idx(PExpr
*ldx
, PExpr
*rdx
)
200 if (lidx_
!= 0 || ridx_
!= 0) {
201 cerr
<< get_line() << ": error: Array ``" << hname_
202 << "'' has already been declared." << endl
;