Reformulate number-to-real on vvp code generator
[iverilog.git] / PWire.h
blob3cf02908d37e287e518a3e33907a0534c1be9c93
1 #ifndef __PWire_H
2 #define __PWire_H
3 /*
4 * Copyright (c) 1998-2007 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 #ifdef HAVE_CVS_IDENT
22 #ident "$Id: PWire.h,v 1.21 2007/05/24 04:07:11 steve Exp $"
23 #endif
25 # include "netlist.h"
26 # include "LineInfo.h"
27 # include <map>
28 # include "svector.h"
29 # include "StringHeap.h"
31 #ifdef HAVE_IOSFWD
32 # include <iosfwd>
33 #else
34 class ostream;
35 #endif
37 class PExpr;
38 class Design;
41 * The different type of PWire::set_range() calls.
43 enum PWSRType {SR_PORT, SR_NET, SR_BOTH};
46 * Wires include nets, registers and ports. A net or register becomes
47 * a port by declaration, so ports are not separate. The module
48 * identifies a port by keeping it in its port list.
50 * The hname parameter to the constructor is a hierarchical name. It
51 * is the name of the wire within a module, so does not include the
52 * current scope or any instances. Modules contain all the wires, so
53 * from that perspective, sub-scopes within the module are a part of
54 * the wire name.
56 class PWire : public LineInfo {
58 public:
59 PWire(const pform_name_t&hname,
60 NetNet::Type t,
61 NetNet::PortType pt,
62 ivl_variable_type_t dt);
64 // Return a hierarchical name.
65 const pform_name_t&path() const;
67 NetNet::Type get_wire_type() const;
68 bool set_wire_type(NetNet::Type);
70 NetNet::PortType get_port_type() const;
71 bool set_port_type(NetNet::PortType);
73 void set_signed(bool flag);
74 bool get_signed() const;
75 bool get_isint() const;
77 bool set_data_type(ivl_variable_type_t dt);
78 ivl_variable_type_t get_data_type() const;
80 void set_range(PExpr*msb, PExpr*lsb, PWSRType type);
81 void set_net_range();
83 void set_memory_idx(PExpr*ldx, PExpr*rdx);
85 map<perm_string,PExpr*> attributes;
87 // Write myself to the specified stream.
88 void dump(ostream&out, unsigned ind=4) const;
90 NetNet* elaborate_sig(Design*, NetScope*scope) const;
92 private:
93 pform_name_t hname_;
94 NetNet::Type type_;
95 NetNet::PortType port_type_;
96 ivl_variable_type_t data_type_;
97 bool signed_;
98 bool isint_; // original type of integer
100 // These members hold expressions for the bit width of the
101 // wire. If they do not exist, the wire is 1 bit wide.
102 PExpr*port_msb_;
103 PExpr*port_lsb_;
104 bool port_set_;
105 PExpr*net_msb_;
106 PExpr*net_lsb_;
107 bool net_set_;
108 unsigned error_cnt_;
110 // If this wire is actually a memory, these indices will give
111 // me the size and address range of the memory.
112 PExpr*lidx_;
113 PExpr*ridx_;
115 private: // not implemented
116 PWire(const PWire&);
117 PWire& operator= (const PWire&);
120 #endif