| 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::Port; |
|
6
|
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
69
|
use Verilog::Netlist; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
191
|
|
|
8
|
8
|
|
|
8
|
|
36
|
use Verilog::Netlist::Subclass; |
|
|
8
|
|
|
|
|
10
|
|
|
|
8
|
|
|
|
|
312
|
|
|
9
|
8
|
|
|
8
|
|
38
|
use vars qw($VERSION @ISA); |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
313
|
|
|
10
|
8
|
|
|
8
|
|
36
|
use strict; |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
5044
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw(Verilog::Netlist::Port::Struct |
|
12
|
|
|
|
|
|
|
Verilog::Netlist::Subclass); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$VERSION = '3.480'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
structs('_new_base', |
|
17
|
|
|
|
|
|
|
'Verilog::Netlist::Port::Struct' |
|
18
|
|
|
|
|
|
|
=>[name => '$', #' # Name of the port |
|
19
|
|
|
|
|
|
|
filename => '$', #' # Filename this came from |
|
20
|
|
|
|
|
|
|
lineno => '$', #' # Linenumber this came from |
|
21
|
|
|
|
|
|
|
userdata => '%', # User information |
|
22
|
|
|
|
|
|
|
attributes => '%', #' # Misc attributes for systemperl or other processors |
|
23
|
|
|
|
|
|
|
# |
|
24
|
|
|
|
|
|
|
direction => '$', #' # Direction (in/out/inout) |
|
25
|
|
|
|
|
|
|
data_type => '$', #' # SystemVerilog Type (logic/integer etc) |
|
26
|
|
|
|
|
|
|
comment => '$', #' # Comment provided by user |
|
27
|
|
|
|
|
|
|
array => '$', #' # Vectorization |
|
28
|
|
|
|
|
|
|
module => '$', #' # Module entity belongs to |
|
29
|
|
|
|
|
|
|
# below only after links() |
|
30
|
|
|
|
|
|
|
net => '$', #' # Net port connects |
|
31
|
|
|
|
|
|
|
# below only after autos() |
|
32
|
|
|
|
|
|
|
sp_autocreated => '$', #' # Created by /*AUTOINOUT*/ |
|
33
|
|
|
|
|
|
|
]); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
|
36
|
690
|
|
|
690
|
0
|
883
|
my $class = shift; |
|
37
|
690
|
|
|
|
|
2770
|
my %params = (@_); |
|
38
|
690
|
50
|
|
|
|
1441
|
$params{data_type} = $params{type} if defined $params{type}; # Backward compatibility |
|
39
|
690
|
50
|
|
|
|
1179
|
if ($params{direction}) { # Correct common mistakes; plus the parser itself needs this conversion |
|
40
|
690
|
100
|
|
|
|
1318
|
$params{direction} = 'in' if $params{direction} eq 'input'; |
|
41
|
690
|
100
|
|
|
|
1327
|
$params{direction} = 'out' if $params{direction} eq 'output'; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
690
|
|
|
|
|
9945
|
return $class->_new_base(%params); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub delete { |
|
47
|
603
|
|
|
603
|
0
|
670
|
my $self = shift; |
|
48
|
603
|
|
|
|
|
6502
|
my $h = $self->module->_ports; |
|
49
|
603
|
|
|
|
|
6538
|
delete $h->{$self->name}; |
|
50
|
603
|
|
|
|
|
1156
|
return undef; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
###################################################################### |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
0
|
0
|
sub netlist { return $_[0]->module->netlist; } |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
0
|
sub logger { return $_[0]->netlist->logger; } |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub type { # Backward compatibility only |
|
60
|
0
|
|
|
0
|
1
|
0
|
my $self=shift; |
|
61
|
0
|
0
|
|
|
|
0
|
if ($#_ >= 0) { $self->data_type(@_); } |
|
|
0
|
|
|
|
|
0
|
|
|
62
|
0
|
|
0
|
|
|
0
|
return ($self->data_type || ($self->net && $self->net->type))||''; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _link { |
|
66
|
182
|
|
|
182
|
|
193
|
my $self = shift; |
|
67
|
182
|
100
|
|
|
|
1953
|
if (!$self->net) { |
|
68
|
88
|
|
|
|
|
995
|
my $net = $self->module->find_net($self->name); |
|
69
|
88
|
100
|
|
|
|
164
|
if (!$net) { |
|
70
|
2
|
|
|
|
|
4
|
my $msb; |
|
71
|
|
|
|
|
|
|
my $lsb; |
|
72
|
2
|
50
|
|
|
|
26
|
if (defined $self->data_type) { |
|
73
|
2
|
|
|
|
|
28
|
$self->data_type =~ /\[([^:]+)(:(.*))?\]$/; |
|
74
|
2
|
|
|
|
|
3
|
$msb = $1; |
|
75
|
2
|
50
|
|
|
|
7
|
$lsb = defined($3) ? $3 : $1; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
2
|
|
|
|
|
22
|
$net = $self->module->new_net |
|
78
|
|
|
|
|
|
|
(name=>$self->name, |
|
79
|
|
|
|
|
|
|
filename=>$self->filename, lineno=>$self->lineno, |
|
80
|
|
|
|
|
|
|
decl_type=>"port", net_type=>"wire", |
|
81
|
|
|
|
|
|
|
data_type=>$self->data_type, array=>$self->array, |
|
82
|
|
|
|
|
|
|
comment=>undef, msb=>$msb, lsb=>$lsb, |
|
83
|
|
|
|
|
|
|
); |
|
84
|
2
|
|
|
|
|
28
|
$net->attributes($self->attributes); # Copy attributes across |
|
85
|
|
|
|
|
|
|
} |
|
86
|
88
|
50
|
33
|
|
|
1032
|
if ($net && $net->port && $net->port != $self) { |
|
|
|
|
33
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
$self->error("Port redeclares existing port: ",$self->name,"\n"); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
88
|
|
|
|
|
1045
|
$self->net($net); |
|
90
|
88
|
|
|
|
|
901
|
$self->net->port($self); |
|
91
|
|
|
|
|
|
|
# A input to the module is actually a "source" or thus "out" of the net. |
|
92
|
88
|
100
|
|
|
|
968
|
$self->net->_used_in_inc() if ($self->direction() eq 'out'); |
|
93
|
88
|
100
|
|
|
|
933
|
$self->net->_used_out_inc() if ($self->direction() eq 'in'); |
|
94
|
88
|
100
|
|
|
|
903
|
$self->net->_used_inout_inc() if ($self->direction() eq 'inout'); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
72
|
0
|
|
sub lint {} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub verilog_text { |
|
100
|
71
|
|
|
71
|
0
|
70
|
my $self = shift; |
|
101
|
71
|
|
|
|
|
725
|
return $self->name; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub dump { |
|
105
|
110
|
|
|
110
|
1
|
138
|
my $self = shift; |
|
106
|
110
|
|
50
|
|
|
163
|
my $indent = shift||0; |
|
107
|
110
|
|
50
|
|
|
1451
|
print " "x$indent,"Port:",$self->name()," Dir:",$self->direction() |
|
108
|
|
|
|
|
|
|
," DataT:",$self->data_type()," Array:",$self->array()||"","\n"; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
###################################################################### |
|
112
|
|
|
|
|
|
|
#### Package return |
|
113
|
|
|
|
|
|
|
1; |
|
114
|
|
|
|
|
|
|
__END__ |