Remove restriction on size of constants
[iverilog.git] / PWire.cc
bloba81b89e6847f7ad72d969bb3c600d9a896245c49
1 /*
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)
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: PWire.cc,v 1.14 2007/05/24 04:07:11 steve Exp $"
21 #endif
23 # include "config.h"
24 # include "PWire.h"
25 # include <assert.h>
27 PWire::PWire(const pform_name_t&n,
28 NetNet::Type t,
29 NetNet::PortType pt,
30 ivl_variable_type_t dt)
31 : hname_(n), type_(t), port_type_(pt), data_type_(dt),
32 signed_(false), isint_(false),
33 lidx_(0), ridx_(0)
35 if (t == NetNet::INTEGER) {
36 type_ = NetNet::REG;
37 signed_ = true;
38 isint_ = true;
42 NetNet::Type PWire::get_wire_type() const
44 return type_;
47 const pform_name_t& PWire::path() const
49 return hname_;
52 bool PWire::set_wire_type(NetNet::Type t)
54 assert(t != NetNet::IMPLICIT);
56 switch (type_) {
57 case NetNet::IMPLICIT:
58 type_ = t;
59 return true;
60 case NetNet::IMPLICIT_REG:
61 if (t == NetNet::REG) { type_ = t; return true; }
62 return false;
63 case NetNet::REG:
64 if (t == NetNet::INTEGER) {
65 isint_ = true;
66 return true;
68 if (t == NetNet::REG) return true;
69 return false;
70 default:
71 if (type_ != t)
72 return false;
73 else
74 return true;
78 NetNet::PortType PWire::get_port_type() const
80 return port_type_;
83 bool PWire::set_port_type(NetNet::PortType pt)
85 assert(pt != NetNet::NOT_A_PORT);
86 assert(pt != NetNet::PIMPLICIT);
88 switch (port_type_) {
89 case NetNet::PIMPLICIT:
90 port_type_ = pt;
91 return true;
93 case NetNet::NOT_A_PORT:
94 return false;
96 default:
97 if (port_type_ != pt)
98 return false;
99 else
100 return true;
104 bool PWire::set_data_type(ivl_variable_type_t dt)
106 if (data_type_ != IVL_VT_NO_TYPE)
107 if (data_type_ != dt)
108 return false;
109 else
110 return true;
112 assert(data_type_ == IVL_VT_NO_TYPE);
113 data_type_ = dt;
114 return true;
117 void PWire::set_signed(bool flag)
119 signed_ = flag;
122 bool PWire::get_signed() const
124 return signed_;
127 bool PWire::get_isint() const
129 return isint_;
132 void PWire::set_range(PExpr*m, PExpr*l)
134 msb_ = svector<PExpr*>(msb_,m);
135 lsb_ = svector<PExpr*>(lsb_,l);
138 void PWire::set_memory_idx(PExpr*ldx, PExpr*rdx)
140 assert(lidx_ == 0);
141 assert(ridx_ == 0);
142 lidx_ = ldx;
143 ridx_ = rdx;
147 * $Log: PWire.cc,v $
148 * Revision 1.14 2007/05/24 04:07:11 steve
149 * Rework the heirarchical identifier parse syntax and pform
150 * to handle more general combinations of heirarch and bit selects.
152 * Revision 1.13 2007/04/26 03:06:21 steve
153 * Rework hname_t to use perm_strings.
155 * Revision 1.12 2007/01/16 05:44:14 steve
156 * Major rework of array handling. Memories are replaced with the
157 * more general concept of arrays. The NetMemory and NetEMemory
158 * classes are removed from the ivl core program, and the IVL_LPM_RAM
159 * lpm type is removed from the ivl_target API.
161 * Revision 1.11 2005/07/07 16:22:49 steve
162 * Generalize signals to carry types.
164 * Revision 1.10 2002/08/12 01:34:58 steve
165 * conditional ident string using autoconfig.
167 * Revision 1.9 2002/06/21 04:59:35 steve
168 * Carry integerness throughout the compilation.
170 * Revision 1.8 2002/01/26 05:28:28 steve
171 * Detect scalar/vector declarion mismatch.
173 * Revision 1.7 2001/12/03 04:47:14 steve
174 * Parser and pform use hierarchical names as hname_t
175 * objects instead of encoded strings.
177 * Revision 1.6 2001/07/25 03:10:48 steve
178 * Create a config.h.in file to hold all the config
179 * junk, and support gcc 3.0. (Stephan Boettcher)
181 * Revision 1.5 2001/01/06 02:29:35 steve
182 * Support arrays of integers.
184 * Revision 1.4 2000/12/11 00:31:43 steve
185 * Add support for signed reg variables,
186 * simulate in t-vvm signed comparisons.
188 * Revision 1.3 2000/02/23 02:56:54 steve
189 * Macintosh compilers do not support ident.
191 * Revision 1.2 1999/09/10 05:02:09 steve
192 * Handle integers at task parameters.
194 * Revision 1.1 1999/06/17 05:34:42 steve
195 * Clean up interface of the PWire class,
196 * Properly match wire ranges.