| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# See copyright, etc in below POD section. |
|
2
|
|
|
|
|
|
|
###################################################################### |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package SystemC::Vregs::Output::Layout; |
|
5
|
3
|
|
|
3
|
|
14
|
use SystemC::Vregs::Number; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
143
|
|
|
6
|
3
|
|
|
3
|
|
1333
|
use SystemC::Vregs::Language; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
124
|
|
|
7
|
3
|
|
|
3
|
|
19
|
use Carp; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
158
|
|
|
8
|
3
|
|
|
3
|
|
13
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
76
|
|
|
9
|
3
|
|
|
3
|
|
14
|
use vars qw($VERSION); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
4813
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '1.470'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
###################################################################### |
|
14
|
|
|
|
|
|
|
# CONSTRUCTOR |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
|
17
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
18
|
0
|
|
|
|
|
|
my $self = {@_}; |
|
19
|
0
|
|
|
|
|
|
bless $self, $class; |
|
20
|
0
|
|
|
|
|
|
return $self; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
###################################################################### |
|
24
|
|
|
|
|
|
|
# METHODS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _print_attributes { |
|
27
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
28
|
0
|
|
|
|
|
|
my $item = shift; |
|
29
|
0
|
|
|
|
|
|
my $fl = shift; |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $string = $item->attributes_string; |
|
32
|
0
|
|
|
|
|
|
$string =~ s/ +/\t/g; |
|
33
|
0
|
0
|
|
|
|
|
$string = "\t$string" if $string ne ""; |
|
34
|
0
|
|
|
|
|
|
$fl->print($string); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _print_bit { |
|
38
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
39
|
0
|
|
|
|
|
|
my $bitref = shift; |
|
40
|
0
|
|
|
|
|
|
my $fl = shift; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $descflags = ""; |
|
43
|
0
|
0
|
|
|
|
|
$descflags = ". Overlaps $bitref->{overlaps}." if $bitref->{overlaps}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$fl->printf_tabify("\tbit\t%-15s\t%-7s\t%-3s %-11s\t%-7s" |
|
46
|
|
|
|
|
|
|
,$bitref->{name},$bitref->{bits},$bitref->{access} |
|
47
|
|
|
|
|
|
|
,$bitref->{type},$bitref->{rst}); |
|
48
|
0
|
|
|
|
|
|
$self->_print_attributes($bitref,$fl); |
|
49
|
0
|
|
|
|
|
|
$fl->printf("\t \"%s%s\"\n", $bitref->{desc},$descflags); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _print_type { |
|
53
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
54
|
0
|
|
|
|
|
|
my $typeref = shift; |
|
55
|
0
|
|
|
|
|
|
my $fl = shift; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$fl->print(" type\t$typeref->{name}"); |
|
58
|
0
|
0
|
|
|
|
|
if ($typeref->{inherits}) { |
|
59
|
0
|
|
|
|
|
|
$fl->print("\t:$typeref->{inherits}"); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
0
|
|
|
|
|
|
$self->_print_attributes($typeref, $fl); |
|
62
|
0
|
|
|
|
|
|
$fl->print("\n"); |
|
63
|
0
|
|
|
|
|
|
foreach my $fieldref ($typeref->fields_sorted()) { |
|
64
|
0
|
|
|
|
|
|
$self->_print_bit($fieldref, $fl); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
###################################################################### |
|
69
|
|
|
|
|
|
|
# Saving |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub write { |
|
72
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
73
|
0
|
|
|
|
|
|
my %params = (@_); |
|
74
|
0
|
0
|
|
|
|
|
my $pack = $params{pack} or croak "%Error: No pack=> parameter passed,"; |
|
75
|
|
|
|
|
|
|
# Dump headers for class name based accessors |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $fl = SystemC::Vregs::File->open(language=>'C', |
|
78
|
|
|
|
|
|
|
#rules => $pack->{rules}, |
|
79
|
|
|
|
|
|
|
noheader => 1, |
|
80
|
|
|
|
|
|
|
%params); |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$fl->print("// DESCR"."IPTION: Register Layout: Generated AUTOMATICALLY by vregs\n"); |
|
83
|
0
|
|
|
|
|
|
$fl->print("//\n"); |
|
84
|
0
|
|
|
|
|
|
$fl->print("// Format:\n"); |
|
85
|
0
|
|
|
|
|
|
$fl->print("//\tpackage {name} [attributes...]\n"); |
|
86
|
0
|
|
|
|
|
|
$fl->print("//\treg {name} {type}[vec] {address} {spacing} [attributes...]\n"); |
|
87
|
0
|
|
|
|
|
|
$fl->print("//\ttype {name} [:{inherits}] [attributes...]\n"); |
|
88
|
0
|
|
|
|
|
|
$fl->print("//\tbit {name} {bits} {access} {type} {reset} [attributes...] {description}\n"); |
|
89
|
0
|
|
|
|
|
|
$fl->print("//\tconst {name} {value} [attributes...] {description}\n"); |
|
90
|
0
|
|
|
|
|
|
$fl->print("//\tdefine {name} {value} [attributes...] {description}\n"); |
|
91
|
0
|
|
|
|
|
|
$fl->print("//\tenum {name} [attributes...]\n"); |
|
92
|
0
|
|
|
|
|
|
$fl->print("// Where [attributes...] are multiple entries of '-{name}' or '-{name}={value}'\n"); |
|
93
|
0
|
|
|
|
|
|
$fl->print("\n"); |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
$fl->print("package $pack->{name}"); |
|
96
|
0
|
|
|
|
|
|
$self->_print_attributes($pack, $fl); |
|
97
|
0
|
|
|
|
|
|
$fl->print("\n"); |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
$fl->print("//Rebuild with: $pack->{rebuild_comment}\n") if $pack->{rebuild_comment}; |
|
100
|
0
|
|
|
|
|
|
$fl->print("\n"); |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$fl->print("//",'*'x70,"\n// Registers\n"); |
|
103
|
0
|
|
|
|
|
|
my %printed; |
|
104
|
0
|
|
|
|
|
|
foreach my $regref ($pack->regs_sorted) { |
|
105
|
0
|
|
0
|
|
|
|
my $classname = $regref->{name} || "x"; |
|
106
|
0
|
|
|
|
|
|
my $addr = $regref->{addr}; |
|
107
|
0
|
|
0
|
|
|
|
my $range = $regref->{range} || ""; |
|
108
|
0
|
0
|
|
|
|
|
if (!defined $addr) { |
|
109
|
0
|
|
|
|
|
|
print "%Error: No address defined: ${classname}\n"; |
|
110
|
|
|
|
|
|
|
} else { |
|
111
|
0
|
|
|
|
|
|
(my $nor = $classname) =~ s/^R_//; |
|
112
|
0
|
|
|
|
|
|
my $type = "Vregs${nor}"; |
|
113
|
0
|
|
|
|
|
|
$fl->printf(" reg\t$classname\t$type$range\t0x%s\t0x%s\t" |
|
114
|
|
|
|
|
|
|
, $addr->to_Hex, $regref->{spacing}->to_Hex); |
|
115
|
0
|
|
|
|
|
|
$fl->print("\n"); |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my $typeref = $regref->{typeref}; |
|
118
|
0
|
0
|
|
|
|
|
if (!$printed{$typeref}) { |
|
119
|
0
|
|
|
|
|
|
$printed{$typeref} = 1; |
|
120
|
0
|
|
|
|
|
|
$self->_print_type ($typeref, $fl); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
$fl->print("//",'*'x70,"\n// Classes\n"); |
|
126
|
0
|
|
|
|
|
|
foreach my $typeref ($pack->types_sorted) { |
|
127
|
0
|
0
|
|
|
|
|
if (!$printed{$typeref}) { |
|
128
|
0
|
|
|
|
|
|
$printed{$typeref} = 1; |
|
129
|
0
|
|
|
|
|
|
$self->_print_type ($typeref, $fl); |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
$fl->print("//",'*'x70,"\n// Enumerations\n"); |
|
134
|
0
|
|
|
|
|
|
foreach my $classref ($pack->enums_sorted) { |
|
135
|
0
|
|
0
|
|
|
|
my $classname = $classref->{name} || "x"; |
|
136
|
0
|
|
|
|
|
|
$fl->printf(" enum\t$classname"); |
|
137
|
0
|
|
|
|
|
|
$self->_print_attributes($classref, $fl); |
|
138
|
0
|
|
|
|
|
|
$fl->print("\n"); |
|
139
|
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
foreach my $fieldref ($classref->fields_sorted()) { |
|
141
|
0
|
0
|
|
|
|
|
next if $fieldref->{omit_from_vregs_file}; |
|
142
|
0
|
|
|
|
|
|
$fl->printf("\tconst\t%-13s\t%s" |
|
143
|
|
|
|
|
|
|
,$fieldref->{name},$fieldref->{rst}); |
|
144
|
0
|
|
|
|
|
|
$self->_print_attributes($fieldref, $fl); |
|
145
|
0
|
|
|
|
|
|
$fl->printf("\t\"%s\"\n",$fieldref->{desc}); |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
$fl->print("//",'*'x70,"\n// Defines\n"); |
|
150
|
0
|
|
|
|
|
|
foreach my $fieldref ($pack->defines_sorted) { |
|
151
|
0
|
0
|
|
|
|
|
next if !$fieldref->{is_manual}; |
|
152
|
0
|
|
|
|
|
|
$fl->printf("\tdefine\t%-13s", $fieldref->{name}); |
|
153
|
0
|
0
|
|
|
|
|
if ($fieldref->attribute_value('freeform')) { |
|
154
|
0
|
|
|
|
|
|
$fl->printf("\t\"%s\"", $fieldref->{rst}); |
|
155
|
|
|
|
|
|
|
} else { |
|
156
|
0
|
|
|
|
|
|
$fl->printf("\t%s", $fieldref->{rst}); |
|
157
|
|
|
|
|
|
|
} |
|
158
|
0
|
|
|
|
|
|
$self->_print_attributes($fieldref, $fl); |
|
159
|
0
|
|
|
|
|
|
$fl->printf("\t\"%s\"\n" |
|
160
|
|
|
|
|
|
|
,$fieldref->{desc}); |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
$fl->close(); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
###################################################################### |
|
167
|
|
|
|
|
|
|
###################################################################### |
|
168
|
|
|
|
|
|
|
#### Package return |
|
169
|
|
|
|
|
|
|
1; |
|
170
|
|
|
|
|
|
|
__END__ |