| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# See copyright, etc in below POD section. |
|
2
|
|
|
|
|
|
|
###################################################################### |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package SystemC::Vregs::Input::Layout; |
|
5
|
3
|
|
|
3
|
|
13
|
use Carp; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
162
|
|
|
6
|
3
|
|
|
3
|
|
14
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
84
|
|
|
7
|
3
|
|
|
3
|
|
12
|
use vars qw($VERSION); |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
3635
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$VERSION = '1.470'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
###################################################################### |
|
12
|
|
|
|
|
|
|
# CONSTRUCTOR |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
1
|
|
|
1
|
1
|
1
|
my $class = shift; |
|
16
|
1
|
|
|
|
|
3
|
my $self = {@_}; |
|
17
|
1
|
|
|
|
|
3
|
bless $self, $class; |
|
18
|
1
|
|
|
|
|
5
|
return $self; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
###################################################################### |
|
22
|
|
|
|
|
|
|
# Saving |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub read { |
|
25
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
26
|
1
|
|
|
|
|
5
|
my %params = (#filename => |
|
27
|
|
|
|
|
|
|
#pack => |
|
28
|
|
|
|
|
|
|
@_); |
|
29
|
1
|
50
|
|
|
|
4
|
my $pack = $params{pack} or croak "%Error: No pack=> parameter passed,"; |
|
30
|
1
|
|
|
|
|
6
|
$self->{pack} = $pack; |
|
31
|
|
|
|
|
|
|
# Dump headers for class name based accessors |
|
32
|
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
2
|
my $filename = $params{filename}; |
|
34
|
1
|
50
|
|
|
|
11
|
my $fh = new IO::File ("<$filename") or die "%Error: $! $filename\n"; |
|
35
|
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
93
|
my $line; |
|
37
|
1
|
|
|
|
|
2
|
my $lineno = 0; |
|
38
|
1
|
|
|
|
|
2
|
my $regref; |
|
39
|
|
|
|
|
|
|
my $typeref; |
|
40
|
0
|
|
|
|
|
0
|
my $classref; |
|
41
|
1
|
|
|
|
|
1
|
my $got_a_line = 0; |
|
42
|
1
|
|
|
|
|
40
|
while (my $line = $fh->getline() ) { |
|
43
|
70
|
|
|
|
|
2064
|
chomp $line; |
|
44
|
70
|
|
|
|
|
76
|
$lineno++; |
|
45
|
70
|
|
|
|
|
81
|
$got_a_line=1; |
|
46
|
70
|
50
|
|
|
|
161
|
if ($line =~ /^\# (\d+) \"([^\"]+)\"[ 0-9]*$/) { # from cpp: # linenu "file" {level} |
|
47
|
0
|
|
|
|
|
0
|
$lineno = $1 - 1; |
|
48
|
0
|
|
|
|
|
0
|
$filename = $2; |
|
49
|
|
|
|
|
|
|
#print "#FILE '$filename'\n" if $Debug; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
70
|
|
|
|
|
132
|
$line =~ s/\/\/.*$//; # Remove C/Verilog style comments |
|
52
|
70
|
|
|
|
|
179
|
$line =~ s/^\s+//; |
|
53
|
70
|
|
|
|
|
200
|
$line =~ s/\s+$//; |
|
54
|
|
|
|
|
|
|
|
|
55
|
70
|
|
|
|
|
133
|
my $fileline = "$filename:$lineno"; |
|
56
|
70
|
100
|
|
|
|
1021
|
if ($line eq "") {} |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
elsif ($line =~ /^reg\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)(.*)$/ ) { |
|
58
|
3
|
|
|
|
|
6
|
my $classname = $1; |
|
59
|
3
|
|
|
|
|
6
|
my $type = $2; |
|
60
|
3
|
|
|
|
|
9
|
my $addr = lc $3; |
|
61
|
3
|
|
|
|
|
5
|
my $spacingtext = $4; |
|
62
|
3
|
|
50
|
|
|
17
|
my $flags = $5 || ""; |
|
63
|
3
|
|
|
|
|
5
|
my $range = ""; |
|
64
|
3
|
100
|
|
|
|
15
|
$range = $1 if $type =~ s/(\[.*\])//; |
|
65
|
3
|
|
|
|
|
23
|
$regref = new SystemC::Vregs::Register |
|
66
|
|
|
|
|
|
|
(pack => $pack, |
|
67
|
|
|
|
|
|
|
name => $classname, |
|
68
|
|
|
|
|
|
|
at => "${filename}:$.", |
|
69
|
|
|
|
|
|
|
addrtext => $addr, |
|
70
|
|
|
|
|
|
|
spacingtext => $spacingtext, |
|
71
|
|
|
|
|
|
|
range => $range, |
|
72
|
|
|
|
|
|
|
); |
|
73
|
3
|
|
|
|
|
11
|
$regref->attributes_parse($flags); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
elsif ($line =~ /^type\s+(\S+)\s*(.*)$/ ) { |
|
76
|
7
|
|
|
|
|
13
|
my $typemnem = $1; my $flags = $2; |
|
|
7
|
|
|
|
|
14
|
|
|
77
|
7
|
|
|
|
|
16
|
my $inh = ""; |
|
78
|
7
|
100
|
|
|
|
34
|
$inh = $1 if ($flags =~ s/:(\S+)//); |
|
79
|
7
|
|
|
|
|
12
|
$typemnem =~ s/^Vregs//; |
|
80
|
7
|
|
|
|
|
8
|
$typemnem =~ s/_t$//; |
|
81
|
7
|
|
|
|
|
41
|
$typeref = new SystemC::Vregs::Type |
|
82
|
|
|
|
|
|
|
(pack => $pack, |
|
83
|
|
|
|
|
|
|
name => $typemnem, |
|
84
|
|
|
|
|
|
|
at => "${filename}:$.", |
|
85
|
|
|
|
|
|
|
); |
|
86
|
7
|
|
|
|
|
54
|
$typeref->inherits($inh); |
|
87
|
7
|
|
|
|
|
20
|
$typeref->attributes_parse($flags); |
|
88
|
7
|
100
|
66
|
|
|
32
|
$regref->{typeref} = $typeref if $regref && $typemnem =~ /^R_/; |
|
89
|
7
|
|
|
|
|
181
|
$regref = undef; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
elsif ($line =~ /^bit\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+([^\"]*)"(.*)"$/ ) { |
|
92
|
24
|
50
|
|
|
|
50
|
if (!$typeref) { |
|
93
|
0
|
|
|
|
|
0
|
die "%Error: $filename:$.: bit without previous type declaration\n";; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
24
|
|
|
|
|
42
|
my $bit_mnem = $1; |
|
96
|
24
|
|
|
|
|
40
|
my $bits = $2; my $acc = $3; my $type = $4; my $rst = $5; my $flags=$6; my $desc=$7; |
|
|
24
|
|
|
|
|
30
|
|
|
|
24
|
|
|
|
|
32
|
|
|
|
24
|
|
|
|
|
38
|
|
|
|
24
|
|
|
|
|
126
|
|
|
|
24
|
|
|
|
|
40
|
|
|
97
|
24
|
|
|
|
|
127
|
my $ref = new SystemC::Vregs::Bit |
|
98
|
|
|
|
|
|
|
(pack => $pack, |
|
99
|
|
|
|
|
|
|
name => $bit_mnem, |
|
100
|
|
|
|
|
|
|
typeref => $typeref, |
|
101
|
|
|
|
|
|
|
bits => $bits, |
|
102
|
|
|
|
|
|
|
access => $acc, |
|
103
|
|
|
|
|
|
|
rst => $rst, |
|
104
|
|
|
|
|
|
|
desc => $desc, |
|
105
|
|
|
|
|
|
|
type => $type, |
|
106
|
|
|
|
|
|
|
at => "${filename}:$.", |
|
107
|
|
|
|
|
|
|
); |
|
108
|
24
|
|
|
|
|
65
|
$ref->attributes_parse($flags); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
elsif ($line =~ /^enum\s+(\S+)\s*(.*)$/) { |
|
111
|
2
|
|
|
|
|
5
|
my $name = $1; my $flags = $2; |
|
|
2
|
|
|
|
|
11
|
|
|
112
|
2
|
|
|
|
|
17
|
$classref = new SystemC::Vregs::Enum |
|
113
|
|
|
|
|
|
|
(pack => $pack, |
|
114
|
|
|
|
|
|
|
name => $name, |
|
115
|
|
|
|
|
|
|
at => "${filename}:$.", |
|
116
|
|
|
|
|
|
|
); |
|
117
|
2
|
|
|
|
|
9
|
$classref->attributes_parse($flags); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
elsif ($line =~ /^const\s+(\S+)\s+(\S+)\s+([^\"]*)"(.*)"$/ ) { |
|
120
|
7
|
|
|
|
|
12
|
my $name = $1; my $rst=$2; my $flags=$3; my $desc=$4; |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
7
|
|
|
|
7
|
|
|
|
|
12
|
|
|
121
|
7
|
|
|
|
|
37
|
my $ref = new SystemC::Vregs::Enum::Value |
|
122
|
|
|
|
|
|
|
(pack => $pack, |
|
123
|
|
|
|
|
|
|
name => $name, |
|
124
|
|
|
|
|
|
|
class => $classref, |
|
125
|
|
|
|
|
|
|
rst => $rst, |
|
126
|
|
|
|
|
|
|
desc => $desc, |
|
127
|
|
|
|
|
|
|
at => "${filename}:$.", |
|
128
|
|
|
|
|
|
|
); |
|
129
|
7
|
|
|
|
|
25
|
$ref->attributes_parse($flags); |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
elsif ($line =~ /^define\s+(\S+)\s+(\S+)\s+([^\"]*)"(.*)"$/ ) { |
|
132
|
4
|
|
|
|
|
8
|
my $name = $1; my $rst=$2; my $flags=$3; my $desc=$4; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
6
|
|
|
133
|
4
|
100
|
|
|
|
15
|
$rst = $1 if $rst =~ m/^"(.*)"$/; |
|
134
|
4
|
|
|
|
|
25
|
my $ref = new SystemC::Vregs::Define::Value |
|
135
|
|
|
|
|
|
|
(pack => $pack, |
|
136
|
|
|
|
|
|
|
name => $name, |
|
137
|
|
|
|
|
|
|
rst => $rst, |
|
138
|
|
|
|
|
|
|
desc => $desc, |
|
139
|
|
|
|
|
|
|
is_manual => 1, |
|
140
|
|
|
|
|
|
|
at => "${filename}:$.", |
|
141
|
|
|
|
|
|
|
); |
|
142
|
4
|
|
|
|
|
15
|
$ref->attributes_parse($flags); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
elsif ($line =~ /^package\s+(\S+)\s*(.*)$/ ) { |
|
145
|
1
|
|
|
|
|
3
|
my $flags = $2; |
|
146
|
1
|
|
|
|
|
4
|
$pack->{name} = $1; |
|
147
|
1
|
|
|
|
|
6
|
$pack->{at} = "${filename}:$."; |
|
148
|
1
|
|
|
|
|
11
|
$pack->attributes_parse($flags); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
else { |
|
151
|
0
|
|
|
|
|
0
|
die "%Error: $fileline: Can't parse \"$line\"\n"; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
1
|
50
|
|
|
|
39
|
($got_a_line) or die "%Error: File empty or cpp error in $filename\n"; |
|
156
|
|
|
|
|
|
|
|
|
157
|
1
|
|
|
|
|
18
|
$fh->close(); |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
###################################################################### |
|
161
|
|
|
|
|
|
|
###################################################################### |
|
162
|
|
|
|
|
|
|
#### Package return |
|
163
|
|
|
|
|
|
|
1; |
|
164
|
|
|
|
|
|
|
__END__ |