line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Verilog - Verilog Perl Interface |
2
|
|
|
|
|
|
|
# See copyright, etc in below POD section. |
3
|
|
|
|
|
|
|
###################################################################### |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Verilog::Netlist::Interface; |
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
47
|
use Verilog::Netlist; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
201
|
|
8
|
8
|
|
|
8
|
|
2673
|
use Verilog::Netlist::ModPort; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
314
|
|
9
|
8
|
|
|
8
|
|
46
|
use Verilog::Netlist::Net; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
195
|
|
10
|
8
|
|
|
8
|
|
3128
|
use Verilog::Netlist::Pin; |
|
8
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
325
|
|
11
|
8
|
|
|
8
|
|
48
|
use Verilog::Netlist::Subclass; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
272
|
|
12
|
8
|
|
|
8
|
|
38
|
use vars qw($VERSION @ISA); |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
282
|
|
13
|
8
|
|
|
8
|
|
36
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
11994
|
|
14
|
|
|
|
|
|
|
@ISA = qw(Verilog::Netlist::Interface::Struct |
15
|
|
|
|
|
|
|
Verilog::Netlist::Subclass); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$VERSION = '3.480'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
structs('new', |
20
|
|
|
|
|
|
|
'Verilog::Netlist::Interface::Struct' |
21
|
|
|
|
|
|
|
=>[name => '$', #' # Name of the module |
22
|
|
|
|
|
|
|
filename => '$', #' # Filename this came from |
23
|
|
|
|
|
|
|
lineno => '$', #' # Linenumber this came from |
24
|
|
|
|
|
|
|
netlist => '$', #' # Netlist is a member of |
25
|
|
|
|
|
|
|
userdata => '%', # User information |
26
|
|
|
|
|
|
|
attributes => '%', #' # Misc attributes for systemperl or other processors |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
comment => '$', #' # Comment provided by user |
29
|
|
|
|
|
|
|
_cells => '%', # hash of Verilog::Netlist::Cells |
30
|
|
|
|
|
|
|
_modports => '%', # hash of Verilog::Netlist::ModPorts |
31
|
|
|
|
|
|
|
_ports => '%', # hash of Verilog::Netlist::Ports |
32
|
|
|
|
|
|
|
_portsordered=> '@', # list of Verilog::Netlist::Ports as ordered in list of ports |
33
|
|
|
|
|
|
|
_nets => '%', # hash of Verilog::Netlist::Nets |
34
|
|
|
|
|
|
|
_level => '$', # Depth in hierarchy (if calculated) |
35
|
|
|
|
|
|
|
]); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub delete { |
38
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
39
|
0
|
|
|
|
|
0
|
foreach my $oref ($self->nets) { |
40
|
0
|
|
|
|
|
0
|
$oref->delete; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
0
|
foreach my $oref ($self->ports) { |
43
|
0
|
|
|
|
|
0
|
$oref->delete; |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
0
|
foreach my $oref ($self->modports) { |
46
|
0
|
|
|
|
|
0
|
$oref->delete; |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
0
|
foreach my $oref ($self->cells) { |
49
|
0
|
|
|
|
|
0
|
$oref->delete; |
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
0
|
my $h = $self->netlist->{_interfaces}; |
52
|
0
|
|
|
|
|
0
|
delete $h->{$self->name}; |
53
|
0
|
|
|
|
|
0
|
return undef; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
###################################################################### |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
6
|
0
|
|
sub is_top {} # Ignored, for module compatibility |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
0
|
0
|
sub keyword { return 'interface'; } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub logger { |
63
|
0
|
|
|
0
|
1
|
0
|
return $_[0]->netlist->logger; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub find_modport { |
67
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
68
|
0
|
|
|
|
|
0
|
my $search = shift; |
69
|
0
|
|
0
|
|
|
0
|
return $self->_modports->{$search} || $self->_modports->{"\\".$search." "}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
sub find_port { |
72
|
8
|
|
|
8
|
0
|
11
|
my $self = shift; |
73
|
8
|
|
|
|
|
12
|
my $search = shift; |
74
|
8
|
|
66
|
|
|
93
|
return $self->_ports->{$search} || $self->_ports->{"\\".$search." "}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
sub find_port_by_index { |
77
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
78
|
0
|
|
|
|
|
0
|
my $myindex = shift; |
79
|
|
|
|
|
|
|
# @{$self->_portsordered}[$myindex-1] returns the name of |
80
|
|
|
|
|
|
|
# the port in the module at this index. Then, this is |
81
|
|
|
|
|
|
|
# used to find the port reference via the port hash |
82
|
0
|
|
|
|
|
0
|
return $self->_ports->{@{$self->_portsordered}[$myindex-1]}; |
|
0
|
|
|
|
|
0
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
sub find_cell { |
85
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
86
|
2
|
|
|
|
|
3
|
my $search = shift; |
87
|
2
|
|
33
|
|
|
42
|
return $self->_cells->{$search} || $self->_cells->{"\\".$search." "}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
sub find_net { |
90
|
10
|
|
|
10
|
1
|
13
|
my $self = shift; |
91
|
10
|
|
|
|
|
14
|
my $search = shift; |
92
|
10
|
|
100
|
|
|
154
|
my $rtn = $self->_nets->{$search}||""; |
93
|
|
|
|
|
|
|
#print "FINDNET ",$self->name, " SS $search $rtn\n"; |
94
|
10
|
|
66
|
|
|
123
|
return $self->_nets->{$search} || $self->_nets->{"\\".$search." "}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub attrs_sorted { |
98
|
0
|
|
|
0
|
0
|
0
|
return (sort {$a cmp $b} @{$_[0]->attrs}); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
sub cells { |
101
|
21
|
|
|
21
|
0
|
22
|
return (values %{$_[0]->_cells}); |
|
21
|
|
|
|
|
227
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
sub cells_sorted { |
104
|
6
|
|
|
6
|
0
|
6
|
return (sort {$a->name() cmp $b->name()} (values %{$_[0]->_cells})); |
|
0
|
|
|
|
|
0
|
|
|
6
|
|
|
|
|
72
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
sub modports { |
107
|
18
|
|
|
18
|
1
|
19
|
return (values %{$_[0]->_modports}); |
|
18
|
|
|
|
|
192
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
sub modports_sorted { |
110
|
6
|
|
|
6
|
1
|
7
|
return (sort {$a->name() cmp $b->name()} (values %{$_[0]->_modports})); |
|
0
|
|
|
|
|
0
|
|
|
6
|
|
|
|
|
82
|
|
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
sub nets { |
113
|
18
|
|
|
18
|
1
|
20
|
return (values %{$_[0]->_nets}); |
|
18
|
|
|
|
|
194
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
sub nets_sorted { |
116
|
6
|
|
|
6
|
1
|
6
|
return (sort {$a->name() cmp $b->name()} (values %{$_[0]->_nets})); |
|
0
|
|
|
|
|
0
|
|
|
6
|
|
|
|
|
71
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
sub ports { |
119
|
18
|
|
|
18
|
1
|
19
|
return (values %{$_[0]->_ports}); |
|
18
|
|
|
|
|
206
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
sub ports_sorted { |
122
|
6
|
|
|
6
|
1
|
7
|
return (sort {$a->name() cmp $b->name()} (values %{$_[0]->_ports})); |
|
0
|
|
|
|
|
0
|
|
|
6
|
|
|
|
|
83
|
|
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
sub ports_ordered { |
125
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
126
|
0
|
|
|
|
|
0
|
return map {$self->_ports->{$_}} @{$self->_portsordered}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub nets_and_ports_sorted { |
130
|
0
|
|
|
0
|
1
|
0
|
return Verilog::Netlist::Module::nets_and_ports_sorted(@_); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub new_net { |
134
|
6
|
|
|
6
|
1
|
12
|
my $self = shift; |
135
|
|
|
|
|
|
|
# @_ params |
136
|
|
|
|
|
|
|
# Create a new net under this |
137
|
6
|
|
|
|
|
23
|
my $netref = new Verilog::Netlist::Net(direction=>'net', data_type=>'wire', |
138
|
|
|
|
|
|
|
@_, |
139
|
|
|
|
|
|
|
module=>$self, ); |
140
|
6
|
|
|
|
|
71
|
$self->_nets($netref->name(), $netref); |
141
|
6
|
|
|
|
|
14
|
return $netref; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub new_attr { |
145
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
146
|
0
|
|
|
|
|
0
|
my $clean_text = shift; |
147
|
0
|
|
|
|
|
0
|
push @{$self->attrs}, $clean_text; |
|
0
|
|
|
|
|
0
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub new_modport { |
151
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
152
|
|
|
|
|
|
|
# @_ params |
153
|
2
|
|
|
|
|
86
|
my $oref = new Verilog::Netlist::ModPort(@_, module=>$self,); |
154
|
2
|
|
|
|
|
42
|
$self->_modports($oref->name(), $oref); |
155
|
2
|
|
|
|
|
6
|
return $oref; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub new_port { |
159
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
160
|
|
|
|
|
|
|
# @_ params |
161
|
|
|
|
|
|
|
# Create a new port under this module |
162
|
2
|
|
|
|
|
12
|
my $portref = new Verilog::Netlist::Port(@_, module=>$self,); |
163
|
2
|
|
|
|
|
26
|
$self->_ports($portref->name(), $portref); |
164
|
2
|
|
|
|
|
32
|
return $portref; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub new_cell { |
168
|
2
|
|
|
2
|
0
|
11
|
return Verilog::Netlist::Module::new_cell(@_); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub level { |
172
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
173
|
3
|
|
|
|
|
40
|
my $level = $self->_level; |
174
|
3
|
50
|
|
|
|
6
|
return $level if defined $level; |
175
|
3
|
|
|
|
|
33
|
$self->_level(2); # Interfaces are never up "top" |
176
|
3
|
|
|
|
|
8
|
foreach my $cell ($self->cells) { |
177
|
1
|
50
|
|
|
|
13
|
if ($cell->submod) { |
178
|
1
|
|
|
|
|
14
|
my $celllevel = $cell->submod->level; |
179
|
1
|
50
|
|
|
|
14
|
$self->_level($celllevel+1) if $celllevel >= $self->_level; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
} |
182
|
3
|
|
|
|
|
32
|
return $self->_level; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub link { |
186
|
18
|
|
|
18
|
1
|
21
|
my $self = shift; |
187
|
|
|
|
|
|
|
# Ports create nets, so link ports before nets |
188
|
18
|
|
|
|
|
32
|
foreach my $portref ($self->ports) { |
189
|
6
|
|
|
|
|
17
|
$portref->_link(); |
190
|
|
|
|
|
|
|
} |
191
|
18
|
|
|
|
|
35
|
foreach my $netref ($self->nets) { |
192
|
18
|
|
|
|
|
40
|
$netref->_link(); |
193
|
|
|
|
|
|
|
} |
194
|
18
|
|
|
|
|
32
|
foreach my $oref ($self->modports) { |
195
|
6
|
|
|
|
|
22
|
$oref->_link(); |
196
|
|
|
|
|
|
|
} |
197
|
18
|
|
|
|
|
39
|
foreach my $cellref ($self->cells) { |
198
|
6
|
|
|
|
|
16
|
$cellref->_link(); |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub lint { |
203
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
204
|
0
|
0
|
|
|
|
0
|
if ($self->netlist->{use_vars}) { |
205
|
0
|
|
|
|
|
0
|
foreach my $portref ($self->ports) { |
206
|
0
|
|
|
|
|
0
|
$portref->lint(); |
207
|
|
|
|
|
|
|
} |
208
|
0
|
|
|
|
|
0
|
foreach my $netref ($self->nets) { |
209
|
0
|
|
|
|
|
0
|
$netref->lint(); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
} |
212
|
0
|
|
|
|
|
0
|
foreach my $cellref ($self->cells) { |
213
|
0
|
|
|
|
|
0
|
$cellref->lint(); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub verilog_text { |
218
|
3
|
|
|
3
|
1
|
4
|
my $self = shift; |
219
|
3
|
|
|
|
|
34
|
my @out = "interface ".$self->name." (\n"; |
220
|
3
|
|
|
|
|
4
|
my $indent = " "; |
221
|
|
|
|
|
|
|
# Port list |
222
|
3
|
|
|
|
|
4
|
my $comma=""; |
223
|
3
|
|
|
|
|
6
|
push @out, $indent; |
224
|
3
|
|
|
|
|
6
|
foreach my $portref ($self->ports_sorted) { |
225
|
1
|
|
|
|
|
4
|
push @out, $comma, $portref->verilog_text; |
226
|
1
|
|
|
|
|
2
|
$comma = ", "; |
227
|
|
|
|
|
|
|
} |
228
|
3
|
|
|
|
|
5
|
push @out, ");\n"; |
229
|
|
|
|
|
|
|
|
230
|
3
|
|
|
|
|
7
|
foreach my $netref ($self->nets_sorted) { |
231
|
3
|
|
|
|
|
8
|
push @out, $indent, $netref->verilog_text, "\n"; |
232
|
|
|
|
|
|
|
} |
233
|
3
|
|
|
|
|
7
|
foreach my $oref ($self->modports_sorted) { |
234
|
1
|
|
|
|
|
6
|
push @out, $indent, $oref->verilog_text, "\n"; |
235
|
|
|
|
|
|
|
} |
236
|
3
|
|
|
|
|
11
|
foreach my $cellref ($self->cells_sorted) { |
237
|
1
|
|
|
|
|
3
|
push @out, $indent, $cellref->verilog_text, "\n"; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
3
|
|
|
|
|
7
|
push @out, "endinterface\n"; |
241
|
3
|
50
|
|
|
|
18
|
return (wantarray ? @out : join('',@out)); |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub dump { |
245
|
6
|
|
|
6
|
1
|
9
|
my $self = shift; |
246
|
6
|
|
100
|
|
|
14
|
my $indent = shift||0; |
247
|
6
|
|
|
|
|
15
|
my $norecurse = shift; |
248
|
6
|
|
|
|
|
78
|
print " "x$indent,"Interface:",$self->name()," File:",$self->filename(),"\n"; |
249
|
6
|
100
|
|
|
|
36
|
if (!$norecurse) { |
250
|
3
|
|
|
|
|
11
|
foreach my $portref ($self->ports_sorted) { |
251
|
1
|
|
|
|
|
4
|
$portref->dump($indent+2); |
252
|
|
|
|
|
|
|
} |
253
|
3
|
|
|
|
|
11
|
foreach my $netref ($self->nets_sorted) { |
254
|
3
|
|
|
|
|
11
|
$netref->dump($indent+2); |
255
|
|
|
|
|
|
|
} |
256
|
3
|
|
|
|
|
11
|
foreach my $oref ($self->modports_sorted) { |
257
|
1
|
|
|
|
|
6
|
$oref->dump($indent+2); |
258
|
|
|
|
|
|
|
} |
259
|
3
|
|
|
|
|
9
|
foreach my $cellref ($self->cells_sorted) { |
260
|
1
|
|
|
|
|
5
|
$cellref->dump($indent+2); |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
###################################################################### |
266
|
|
|
|
|
|
|
#### Package return |
267
|
|
|
|
|
|
|
1; |
268
|
|
|
|
|
|
|
__END__ |