line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# See copyright, etc in below POD section. |
2
|
|
|
|
|
|
|
###################################################################### |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package SystemC::Vregs::Language; |
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
37999
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
149
|
|
7
|
4
|
|
|
4
|
|
18
|
use vars qw($VERSION $Global_Change_Error); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
191
|
|
8
|
4
|
|
|
4
|
|
21
|
use Carp; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
265
|
|
9
|
4
|
|
|
4
|
|
22
|
use IO::File; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
10567
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '1.470'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Set to globally report if any files change; |
14
|
|
|
|
|
|
|
# for local usage, use new(change_error => ...) instead. |
15
|
|
|
|
|
|
|
#$Global_Change_Error = undef; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
###################################################################### |
18
|
|
|
|
|
|
|
#### Implementation |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
###################################################################### |
21
|
|
|
|
|
|
|
#### Creation |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
10
|
|
|
10
|
0
|
574
|
my $class = shift; |
25
|
10
|
|
|
|
|
60
|
my $self = {text=>[], |
26
|
|
|
|
|
|
|
close_text=>[], |
27
|
|
|
|
|
|
|
#keep_timestamp=>undef, |
28
|
|
|
|
|
|
|
#dry_run=>undef, # Don't do it, just see if would do it |
29
|
|
|
|
|
|
|
#change_diff=>"", |
30
|
|
|
|
|
|
|
#change_error=>{}, |
31
|
|
|
|
|
|
|
#changes=>undef, # For dry_run, any changes found? |
32
|
|
|
|
|
|
|
#verbose=>0, |
33
|
|
|
|
|
|
|
@_}; |
34
|
|
|
|
|
|
|
|
35
|
10
|
50
|
|
|
|
30
|
$self->{filename} or croak "%Error: ->new() requires filename=> argument, stopped"; |
36
|
10
|
|
|
|
|
22
|
$self->{modulename} = $self->{filename}; |
37
|
10
|
|
|
|
|
48
|
$self->{modulename} =~ s/.*[\/\\]//; |
38
|
10
|
|
|
|
|
48
|
$self->{modulename} =~ s/[^a-zA-Z0-9]/_/g; |
39
|
|
|
|
|
|
|
|
40
|
10
|
|
|
|
|
18
|
my $bless_class = $class; |
41
|
10
|
50
|
|
|
|
27
|
if ($self->{language}) { |
42
|
|
|
|
|
|
|
# Have language=>C use the class SystemC::Vregs::Language::C |
43
|
10
|
|
|
|
|
21
|
$bless_class .= "::" . $self->{language}; |
44
|
10
|
|
|
|
|
21
|
my $package_class = __PACKAGE__ . "::" . $self->{language}; |
45
|
10
|
100
|
|
|
|
35
|
$package_class = $class if $class eq __PACKAGE__; |
46
|
|
|
|
|
|
|
#exists $::{$bless_class} or croak "%Error: ->new() passed invalid language=>",$self->{language},", stopped"; |
47
|
|
|
|
|
|
|
# Things are interesting, because the user might have made their |
48
|
|
|
|
|
|
|
# own class. We'll simply make a multiple-inheritance package for them. |
49
|
2
|
50
|
|
2
|
|
20
|
eval (" |
|
2
|
|
|
1
|
|
5
|
|
|
2
|
|
|
1
|
|
745
|
|
|
1
|
|
|
1
|
|
8
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
85
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
99
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
82
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
|
10
|
|
|
|
|
932
|
|
50
|
|
|
|
|
|
|
package ${bless_class}; |
51
|
|
|
|
|
|
|
use base qw (${package_class} ${class}); |
52
|
|
|
|
|
|
|
1;") or die; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Allow $self->{C} to be a short cut for $self->{language} eq "C" |
56
|
10
|
|
|
|
|
34
|
$self->{ $self->{language} } = 1; |
57
|
|
|
|
|
|
|
|
58
|
10
|
|
|
|
|
26
|
bless $self, $bless_class; |
59
|
10
|
|
|
|
|
28
|
return $self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub DESTROY { |
63
|
9
|
|
|
9
|
|
2319
|
my $self = shift; |
64
|
9
|
50
|
|
|
|
15
|
if ($#{$self->{text}} >= 0) { |
|
9
|
|
|
|
|
170
|
|
65
|
0
|
|
|
|
|
0
|
$self->close(); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub close_prep { |
70
|
11
|
|
|
11
|
0
|
14
|
my $self = shift; |
71
|
11
|
|
|
|
|
13
|
$self->print (@{$self->{close_text}}); |
|
11
|
|
|
|
|
33
|
|
72
|
11
|
|
|
|
|
23
|
@{$self->{close_text}} = (); |
|
11
|
|
|
|
|
33
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub text_to_output { |
76
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
77
|
0
|
|
|
|
|
0
|
return join('',@{$self->{text}},@{$self->{close_text}}); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub close { |
81
|
10
|
|
|
10
|
0
|
62
|
my $self = shift; |
82
|
10
|
50
|
|
|
|
30
|
return if $self->{_closing}; # Don't recurse in close if we die() here. |
83
|
10
|
|
|
|
|
19
|
$self->{_closing} = 1; |
84
|
|
|
|
|
|
|
|
85
|
10
|
|
|
|
|
52
|
$self->close_prep(); |
86
|
|
|
|
|
|
|
|
87
|
10
|
|
|
|
|
14
|
my @oldtext; # Old file contents |
88
|
10
|
|
|
|
|
19
|
my $keepstamp = $self->{keep_timestamp}; |
89
|
10
|
100
|
|
|
|
24
|
if ($keepstamp) { |
90
|
1
|
|
|
|
|
13
|
my $fh = IO::File->new ($self->{filename}); |
91
|
1
|
50
|
|
|
|
170
|
if ($fh) { |
92
|
1
|
|
|
|
|
55
|
@oldtext = $fh->getlines(); |
93
|
1
|
|
|
|
|
206
|
$fh->close(); |
94
|
|
|
|
|
|
|
} else { |
95
|
0
|
|
|
|
|
0
|
$keepstamp = 0; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
10
|
100
|
66
|
|
|
101
|
if (!$keepstamp |
|
1
|
|
|
|
|
28
|
|
100
|
|
|
|
|
|
|
|| (join ('',@oldtext) ne join ('',@{$self->{text}}))) { |
101
|
9
|
|
|
|
|
27
|
$self->{changes} = 1; |
102
|
9
|
|
|
|
|
17
|
my $diff = describe_diff (join ('',@oldtext), join ('',@{$self->{text}})); |
|
9
|
|
|
|
|
42
|
|
103
|
9
|
50
|
33
|
|
|
42
|
if ($Global_Change_Error) { |
|
|
50
|
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
die "%Error: Changes needed to $self->{filename}, but globally not allowed to change files\n$diff\n"; |
105
|
|
|
|
|
|
|
} elsif ($self->{change_error}{ $self->language } |
106
|
|
|
|
|
|
|
|| $self->{change_error}{ALL}) { |
107
|
0
|
0
|
|
|
|
0
|
if ($self->_close_change_diff()) { |
108
|
0
|
|
|
|
|
0
|
die "%Error: Changes needed to $self->{filename}, but not allowed to change ".$self->language." files\n$diff\n"; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
112
|
9
|
50
|
|
|
|
24
|
if ($self->{dry_run}) { |
113
|
0
|
0
|
|
|
|
0
|
printf "Would write $self->{filename} (--dry-run)\n" if ($self->{verbose}); |
114
|
|
|
|
|
|
|
} else { |
115
|
9
|
50
|
|
|
|
22
|
printf "Writing $self->{filename}\n" if ($self->{verbose}); |
116
|
9
|
50
|
|
|
|
65
|
my $fh = IO::File->new ($self->{filename},"w") or die "%Error: $! $self->{filename}\n"; |
117
|
9
|
|
|
|
|
1464
|
print $fh @{$self->{text}}; |
|
9
|
|
|
|
|
162
|
|
118
|
9
|
|
|
|
|
37
|
$fh->close(); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} else { |
121
|
1
|
50
|
|
|
|
338
|
printf "Same $self->{filename}\n" if ($self->{verbose}); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
10
|
|
|
|
|
444
|
$self->{text} = []; |
125
|
10
|
|
|
|
|
67
|
delete $self->{_closing}; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub describe_diff { |
129
|
9
|
|
|
9
|
0
|
14
|
my $text1 = shift; |
130
|
9
|
|
|
|
|
19
|
my $text2 = shift; |
131
|
9
|
|
|
|
|
18
|
my @l1 = split(/\n/, $text1); |
132
|
9
|
|
|
|
|
65
|
my @l2 = split(/\n/, $text2); |
133
|
|
|
|
|
|
|
|
134
|
9
|
|
|
|
|
18
|
my $diffs = ""; |
135
|
9
|
50
|
|
|
|
12
|
my $nl = $#l1; $nl = $#l2 if ($#l2 > $nl); |
|
9
|
|
|
|
|
22
|
|
136
|
9
|
|
|
|
|
25
|
for (my $l=0; $l<=$nl; $l++) { |
137
|
76
|
50
|
50
|
|
|
327
|
if (($l1[$l]||"") ne ($l2[$l]||"")) { |
|
|
|
50
|
|
|
|
|
138
|
76
|
50
|
|
|
|
135
|
$diffs .= "- ".$l1[$l]."\n" if defined $l1[$l]; |
139
|
76
|
50
|
|
|
|
278
|
$diffs .= "+ ".$l2[$l]."\n" if defined $l2[$l]; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
} |
142
|
9
|
|
|
|
|
33
|
return $diffs; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
4
|
50
|
|
4
|
|
370818
|
our $_CloseUnlink; END { unlink($_CloseUnlink) if $_CloseUnlink; } |
146
|
|
|
|
|
|
|
sub _close_change_diff { |
147
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
148
|
|
|
|
|
|
|
# Are there differences the user cared about? |
149
|
0
|
0
|
|
|
|
0
|
return 1 if (!$self->{change_diff}); |
150
|
|
|
|
|
|
|
# Write to temp file |
151
|
0
|
|
0
|
|
|
0
|
my $tempname = (($ENV{TEMP}||$ENV{TMP}||"/tmp")."/.vreg_".$$); |
152
|
0
|
|
|
|
|
0
|
$_CloseUnlink = $tempname; |
153
|
0
|
0
|
|
|
|
0
|
my $fh = IO::File->new(">$tempname") or die "%Error: $! $tempname,"; |
154
|
0
|
0
|
|
|
|
0
|
$fh or die "%Error: $! $tempname\n"; |
155
|
0
|
|
|
|
|
0
|
print $fh @{$self->{text}}; |
|
0
|
|
|
|
|
0
|
|
156
|
0
|
|
|
|
|
0
|
$fh->close(); |
157
|
|
|
|
|
|
|
# Diff it |
158
|
0
|
|
|
|
|
0
|
system ($self->{change_diff}, $self->{filename}, $tempname); |
159
|
0
|
|
|
|
|
0
|
my $status = $?; |
160
|
|
|
|
|
|
|
# Cleanup |
161
|
0
|
|
|
|
|
0
|
unlink ($tempname); $_CloseUnlink=undef; |
|
0
|
|
|
|
|
0
|
|
162
|
0
|
|
|
|
|
0
|
return ($status != 0); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
###################################################################### |
166
|
|
|
|
|
|
|
#### Accessors |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub language { |
169
|
18
|
|
|
18
|
1
|
77
|
my $self = shift; |
170
|
18
|
|
|
|
|
1341
|
return $self->{language}; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub is_keyword { |
174
|
32
|
|
|
32
|
0
|
47
|
my $sym = shift; |
175
|
32
|
|
33
|
|
|
63
|
return (SystemC::Vregs::Language::C::is_keyword($sym) && "C" |
176
|
|
|
|
|
|
|
|| SystemC::Vregs::Language::CPP::is_keyword($sym) && "CPP" |
177
|
|
|
|
|
|
|
|| SystemC::Vregs::Language::Perl::is_keyword($sym) && "Perl" |
178
|
|
|
|
|
|
|
|| SystemC::Vregs::Language::Verilog::is_keyword($sym) && "Verilog" |
179
|
|
|
|
|
|
|
|| SystemC::Vregs::Language::Assembler::is_keyword($sym) && "Assembler" |
180
|
|
|
|
|
|
|
|| SystemC::Vregs::Language::Tcl::is_keyword($sym) && "Tcl" |
181
|
|
|
|
|
|
|
# XML keywords can't conflict as they all have <'s |
182
|
|
|
|
|
|
|
); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
###################################################################### |
186
|
|
|
|
|
|
|
#### Printing |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub push_text { |
189
|
219
|
|
|
219
|
0
|
273
|
my $self = shift; |
190
|
219
|
|
|
|
|
228
|
push @{$self->{text}}, @_; |
|
219
|
|
|
|
|
1415
|
|
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub print { |
194
|
66
|
|
|
66
|
1
|
99
|
my $self = shift; |
195
|
66
|
|
|
|
|
23275
|
$self->push_text(@_); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub printf { |
199
|
98
|
|
|
98
|
1
|
119
|
my $self = shift; |
200
|
98
|
|
|
|
|
116
|
my $fmt = shift; |
201
|
98
|
|
|
0
|
|
573
|
local $SIG{__WARN__} = sub { carp @_ }; |
|
0
|
|
|
|
|
0
|
|
202
|
98
|
|
|
|
|
300
|
my $text = sprintf ($fmt, @_); |
203
|
98
|
|
|
|
|
257
|
$self->print($text); |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub push_close_text { |
207
|
8
|
|
|
8
|
0
|
11
|
my $self = shift; |
208
|
8
|
|
|
|
|
22
|
push @{$self->{close_text}}, @_; |
|
8
|
|
|
|
|
42
|
|
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub print_at_close { |
212
|
7
|
|
|
7
|
0
|
12
|
my $self = shift; |
213
|
7
|
|
|
|
|
43
|
$self->push_close_text(@_); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub printf_at_close { |
217
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
218
|
1
|
|
|
|
|
2
|
my $fmt = shift; |
219
|
1
|
|
|
|
|
2
|
push @{$self->{close_text}}, sprintf ($fmt, @_); |
|
1
|
|
|
|
|
7
|
|
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub comment { |
223
|
12
|
50
|
33
|
12
|
1
|
53
|
my $self = shift; ($self && ref($self)) or croak 'Not a hash reference'; |
|
12
|
|
|
|
|
64
|
|
224
|
12
|
|
|
|
|
31
|
my $strg = join ('', @_); |
225
|
|
|
|
|
|
|
# Assume C++ style commenting |
226
|
12
|
|
|
|
|
60
|
$strg =~ s%\n(?!$)% */\n/*%sg; |
227
|
12
|
50
|
|
|
|
59
|
if ($strg =~ s/\n$//) { |
228
|
12
|
|
|
|
|
52
|
$self->print("/* $strg */\n"); |
229
|
|
|
|
|
|
|
} else { |
230
|
0
|
|
|
|
|
0
|
$self->print("/* $strg */"); |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub comment_pre { |
235
|
0
|
0
|
0
|
0
|
1
|
0
|
my $self = shift; ($self && ref($self)) or croak 'Not a hash reference'; |
|
0
|
|
|
|
|
0
|
|
236
|
0
|
|
|
|
|
0
|
$self->comment(@_); |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub comment_post { |
240
|
4
|
50
|
33
|
4
|
1
|
5
|
my $self = shift; ($self && ref($self)) or croak 'Not a hash reference'; |
|
4
|
|
|
|
|
24
|
|
241
|
4
|
|
|
|
|
10
|
$self->comment(@_); |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub define { |
245
|
6
|
50
|
33
|
6
|
0
|
55
|
my $self = shift; ($self && ref($self)) or croak 'Not a hash reference'; |
|
6
|
|
|
|
|
30
|
|
246
|
6
|
|
|
|
|
8
|
my $def = shift; |
247
|
6
|
|
|
|
|
8
|
my $val = shift; |
248
|
6
|
|
|
|
|
8
|
my $cmt = shift; |
249
|
|
|
|
|
|
|
# Assume C++ define |
250
|
6
|
50
|
|
|
|
14
|
my $len = ((length($val)> 16) ? 29 : 16); |
251
|
6
|
50
|
|
|
|
13
|
if ($cmt) { |
252
|
6
|
|
|
|
|
48
|
$self->printf ("#define\t%-26s\t%${len}s\t", $def, $val); |
253
|
6
|
|
|
|
|
32
|
$self->comment_post ($cmt,"\n"); |
254
|
|
|
|
|
|
|
} else { |
255
|
0
|
|
|
|
|
0
|
$self->printf ("#define\t%-26s\t%${len}s\n", $def, $val); |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
sub preproc_char { |
260
|
21
|
|
|
21
|
0
|
123
|
return '#'; |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
sub preproc { |
264
|
17
|
50
|
33
|
17
|
1
|
26
|
my $self = shift; ($self && ref($self)) or croak 'Not a hash reference'; |
|
17
|
|
|
|
|
111
|
|
265
|
17
|
|
|
|
|
69
|
$self->print($self->preproc_char(), @_); |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
sub include_guard { |
269
|
8
|
50
|
33
|
8
|
1
|
69
|
my $self = shift; ($self && ref($self)) or croak 'Not a hash reference'; |
|
8
|
|
|
|
|
55
|
|
270
|
8
|
|
|
|
|
32
|
my $cmt = "_".uc $self->{modulename}."_"; |
271
|
8
|
100
|
|
|
|
25
|
if ($self->{language} eq 'Verilog') { |
272
|
1
|
|
|
|
|
14
|
$self->preproc ("ifdef $cmt\n"); |
273
|
1
|
|
|
|
|
4
|
$self->preproc ("else\n"); # Verilog doesn't support ifndef |
274
|
|
|
|
|
|
|
} else { |
275
|
7
|
|
|
|
|
53
|
$self->preproc ("ifndef $cmt\n"); |
276
|
|
|
|
|
|
|
} |
277
|
8
|
|
|
|
|
37
|
$self->preproc ("define $cmt 1\n"); |
278
|
|
|
|
|
|
|
|
279
|
8
|
|
|
|
|
21
|
$self->print_at_close("\n", $self->preproc_char(), "endif /*$cmt*/\n"); |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
sub sprint_hex_value { |
283
|
0
|
|
|
0
|
1
|
0
|
my ($self,$value,$bits,$force_ull) = @_; |
284
|
0
|
0
|
|
|
|
0
|
if ($bits>32) { |
285
|
0
|
0
|
|
|
|
0
|
if ($force_ull) { |
286
|
0
|
|
|
|
|
0
|
return "0x".$value . "ULL"; |
287
|
|
|
|
|
|
|
} else { |
288
|
0
|
|
|
|
|
0
|
return "VREGS_ULL(0x".$value . ")"; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
} else { |
291
|
0
|
|
|
|
|
0
|
return "0x".$value; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
sub sprint_hex_value_add0 { |
296
|
0
|
|
|
0
|
0
|
0
|
my ($self,$valuestr,$bits) = @_; |
297
|
|
|
|
|
|
|
# Print the hex number, adding leading 0s to make it the proper width |
298
|
0
|
|
|
|
|
0
|
$valuestr = "0".$valuestr; # Force conversion to string in case is Bit::Vector |
299
|
0
|
|
|
|
|
0
|
$valuestr=~ s/^0+([0-9a-f])/$1/i; |
300
|
0
|
|
|
|
|
0
|
my $add = int(($bits+3)/4) - length($valuestr); |
301
|
0
|
0
|
|
|
|
0
|
$valuestr = "0"x$add . $valuestr if $add>=1; |
302
|
|
|
|
|
|
|
#print "ADD $valuestr $add ".("0"x$add)."\n" if $SystemC::Vregs::Debug; |
303
|
0
|
|
|
|
|
0
|
return $self->sprint_hex_value ($valuestr, $bits); |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub sprint_hex_value_drop0 { |
307
|
0
|
|
|
0
|
0
|
0
|
my ($self,$valuestr,$bits) = @_; |
308
|
0
|
|
|
|
|
0
|
$valuestr = "0".$valuestr; # Force conversion to string in case is Bit::Vector |
309
|
0
|
|
|
|
|
0
|
$valuestr=~ s/^0+(\d)/$1/; |
310
|
0
|
|
|
|
|
0
|
return $self->sprint_hex_value ($valuestr, $bits); |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
###################################################################### |
314
|
|
|
|
|
|
|
###################################################################### |
315
|
|
|
|
|
|
|
###################################################################### |
316
|
|
|
|
|
|
|
#### C |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
package SystemC::Vregs::Language::C; |
319
|
4
|
|
|
4
|
|
31
|
use Carp; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
267
|
|
320
|
4
|
|
|
4
|
|
104
|
use vars qw(%Keywords); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
168
|
|
321
|
|
|
|
|
|
|
#Made by super::New: use base qw(SystemC::Vregs::Language); |
322
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1595
|
|
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
#Includes some stdlib functions at the end. |
325
|
|
|
|
|
|
|
foreach my $kwd (qw( asm auto break case catch cdecl char class const |
326
|
|
|
|
|
|
|
continue default delete do double else enum extern far |
327
|
|
|
|
|
|
|
float for friend goto huge if inline int interrupt |
328
|
|
|
|
|
|
|
long near new operator pascal private protected public |
329
|
|
|
|
|
|
|
register short signed sizeof static struct switch |
330
|
|
|
|
|
|
|
template this throw try typedef union unsigned virtual |
331
|
|
|
|
|
|
|
void volatile while |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
bool false NULL string true |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
sensitive sensitive_pos sensitive_neg |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
abort)) |
338
|
|
|
|
|
|
|
{ $Keywords{$kwd} = 1; } |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
sub is_keyword { |
341
|
64
|
|
|
64
|
|
352
|
return $Keywords{$_[0]}; |
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
sub comment_pre { |
345
|
4
|
50
|
33
|
4
|
|
5
|
my $self = shift; ($self && ref($self)) or croak 'Not a hash reference'; |
|
4
|
|
|
|
|
22
|
|
346
|
4
|
|
|
|
|
9
|
my $strg = join ('', @_); |
347
|
4
|
|
|
|
|
9
|
$strg =~ s!\n(.)!\n/// $1!og; |
348
|
4
|
|
|
|
|
6
|
$strg =~ s!\n\n!\n///\n!og; |
349
|
4
|
100
|
|
|
|
21
|
$strg = " ".$strg unless $strg =~ /^\s/; |
350
|
4
|
|
|
|
|
15
|
$self->print("///$strg"); |
351
|
|
|
|
|
|
|
} |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
sub comment_post { |
354
|
19
|
50
|
33
|
19
|
|
23
|
my $self = shift; ($self && ref($self)) or croak 'Not a hash reference'; |
|
19
|
|
|
|
|
99
|
|
355
|
19
|
|
|
|
|
42
|
my $strg = join ('', @_); |
356
|
19
|
|
|
|
|
31
|
$strg =~ s!\n(.)!\n///< $1!og; |
357
|
19
|
|
|
|
|
69
|
$self->print("///< $strg"); |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
###################################################################### |
361
|
|
|
|
|
|
|
###################################################################### |
362
|
|
|
|
|
|
|
###################################################################### |
363
|
|
|
|
|
|
|
#### CPP |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
package SystemC::Vregs::Language::CPP; |
366
|
4
|
|
|
4
|
|
22
|
use Carp; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
259
|
|
367
|
4
|
|
|
4
|
|
21
|
use vars qw(%Keywords); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
148
|
|
368
|
4
|
|
|
4
|
|
32
|
use base qw(SystemC::Vregs::Language::C); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
2578
|
|
369
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
286
|
|
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
sub is_keyword { |
372
|
32
|
|
|
32
|
|
62
|
return SystemC::Vregs::Language::C::is_keyword(@_); |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
###################################################################### |
376
|
|
|
|
|
|
|
###################################################################### |
377
|
|
|
|
|
|
|
###################################################################### |
378
|
|
|
|
|
|
|
#### Lisp |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
package SystemC::Vregs::Language::Lisp; |
381
|
4
|
|
|
4
|
|
23
|
use base qw(SystemC::Vregs::Language); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
293
|
|
382
|
4
|
|
|
4
|
|
19
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
211
|
|
383
|
4
|
|
|
4
|
|
18
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1274
|
|
384
|
|
|
|
|
|
|
|
385
|
0
|
|
|
0
|
|
0
|
sub is_keyword { return undef;} |
386
|
1
|
|
|
1
|
|
7
|
sub include_guard {} |
387
|
|
|
|
|
|
|
|
388
|
0
|
|
|
0
|
|
0
|
sub comment_start_char { return ";;"; } |
389
|
0
|
|
|
0
|
|
0
|
sub comment_end_char { return ""; } |
390
|
|
|
|
|
|
|
sub comment { |
391
|
2
|
|
|
2
|
|
8
|
my $self = shift; |
392
|
2
|
|
|
|
|
4
|
my $strg = join ('', @_); |
393
|
2
|
|
|
|
|
13
|
$strg =~ s!\n(.)!\n;;$1!g; |
394
|
2
|
|
|
|
|
4
|
$strg =~ s!\n\n!\n;;\n!og; |
395
|
2
|
|
|
|
|
11
|
$self->print(";;".$strg); |
396
|
|
|
|
|
|
|
} |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
sub define { |
399
|
1
|
50
|
33
|
1
|
|
4
|
my $self = shift; ($self && ref($self)) or croak 'Not a hash reference'; |
|
1
|
|
|
|
|
12
|
|
400
|
1
|
|
|
|
|
2
|
my $def = shift; |
401
|
1
|
|
|
|
|
2
|
my $val = shift; |
402
|
1
|
|
|
|
|
1
|
my $cmt = shift; |
403
|
1
|
50
|
|
|
|
8
|
if ($cmt) { |
404
|
1
|
|
|
|
|
8
|
$self->printf ("(defconstant %-26s\t%16s) ;; %s\n", $def, $val, $cmt); |
405
|
|
|
|
|
|
|
} else { |
406
|
0
|
|
|
|
|
0
|
$self->printf ("(defconstant %-26s\t%16s)\n", $def, $val); |
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
} |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
sub sprint_hex_value { |
411
|
0
|
|
|
0
|
|
0
|
my ($self,$value,$bits) = @_; |
412
|
0
|
|
|
|
|
0
|
return "#x".$value; |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
###################################################################### |
416
|
|
|
|
|
|
|
###################################################################### |
417
|
|
|
|
|
|
|
###################################################################### |
418
|
|
|
|
|
|
|
#### Perl |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
package SystemC::Vregs::Language::Perl; |
421
|
|
|
|
|
|
|
#Made by super::New: use base qw(SystemC::Vregs::Language); |
422
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1500
|
|
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
sub is_keyword { |
425
|
32
|
|
|
32
|
|
42
|
my $sym = shift; |
426
|
32
|
|
|
|
|
147
|
return undef; |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
sub include_guard { |
430
|
1
|
|
|
1
|
|
7
|
my $self = shift; |
431
|
|
|
|
|
|
|
# Presumably is a module, so doesn't matter |
432
|
1
|
|
|
|
|
9
|
$self->printf_at_close ("1;\n"); # Good idea to have true exit status though. |
433
|
|
|
|
|
|
|
} |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
sub comment_start_char { |
436
|
0
|
|
|
0
|
|
0
|
return "#"; |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
sub comment_end_char { |
439
|
0
|
|
|
0
|
|
0
|
return ""; |
440
|
|
|
|
|
|
|
} |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
sub comment { |
443
|
2
|
|
|
2
|
|
9
|
my $self = shift; |
444
|
2
|
|
|
|
|
5
|
my $strg = join ('', @_); |
445
|
2
|
|
|
|
|
15
|
$strg =~ s!\n(.)!\n#$1!g; |
446
|
2
|
|
|
|
|
5
|
$strg =~ s!\n\n!\n#\n!og; |
447
|
2
|
|
|
|
|
11
|
$self->print("#".$strg); |
448
|
|
|
|
|
|
|
} |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
sub preproc { |
451
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
452
|
0
|
|
|
|
|
0
|
warn 'No preprocessor for Perl Language'; |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
sub define { |
456
|
1
|
|
|
1
|
|
6
|
my $self = shift; |
457
|
1
|
50
|
|
|
|
4
|
if ($_[2]) { |
458
|
1
|
|
|
|
|
9
|
$self->printf ("use constant %-26s\t=> %16s;\t# %s\n", @_); |
459
|
|
|
|
|
|
|
} else { |
460
|
0
|
|
|
|
|
0
|
$self->printf ("use constant %-26s\t=> %16s;\n", @_); |
461
|
|
|
|
|
|
|
} |
462
|
|
|
|
|
|
|
} |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
sub sprint_hex_value { |
465
|
0
|
|
|
0
|
|
0
|
my ($self,$value,$bits) = @_; |
466
|
0
|
0
|
|
|
|
0
|
if ($bits>32) { |
467
|
|
|
|
|
|
|
# return "Bit::Vector::new_hex(".$bits.",0x".$value.")"; |
468
|
0
|
|
|
|
|
0
|
return "0x".$value; |
469
|
|
|
|
|
|
|
} else { |
470
|
0
|
|
|
|
|
0
|
return "0x".$value; |
471
|
|
|
|
|
|
|
} |
472
|
|
|
|
|
|
|
} |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
###################################################################### |
475
|
|
|
|
|
|
|
###################################################################### |
476
|
|
|
|
|
|
|
###################################################################### |
477
|
|
|
|
|
|
|
#### Verilog |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
package SystemC::Vregs::Language::Verilog; |
480
|
|
|
|
|
|
|
#Made by super::New: use base qw(SystemC::Vregs::Language); |
481
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
115
|
|
482
|
|
|
|
|
|
|
|
483
|
4
|
|
|
4
|
|
1235
|
use Verilog::Language; |
|
4
|
|
|
|
|
6642
|
|
|
4
|
|
|
|
|
796
|
|
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
sub is_keyword { |
486
|
32
|
|
|
32
|
|
46
|
my $sym = shift; |
487
|
32
|
|
|
|
|
94
|
return (Verilog::Language::is_keyword($sym)); |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
sub preproc_char { |
491
|
4
|
|
|
4
|
|
18
|
return "`"; |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
sub define { |
495
|
1
|
|
|
1
|
|
6
|
my $self = shift; |
496
|
1
|
50
|
|
|
|
4
|
if ($_[2]) { |
497
|
1
|
|
|
|
|
9
|
$self->printf ("`define\t%-26s\t%16s\t// %s\n", @_); |
498
|
|
|
|
|
|
|
} else { |
499
|
0
|
|
|
|
|
0
|
$self->printf ("`define\t%-26s\t%16s\n", @_); |
500
|
|
|
|
|
|
|
} |
501
|
|
|
|
|
|
|
} |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
sub sprint_hex_value { |
504
|
0
|
|
|
0
|
|
0
|
my ($self,$value,$bits) = @_; |
505
|
0
|
|
|
|
|
0
|
return "${bits}'h".$value; |
506
|
|
|
|
|
|
|
} |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
###################################################################### |
509
|
|
|
|
|
|
|
###################################################################### |
510
|
|
|
|
|
|
|
###################################################################### |
511
|
|
|
|
|
|
|
#### Assembler |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
package SystemC::Vregs::Language::Assembler; |
514
|
|
|
|
|
|
|
#Made by super::New: use base qw(SystemC::Vregs::Language); |
515
|
4
|
|
|
4
|
|
34
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
678
|
|
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
sub is_keyword { |
518
|
32
|
|
|
32
|
|
236
|
my $sym = shift; |
519
|
32
|
|
|
|
|
143
|
return undef; |
520
|
|
|
|
|
|
|
} |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
sub comment_start_char { |
523
|
0
|
|
|
0
|
|
0
|
return ";"; |
524
|
|
|
|
|
|
|
} |
525
|
|
|
|
|
|
|
sub comment_end_char { |
526
|
0
|
|
|
0
|
|
0
|
return ""; |
527
|
|
|
|
|
|
|
} |
528
|
|
|
|
|
|
|
sub comment { |
529
|
3
|
|
|
3
|
|
10
|
my $self = shift; |
530
|
3
|
|
|
|
|
7
|
my $strg = join ('', @_); |
531
|
3
|
|
|
|
|
15
|
$strg =~ s!\n(.)!\n;$1!g; |
532
|
3
|
|
|
|
|
5
|
$strg =~ s!\n\n!\n;\n!og; |
533
|
3
|
|
|
|
|
11
|
$self->print (";".$strg); |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
###################################################################### |
537
|
|
|
|
|
|
|
###################################################################### |
538
|
|
|
|
|
|
|
###################################################################### |
539
|
|
|
|
|
|
|
#### Gas Assembler |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
package SystemC::Vregs::Language::Gas; |
542
|
4
|
|
|
4
|
|
27
|
use base qw(SystemC::Vregs::Language); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
357
|
|
543
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
399
|
|
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
sub is_keyword { |
546
|
0
|
|
|
0
|
|
0
|
my $sym = shift; |
547
|
0
|
|
|
|
|
0
|
return undef; |
548
|
|
|
|
|
|
|
} |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
sub sprint_hex_value { |
551
|
0
|
|
|
0
|
|
0
|
my ($self,$value,$bits) = @_; |
552
|
|
|
|
|
|
|
# Never a ULL postfix |
553
|
0
|
|
|
|
|
0
|
return "0x".$value; |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
###################################################################### |
557
|
|
|
|
|
|
|
###################################################################### |
558
|
|
|
|
|
|
|
###################################################################### |
559
|
|
|
|
|
|
|
#### Tcl |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
package SystemC::Vregs::Language::Tcl; |
562
|
4
|
|
|
4
|
|
20
|
use base qw(SystemC::Vregs::Language); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
294
|
|
563
|
4
|
|
|
4
|
|
25
|
use strict; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
733
|
|
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
sub is_keyword { |
566
|
32
|
|
|
32
|
|
38
|
my $sym = shift; |
567
|
32
|
|
|
|
|
212
|
return undef; |
568
|
|
|
|
|
|
|
} |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
sub comment_start_char { |
571
|
0
|
|
|
0
|
|
0
|
return "\#"; |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
sub comment_end_char { |
574
|
0
|
|
|
0
|
|
0
|
return ""; |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
sub comment { |
577
|
3
|
|
|
3
|
|
8
|
my $self = shift; |
578
|
3
|
|
|
|
|
8
|
my $strg = join ('', @_); |
579
|
3
|
|
|
|
|
12
|
$strg =~ s!\n(.)!\n#$1!g; |
580
|
3
|
|
|
|
|
5
|
$strg =~ s!\n\n!\n#\n!og; |
581
|
3
|
|
|
|
|
9
|
$self->print ("\#".$strg); |
582
|
|
|
|
|
|
|
} |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
###################################################################### |
585
|
|
|
|
|
|
|
###################################################################### |
586
|
|
|
|
|
|
|
###################################################################### |
587
|
|
|
|
|
|
|
#### XML |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
package SystemC::Vregs::Language::XML; |
590
|
4
|
|
|
4
|
|
31
|
use base qw(SystemC::Vregs::Language); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
266
|
|
591
|
4
|
|
|
4
|
|
18
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1159
|
|
592
|
|
|
|
|
|
|
|
593
|
0
|
|
|
0
|
|
0
|
sub is_keyword { return undef;} |
594
|
0
|
|
|
0
|
|
0
|
sub comment_start_char { return ""; } |
596
|
|
|
|
|
|
|
sub comment { |
597
|
3
|
|
|
3
|
|
10
|
my $self = shift; |
598
|
3
|
|
|
|
|
7
|
my $strg = join ('', @_); |
599
|
3
|
|
|
|
|
5
|
$strg =~ s%--+%-%sg; # Drop --'s, they end comments |
600
|
3
|
|
|
|
|
5
|
$strg =~ s%[<>]%_%sg; # Replace special <>'s |
601
|
3
|
|
|
|
|
11
|
$strg =~ s%\n(?!$)% -->\n\n"); |
604
|
|
|
|
|
|
|
} else { |
605
|
0
|
|
|
|
|
|
$self->print(""); |
606
|
|
|
|
|
|
|
} |
607
|
|
|
|
|
|
|
} |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
###################################################################### |
610
|
|
|
|
|
|
|
package SystemC::Vregs::Language; |
611
|
|
|
|
|
|
|
#### Package return |
612
|
|
|
|
|
|
|
1; |
613
|
|
|
|
|
|
|
=pod |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
=head1 NAME |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
SystemC::Vregs::Language - File processing for various Languages |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=head1 SYNOPSIS |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
use SystemC::Vregs::Language; |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
my $fh = SystemC::Vregs::Language->new (filename=>"foo.c", |
624
|
|
|
|
|
|
|
language=>'C',); |
625
|
|
|
|
|
|
|
$fh->comment ("This file is generated automatically\n"); |
626
|
|
|
|
|
|
|
$fh->define ("TRUE",1, "Set true"); |
627
|
|
|
|
|
|
|
$fh->print ("void main();\n"); |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
=head1 DESCRIPTION |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
This package creates a file handle with language specific semantics. This |
632
|
|
|
|
|
|
|
allows similar operators to be called, such as I, for many |
633
|
|
|
|
|
|
|
different file formats. |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
The output data is stored in an array and dumped when the file is complete. |
636
|
|
|
|
|
|
|
This allows the file to only be written if the data changes, to reduce |
637
|
|
|
|
|
|
|
makefile rebuilding. |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
=head1 FIELDS |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
These fields may be specified with the new() function. |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
=over 4 |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
=item filename |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
The filename to write the data to. |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
=item keep_timestamp |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
If true, the file will only be written if the data being written differs |
652
|
|
|
|
|
|
|
from the present file contents. |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
=item language |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
The language for the file. May be C, Perl, Assembler, TCL, or Verilog. A new |
657
|
|
|
|
|
|
|
language Foo may be defined by making a SystemC::Vregs::Language::Foo class |
658
|
|
|
|
|
|
|
which is an @ISA of SystemC::Vregs::Language. |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
=back |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
=head1 ACCESSORS |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=over 4 |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
=item language |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
Returns the type of file, for example 'C'. |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
=back |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
=head1 OUTPUT FUNCTIONS |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
=over 4 |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
=item comment |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
Output a string with the appropriate comment delimiters. |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
=item comment_pre |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
Output a comment and Doxygen document before-the-fact. |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
=item comment_post |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
Output a comment and Doxygen document after-the-fact. |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=item include_guard |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
Output a standard #ifndef around the file to prevent multiple inclusion. |
691
|
|
|
|
|
|
|
Closing the file will automatically add the #endif |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
=item sprint_hex_value |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
Return a string representing the value as a hex number. Second argument is |
696
|
|
|
|
|
|
|
number of bits. |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
=item preproc |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
Output a preprocessor directive. |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
=item print |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
Output plain text. This function is called by all other functions. You |
705
|
|
|
|
|
|
|
will probably want to make a inherited class and override this method. |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
=item printf |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
Output printf text. |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
=back |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
=head1 DISTRIBUTION |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
Vregs is part of the L free Verilog software tool |
716
|
|
|
|
|
|
|
suite. The latest version is available from CPAN and from |
717
|
|
|
|
|
|
|
L. /www.veripool.org/>. |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
Copyright 2001-2010 by Wilson Snyder. This package is free software; you |
720
|
|
|
|
|
|
|
can redistribute it and/or modify it under the terms of either the GNU |
721
|
|
|
|
|
|
|
Lesser General Public License Version 3 or the Perl Artistic License Version 2.0. |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
=head1 AUTHORS |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
Wilson Snyder |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
=head1 SEE ALSO |
728
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
L, L |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
=cut |