| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Verilog - Verilog Perl Modport |
|
2
|
|
|
|
|
|
|
# See copyright, etc in below POD section. |
|
3
|
|
|
|
|
|
|
###################################################################### |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Verilog::Netlist::ModPort; |
|
6
|
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
46
|
use Verilog::Netlist; |
|
|
8
|
|
|
|
|
10
|
|
|
|
8
|
|
|
|
|
195
|
|
|
8
|
8
|
|
|
8
|
|
2703
|
use Verilog::Netlist::Net; |
|
|
8
|
|
|
|
|
20
|
|
|
|
8
|
|
|
|
|
315
|
|
|
9
|
8
|
|
|
8
|
|
46
|
use Verilog::Netlist::Subclass; |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
264
|
|
|
10
|
8
|
|
|
8
|
|
53
|
use vars qw($VERSION @ISA); |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
285
|
|
|
11
|
8
|
|
|
8
|
|
33
|
use strict; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
7589
|
|
|
12
|
|
|
|
|
|
|
@ISA = qw(Verilog::Netlist::ModPort::Struct |
|
13
|
|
|
|
|
|
|
Verilog::Netlist::Subclass); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$VERSION = '3.480'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
structs('new', |
|
18
|
|
|
|
|
|
|
'Verilog::Netlist::ModPort::Struct' |
|
19
|
|
|
|
|
|
|
=>[name => '$', #' # Name of the module |
|
20
|
|
|
|
|
|
|
filename => '$', #' # Filename this came from |
|
21
|
|
|
|
|
|
|
lineno => '$', #' # Linenumber this came from |
|
22
|
|
|
|
|
|
|
module => '$', #' # Interface is a member of |
|
23
|
|
|
|
|
|
|
userdata => '%', # User information |
|
24
|
|
|
|
|
|
|
attributes => '%', #' # Misc attributes for systemperl or other processors |
|
25
|
|
|
|
|
|
|
# |
|
26
|
|
|
|
|
|
|
comment => '$', #' # Comment provided by user |
|
27
|
|
|
|
|
|
|
_ports => '%', # hash of Verilog::Netlist::Ports |
|
28
|
|
|
|
|
|
|
_portsordered=> '@', # list of Verilog::Netlist::Ports as ordered in list of ports |
|
29
|
|
|
|
|
|
|
_nets => '%', # hash of Verilog::Netlist::Nets |
|
30
|
|
|
|
|
|
|
]); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub delete { |
|
33
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
34
|
0
|
|
|
|
|
0
|
foreach my $oref ($self->nets) { |
|
35
|
0
|
|
|
|
|
0
|
$oref->delete; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
0
|
|
|
|
|
0
|
foreach my $oref ($self->ports) { |
|
38
|
0
|
|
|
|
|
0
|
$oref->delete; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
0
|
|
|
|
|
0
|
my $h = $self->module->{_modports}; |
|
41
|
0
|
|
|
|
|
0
|
delete $h->{$self->name}; |
|
42
|
0
|
|
|
|
|
0
|
return undef; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
###################################################################### |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
1
|
0
|
sub netlist { return $_[0]->module->netlist; } |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
0
|
0
|
|
sub is_top {} # Ignored, for module compatibility |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
0
|
0
|
0
|
sub keyword { return 'modport'; } |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub logger { |
|
54
|
0
|
|
|
0
|
1
|
0
|
return $_[0]->netlist->logger; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub find_net { |
|
58
|
8
|
|
|
8
|
0
|
10
|
my $self = shift; |
|
59
|
8
|
|
|
|
|
18
|
my $search = shift; |
|
60
|
8
|
|
100
|
|
|
116
|
my $rtn = $self->_nets->{$search}||""; |
|
61
|
|
|
|
|
|
|
#print "FINDNET ",$self->name, " SS $search $rtn\n"; |
|
62
|
8
|
|
66
|
|
|
92
|
return $self->_nets->{$search} || $self->_nets->{"\\".$search." "}; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
sub find_port { |
|
65
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
66
|
0
|
|
|
|
|
0
|
my $search = shift; |
|
67
|
0
|
|
0
|
|
|
0
|
return $self->_ports->{$search} || $self->_ports->{"\\".$search." "}; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
sub find_port_by_index { |
|
70
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
71
|
0
|
|
|
|
|
0
|
my $myindex = shift; |
|
72
|
|
|
|
|
|
|
# @{$self->_portsordered}[$myindex-1] returns the name of |
|
73
|
|
|
|
|
|
|
# the port in the module at this index. Then, this is |
|
74
|
|
|
|
|
|
|
# used to find the port reference via the port hash |
|
75
|
0
|
|
|
|
|
0
|
return $self->_ports->{@{$self->_portsordered}[$myindex-1]}; |
|
|
0
|
|
|
|
|
0
|
|
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub attrs_sorted { |
|
79
|
0
|
|
|
0
|
0
|
0
|
return (sort {$a cmp $b} @{$_[0]->attrs}); |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
sub nets { |
|
82
|
0
|
|
|
0
|
1
|
0
|
return (values %{$_[0]->_nets}); |
|
|
0
|
|
|
|
|
0
|
|
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
sub nets_sorted { |
|
85
|
0
|
|
|
0
|
1
|
0
|
return (sort {$a->name() cmp $b->name()} (values %{$_[0]->_nets})); |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
sub ports { |
|
88
|
6
|
|
|
6
|
1
|
7
|
return (values %{$_[0]->_ports}); |
|
|
6
|
|
|
|
|
84
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
sub ports_sorted { |
|
91
|
2
|
|
|
2
|
1
|
3
|
return (sort {$a->name() cmp $b->name()} (values %{$_[0]->_ports})); |
|
|
2
|
|
|
|
|
30
|
|
|
|
2
|
|
|
|
|
27
|
|
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
sub ports_ordered { |
|
94
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
95
|
0
|
|
|
|
|
0
|
return map {$self->_ports->{$_}} @{$self->_portsordered}; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub nets_and_ports_sorted { |
|
99
|
0
|
|
|
0
|
1
|
0
|
return Verilog::Netlist::Module::nets_and_ports_sorted(@_); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub new_attr { |
|
103
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
104
|
0
|
|
|
|
|
0
|
my $clean_text = shift; |
|
105
|
0
|
|
|
|
|
0
|
push @{$self->attrs}, $clean_text; |
|
|
0
|
|
|
|
|
0
|
|
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub new_net { |
|
109
|
4
|
|
|
4
|
0
|
8
|
my $self = shift; |
|
110
|
|
|
|
|
|
|
# @_ params |
|
111
|
|
|
|
|
|
|
# Create a new net under this |
|
112
|
4
|
|
|
|
|
12
|
my $netref = new Verilog::Netlist::Net(direction=>'net', data_type=>'wire', |
|
113
|
|
|
|
|
|
|
@_, |
|
114
|
|
|
|
|
|
|
module=>$self, ); |
|
115
|
4
|
|
|
|
|
49
|
$self->_nets($netref->name(), $netref); |
|
116
|
4
|
|
|
|
|
8
|
return $netref; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub new_port { |
|
120
|
4
|
|
|
4
|
0
|
12
|
my $self = shift; |
|
121
|
|
|
|
|
|
|
# @_ params |
|
122
|
|
|
|
|
|
|
# Create a new port under this module |
|
123
|
4
|
|
|
|
|
16
|
my $portref = new Verilog::Netlist::Port(@_, module=>$self,); |
|
124
|
4
|
|
|
|
|
45
|
$self->_ports($portref->name(), $portref); |
|
125
|
4
|
|
|
|
|
53
|
return $portref; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _link { |
|
129
|
6
|
|
|
6
|
|
10
|
my $self = shift; |
|
130
|
|
|
|
|
|
|
# Ports create nets, so link ports before nets |
|
131
|
6
|
|
|
|
|
15
|
foreach my $oref ($self->ports) { |
|
132
|
12
|
|
|
|
|
31
|
$oref->_link(); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub lint { |
|
137
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
138
|
0
|
0
|
|
|
|
0
|
if ($self->netlist->{use_vars}) { |
|
139
|
0
|
|
|
|
|
0
|
foreach my $oref ($self->ports) { |
|
140
|
0
|
|
|
|
|
0
|
$oref->lint(); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub verilog_text { |
|
146
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
147
|
1
|
|
|
|
|
13
|
my @out = "modport ".$self->name." (\n"; |
|
148
|
1
|
|
|
|
|
2
|
my $indent = " "; |
|
149
|
|
|
|
|
|
|
# Port list |
|
150
|
1
|
|
|
|
|
1
|
my $comma=""; |
|
151
|
1
|
|
|
|
|
2
|
push @out, $indent; |
|
152
|
1
|
|
|
|
|
2
|
foreach my $oref ($self->ports_sorted) { |
|
153
|
2
|
|
|
|
|
5
|
push @out, $comma, $oref->verilog_text; |
|
154
|
2
|
|
|
|
|
3
|
$comma = ", "; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
1
|
|
|
|
|
2
|
push @out, ");\n"; |
|
157
|
1
|
|
|
|
|
2
|
push @out, "endmodport\n"; |
|
158
|
1
|
50
|
|
|
|
6
|
return (wantarray ? @out : join('',@out)); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub dump { |
|
162
|
1
|
|
|
1
|
1
|
1
|
my $self = shift; |
|
163
|
1
|
|
50
|
|
|
3
|
my $indent = shift||0; |
|
164
|
1
|
|
|
|
|
2
|
my $norecurse = shift; |
|
165
|
1
|
|
|
|
|
24
|
print " "x$indent,"ModPort:",$self->name()," File:",$self->filename(),"\n"; |
|
166
|
1
|
50
|
|
|
|
5
|
if (!$norecurse) { |
|
167
|
1
|
|
|
|
|
4
|
foreach my $oref ($self->ports_sorted) { |
|
168
|
2
|
|
|
|
|
8
|
$oref->dump($indent+2); |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
###################################################################### |
|
174
|
|
|
|
|
|
|
#### Package return |
|
175
|
|
|
|
|
|
|
1; |
|
176
|
|
|
|
|
|
|
__END__ |