line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# See copyright, etc in below POD section. |
2
|
|
|
|
|
|
|
###################################################################### |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package SystemC::Vregs::Number; |
5
|
4
|
|
|
4
|
|
26514
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
125
|
|
6
|
4
|
|
|
4
|
|
22
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
256
|
|
7
|
4
|
|
|
4
|
|
18
|
use vars qw($VERSION); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
186
|
|
8
|
4
|
|
|
4
|
|
21
|
use base qw(Bit::Vector); # For now, let Bit::Vector do all the work |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
3383
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '1.470'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
###################################################################### |
13
|
|
|
|
|
|
|
###################################################################### |
14
|
|
|
|
|
|
|
###################################################################### |
15
|
|
|
|
|
|
|
###################################################################### |
16
|
|
|
|
|
|
|
#### Creators |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub min { |
19
|
0
|
|
|
0
|
0
|
0
|
my $veca = shift; |
20
|
0
|
|
|
|
|
0
|
my $vecb = shift; |
21
|
0
|
0
|
|
|
|
0
|
return $veca if !defined $vecb; |
22
|
0
|
0
|
|
|
|
0
|
return $vecb if !defined $veca; |
23
|
0
|
0
|
|
|
|
0
|
if ($veca->Lexicompare($vecb) < 0) {return $veca;} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
24
|
|
|
|
|
|
|
else {return $vecb;} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
sub max { |
27
|
0
|
|
|
0
|
0
|
0
|
my $veca = shift; |
28
|
0
|
|
|
|
|
0
|
my $vecb = shift; |
29
|
0
|
0
|
|
|
|
0
|
return $veca if !defined $vecb; |
30
|
0
|
0
|
|
|
|
0
|
return $vecb if !defined $veca; |
31
|
0
|
0
|
|
|
|
0
|
if ($veca->Lexicompare($vecb) > 0) {return $veca;} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
32
|
|
|
|
|
|
|
else {return $vecb;} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub text_to_vec { |
36
|
15
|
|
|
15
|
0
|
670
|
my $default_width = shift; # Width if not specified, undef=must be sized |
37
|
15
|
|
|
|
|
19
|
my $text = shift; |
38
|
|
|
|
|
|
|
# Return bitvector structure, or undef if it isn't a nicely formed number |
39
|
|
|
|
|
|
|
# We allow C format (10, 0x10, 0x10_11) |
40
|
|
|
|
|
|
|
# And Verilog format (32'd20, 32'h2f, 32'b1011) |
41
|
15
|
|
|
|
|
30
|
$text =~ s/_//g; |
42
|
15
|
|
|
|
|
28
|
$text =~ s/\s+$//; |
43
|
15
|
|
|
|
|
19
|
my $width = $default_width; |
44
|
15
|
100
|
|
|
|
41
|
if ($text =~ s/^(\d+)\'/\'/) { |
45
|
2
|
|
|
|
|
3
|
$width = $1; |
46
|
|
|
|
|
|
|
} |
47
|
15
|
100
|
|
|
|
103
|
if ($text =~ /^(\'d|)(\d+)$/i) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
48
|
5
|
50
|
|
|
|
19
|
return undef if !$width; |
49
|
5
|
|
|
|
|
50
|
return SystemC::Vregs::Number->new_Dec($width, $2); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif ($text =~ /^(0x|\'[hx])([a-z0-9]+)$/i) { |
52
|
9
|
50
|
|
|
|
21
|
return undef if !$width; |
53
|
9
|
|
|
|
|
89
|
return SystemC::Vregs::Number->new_Hex($width, $2); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif ($text =~ /^\'b([0-1]+)$/i) { |
56
|
1
|
50
|
|
|
|
3
|
return undef if !$width; |
57
|
1
|
|
|
|
|
9
|
return SystemC::Vregs::Number->new_Bin($width, $1); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return undef; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
###################################################################### |
64
|
|
|
|
|
|
|
#### Accessors |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
###################################################################### |
67
|
|
|
|
|
|
|
#### Package return |
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |