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
|
|
58
|
use Verilog::Netlist; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
239
|
|
8
|
8
|
|
|
8
|
|
3257
|
use Verilog::Netlist::ModPort; |
|
8
|
|
|
|
|
24
|
|
|
8
|
|
|
|
|
390
|
|
9
|
8
|
|
|
8
|
|
58
|
use Verilog::Netlist::Net; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
229
|
|
10
|
8
|
|
|
8
|
|
3911
|
use Verilog::Netlist::Pin; |
|
8
|
|
|
|
|
30
|
|
|
8
|
|
|
|
|
392
|
|
11
|
8
|
|
|
8
|
|
57
|
use Verilog::Netlist::Subclass; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
384
|
|
12
|
8
|
|
|
8
|
|
50
|
use vars qw($VERSION @ISA); |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
391
|
|
13
|
8
|
|
|
8
|
|
43
|
use strict; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
14270
|
|
14
|
|
|
|
|
|
|
@ISA = qw(Verilog::Netlist::Interface::Struct |
15
|
|
|
|
|
|
|
Verilog::Netlist::Subclass); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$VERSION = '3.476'; |
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
|
|
|
|
|
14
|
my $search = shift; |
74
|
8
|
|
66
|
|
|
99
|
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
|
|
|
|
|
4
|
my $search = shift; |
87
|
2
|
|
33
|
|
|
48
|
return $self->_cells->{$search} || $self->_cells->{"\\".$search." "}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
sub find_net { |
90
|
10
|
|
|
10
|
1
|
16
|
my $self = shift; |
91
|
10
|
|
|
|
|
15
|
my $search = shift; |
92
|
10
|
|
100
|
|
|
184
|
my $rtn = $self->_nets->{$search}||""; |
93
|
|
|
|
|
|
|
#print "FINDNET ",$self->name, " SS $search $rtn\n"; |
94
|
10
|
|
66
|
|
|
132
|
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
|
27
|
return (values %{$_[0]->_cells}); |
|
21
|
|
|
|
|
249
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
sub cells_sorted { |
104
|
6
|
|
|
6
|
0
|
7
|
return (sort {$a->name() cmp $b->name()} (values %{$_[0]->_cells})); |
|
0
|
|
|
|
|
0
|
|
|
6
|
|
|
|
|
86
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
sub modports { |
107
|
18
|
|
|
18
|
1
|
23
|
return (values %{$_[0]->_modports}); |
|
18
|
|
|
|
|
214
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
sub modports_sorted { |
110
|
6
|
|
|
6
|
1
|
8
|
return (sort {$a->name() cmp $b->name()} (values %{$_[0]->_modports})); |
|
0
|
|
|
|
|
0
|
|
|
6
|
|
|
|
|
95
|
|
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
sub nets { |
113
|
18
|
|
|
18
|
1
|
26
|
return (values %{$_[0]->_nets}); |
|
18
|
|
|
|
|
210
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
sub nets_sorted { |
116
|
6
|
|
|
6
|
1
|
10
|
return (sort {$a->name() cmp $b->name()} (values %{$_[0]->_nets})); |
|
0
|
|
|
|
|
0
|
|
|
6
|
|
|
|
|
84
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
sub ports { |
119
|
18
|
|
|
18
|
1
|
22
|
return (values %{$_[0]->_ports}); |
|
18
|
|
|
|
|
229
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
sub ports_sorted { |
122
|
6
|
|
|
6
|
1
|
7
|
return (sort {$a->name() cmp $b->name()} (values %{$_[0]->_ports})); |
|
0
|
|
|
|
|
0
|
|
|
6
|
|
|
|
|
100
|
|
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
|
14
|
my $self = shift; |
135
|
|
|
|
|
|
|
# @_ params |
136
|
|
|
|
|
|
|
# Create a new net under this |
137
|
6
|
|
|
|
|
34
|
my $netref = new Verilog::Netlist::Net(direction=>'net', data_type=>'wire', |
138
|
|
|
|
|
|
|
@_, |
139
|
|
|
|
|
|
|
module=>$self, ); |
140
|
6
|
|
|
|
|
77
|
$self->_nets($netref->name(), $netref); |
141
|
6
|
|
|
|
|
13
|
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
|
4
|
my $self = shift; |
152
|
|
|
|
|
|
|
# @_ params |
153
|
2
|
|
|
|
|
51
|
my $oref = new Verilog::Netlist::ModPort(@_, module=>$self,); |
154
|
2
|
|
|
|
|
35
|
$self->_modports($oref->name(), $oref); |
155
|
2
|
|
|
|
|
7
|
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
|
|
|
|
|
16
|
my $portref = new Verilog::Netlist::Port(@_, module=>$self,); |
163
|
2
|
|
|
|
|
29
|
$self->_ports($portref->name(), $portref); |
164
|
2
|
|
|
|
|
38
|
return $portref; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub new_cell { |
168
|
2
|
|
|
2
|
0
|
15
|
return Verilog::Netlist::Module::new_cell(@_); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub level { |
172
|
3
|
|
|
3
|
1
|
4
|
my $self = shift; |
173
|
3
|
|
|
|
|
44
|
my $level = $self->_level; |
174
|
3
|
50
|
|
|
|
8
|
return $level if defined $level; |
175
|
3
|
|
|
|
|
32
|
$self->_level(2); # Interfaces are never up "top" |
176
|
3
|
|
|
|
|
8
|
foreach my $cell ($self->cells) { |
177
|
1
|
50
|
|
|
|
11
|
if ($cell->submod) { |
178
|
1
|
|
|
|
|
13
|
my $celllevel = $cell->submod->level; |
179
|
1
|
50
|
|
|
|
13
|
$self->_level($celllevel+1) if $celllevel >= $self->_level; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
} |
182
|
3
|
|
|
|
|
35
|
return $self->_level; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub link { |
186
|
18
|
|
|
18
|
1
|
27
|
my $self = shift; |
187
|
|
|
|
|
|
|
# Ports create nets, so link ports before nets |
188
|
18
|
|
|
|
|
38
|
foreach my $portref ($self->ports) { |
189
|
6
|
|
|
|
|
22
|
$portref->_link(); |
190
|
|
|
|
|
|
|
} |
191
|
18
|
|
|
|
|
46
|
foreach my $netref ($self->nets) { |
192
|
18
|
|
|
|
|
46
|
$netref->_link(); |
193
|
|
|
|
|
|
|
} |
194
|
18
|
|
|
|
|
38
|
foreach my $oref ($self->modports) { |
195
|
6
|
|
|
|
|
27
|
$oref->_link(); |
196
|
|
|
|
|
|
|
} |
197
|
18
|
|
|
|
|
54
|
foreach my $cellref ($self->cells) { |
198
|
6
|
|
|
|
|
21
|
$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
|
6
|
my $self = shift; |
219
|
3
|
|
|
|
|
95
|
my @out = "interface ".$self->name." (\n"; |
220
|
3
|
|
|
|
|
6
|
my $indent = " "; |
221
|
|
|
|
|
|
|
# Port list |
222
|
3
|
|
|
|
|
5
|
my $comma=""; |
223
|
3
|
|
|
|
|
6
|
push @out, $indent; |
224
|
3
|
|
|
|
|
9
|
foreach my $portref ($self->ports_sorted) { |
225
|
1
|
|
|
|
|
5
|
push @out, $comma, $portref->verilog_text; |
226
|
1
|
|
|
|
|
4
|
$comma = ", "; |
227
|
|
|
|
|
|
|
} |
228
|
3
|
|
|
|
|
6
|
push @out, ");\n"; |
229
|
|
|
|
|
|
|
|
230
|
3
|
|
|
|
|
7
|
foreach my $netref ($self->nets_sorted) { |
231
|
3
|
|
|
|
|
11
|
push @out, $indent, $netref->verilog_text, "\n"; |
232
|
|
|
|
|
|
|
} |
233
|
3
|
|
|
|
|
8
|
foreach my $oref ($self->modports_sorted) { |
234
|
1
|
|
|
|
|
5
|
push @out, $indent, $oref->verilog_text, "\n"; |
235
|
|
|
|
|
|
|
} |
236
|
3
|
|
|
|
|
9
|
foreach my $cellref ($self->cells_sorted) { |
237
|
1
|
|
|
|
|
5
|
push @out, $indent, $cellref->verilog_text, "\n"; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
3
|
|
|
|
|
7
|
push @out, "endinterface\n"; |
241
|
3
|
50
|
|
|
|
24
|
return (wantarray ? @out : join('',@out)); |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub dump { |
245
|
6
|
|
|
6
|
1
|
9
|
my $self = shift; |
246
|
6
|
|
100
|
|
|
18
|
my $indent = shift||0; |
247
|
6
|
|
|
|
|
8
|
my $norecurse = shift; |
248
|
6
|
|
|
|
|
84
|
print " "x$indent,"Interface:",$self->name()," File:",$self->filename(),"\n"; |
249
|
6
|
100
|
|
|
|
31
|
if (!$norecurse) { |
250
|
3
|
|
|
|
|
10
|
foreach my $portref ($self->ports_sorted) { |
251
|
1
|
|
|
|
|
5
|
$portref->dump($indent+2); |
252
|
|
|
|
|
|
|
} |
253
|
3
|
|
|
|
|
9
|
foreach my $netref ($self->nets_sorted) { |
254
|
3
|
|
|
|
|
11
|
$netref->dump($indent+2); |
255
|
|
|
|
|
|
|
} |
256
|
3
|
|
|
|
|
14
|
foreach my $oref ($self->modports_sorted) { |
257
|
1
|
|
|
|
|
7
|
$oref->dump($indent+2); |
258
|
|
|
|
|
|
|
} |
259
|
3
|
|
|
|
|
11
|
foreach my $cellref ($self->cells_sorted) { |
260
|
1
|
|
|
|
|
6
|
$cellref->dump($indent+2); |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
###################################################################### |
266
|
|
|
|
|
|
|
#### Package return |
267
|
|
|
|
|
|
|
1; |
268
|
|
|
|
|
|
|
__END__ |