forked from steveicarus/iverilog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PWire.h
144 lines (115 loc) · 4.41 KB
/
PWire.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#ifndef IVL_PWire_H
#define IVL_PWire_H
/*
* Copyright (c) 1998-2021 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "netlist.h"
# include "PNamedItem.h"
# include <list>
# include <map>
# include "StringHeap.h"
#ifdef HAVE_IOSFWD
# include <iosfwd>
#else
# include <iostream>
#endif
class PExpr;
class Design;
class netdarray_t;
/*
* The different type of PWire::set_range() calls.
*/
enum PWSRType {SR_PORT, SR_NET, SR_BOTH};
/*
* Wires include nets, registers and ports. A net or register becomes
* a port by declaration, so ports are not separate. The module
* identifies a port by keeping it in its port list.
*
* The hname parameter to the constructor is a hierarchical name. It
* is the name of the wire within a module, so does not include the
* current scope or any instances. Modules contain all the wires, so
* from that perspective, sub-scopes within the module are a part of
* the wire name.
*/
class PWire : public PNamedItem {
public:
PWire(perm_string name,
NetNet::Type t,
NetNet::PortType pt,
PWSRType rt = SR_NET);
// Return a hierarchical name.
perm_string basename() const;
NetNet::Type get_wire_type() const;
bool set_wire_type(NetNet::Type);
NetNet::PortType get_port_type() const;
bool set_port_type(NetNet::PortType);
void set_const(bool is_const) { is_const_ = is_const; };
bool get_const() const { return is_const_; };
void set_signed(bool flag);
bool get_signed() const;
void set_range(const std::list<pform_range_t>&ranges, PWSRType type);
void set_unpacked_idx(const std::list<pform_range_t>&ranges);
void set_data_type(data_type_t*type);
void set_discipline(ivl_discipline_t);
ivl_discipline_t get_discipline(void) const;
std::map<perm_string,PExpr*> attributes;
// Write myself to the specified stream.
void dump(std::ostream&out, unsigned ind=4) const;
NetNet* elaborate_sig(Design*, NetScope*scope) const;
SymbolType symbol_type() const;
bool is_net() const { return net_set_; };
bool is_port() const { return port_set_; };
void set_net(NetNet::Type t);
void set_port(NetNet::PortType pt);
private:
perm_string name_;
NetNet::Type type_;
NetNet::PortType port_type_;
bool signed_;
// Whether the wire is variable declared with the const keyword.
bool is_const_ = false;
// These members hold expressions for the bit width of the
// wire. If they do not exist, the wire is 1 bit wide. If they
// do exist, they represent the packed dimensions of the
// bit. The first item in the list is the first range, and so
// on. For example "reg [3:0][7:0] ..." will contains the
// range_t object for [3:0] first and [7:0] last.
std::list<pform_range_t>port_;
bool port_set_;
std::list<pform_range_t>net_;
bool net_set_;
bool is_scalar_;
unsigned error_cnt_;
// If this wire is actually a memory, these indices will give
// me the size and address ranges of the memory.
std::list<pform_range_t>unpacked_;
// This is the complex type of the wire. the data_type_ may
// modify how this is interpreted.
std::unique_ptr<data_type_t> set_data_type_;
ivl_discipline_t discipline_;
private: // not implemented
PWire(const PWire&);
PWire& operator= (const PWire&);
ivl_type_t elaborate_type(Design*des, NetScope*scope,
const netranges_t &packed_dimensions) const;
ivl_type_t elaborate_darray_type(Design*des, NetScope*scope,
const char *darray_type,
const netranges_t &packed_dimensions)
const;
};
#endif /* IVL_PWire_H */