line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VIC::PIC::Base; |
2
|
31
|
|
|
31
|
|
13517
|
use strict; |
|
31
|
|
|
|
|
58
|
|
|
31
|
|
|
|
|
790
|
|
3
|
31
|
|
|
31
|
|
136
|
use warnings; |
|
31
|
|
|
|
|
51
|
|
|
31
|
|
|
|
|
1326
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.32'; |
6
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
7
|
|
|
|
|
|
|
|
8
|
31
|
|
|
31
|
|
155
|
use Carp; |
|
31
|
|
|
|
|
60
|
|
|
31
|
|
|
|
|
1531
|
|
9
|
31
|
|
|
31
|
|
194
|
use Moo; |
|
31
|
|
|
|
|
85
|
|
|
31
|
|
|
|
|
189
|
|
10
|
31
|
|
|
31
|
|
19211
|
use VIC::PIC::Roles; # load all the roles |
|
31
|
|
|
|
|
76
|
|
|
31
|
|
|
|
|
931
|
|
11
|
31
|
|
|
31
|
|
13537
|
use namespace::clean; |
|
31
|
|
|
|
|
297230
|
|
|
31
|
|
|
|
|
157
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub doesrole { |
14
|
1512
|
|
|
1512
|
0
|
214519
|
my $a = $_[0]->does('VIC::PIC::Roles::' . $_[1]); |
15
|
1512
|
50
|
|
|
|
20177
|
unless ($_[1]) { # no logging |
16
|
0
|
0
|
|
|
|
0
|
carp ref($_[0]) . " does not do role $_[1]" unless $a; |
17
|
|
|
|
|
|
|
} |
18
|
1512
|
|
|
|
|
3424
|
return $a; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub doesroles { |
22
|
240
|
|
|
240
|
0
|
49335
|
my $self = shift; |
23
|
240
|
|
|
|
|
431
|
foreach (@_) { |
24
|
600
|
100
|
|
|
|
1164
|
return unless $self->doesrole($_); |
25
|
|
|
|
|
|
|
} |
26
|
228
|
|
|
|
|
775
|
return 1; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has chip_config => (is => 'ro', default => sub { {} }); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub print_pinout { |
32
|
0
|
|
|
0
|
0
|
|
my ($self, $fh) = @_; |
33
|
0
|
0
|
|
|
|
|
$fh = *STDOUT unless $fh; |
34
|
0
|
0
|
|
|
|
|
return unless $self->doesroles(qw(CodeGen Chip)); |
35
|
0
|
|
|
|
|
|
my $pinref = $self->pins; |
36
|
0
|
|
|
|
|
|
my @pinnames = (); |
37
|
0
|
|
|
|
|
|
my $maxlen = 0; |
38
|
0
|
|
|
|
|
|
foreach (sort(keys %$pinref)) { |
39
|
0
|
0
|
|
|
|
|
next unless $_ =~ /^\d+$/; |
40
|
0
|
|
|
|
|
|
my $aa = $pinref->{$_}; |
41
|
0
|
0
|
|
|
|
|
my $str = join('/', @{$aa}) if ref $aa eq 'ARRAY'; |
|
0
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
$str = $aa unless ref $aa; |
43
|
0
|
|
|
|
|
|
$pinnames[$_ - 1] = $str; |
44
|
0
|
0
|
|
|
|
|
$maxlen = length($str) if $maxlen < length($str); |
45
|
|
|
|
|
|
|
} |
46
|
0
|
|
|
|
|
|
my $pdip = scalar(@pinnames) / 2; |
47
|
0
|
|
|
|
|
|
my $start = 5 + $maxlen; |
48
|
0
|
|
|
|
|
|
my $chip = uc($self->type); |
49
|
0
|
|
|
|
|
|
my $w = 14; |
50
|
0
|
|
|
|
|
|
my $notch = '__'; |
51
|
0
|
|
|
|
|
|
my $w0 = ($w - length($notch)) / 2; |
52
|
0
|
|
|
|
|
|
print $fh "\n\n"; |
53
|
0
|
|
|
|
|
|
print $fh ' ' x $start, '+', '=' x $w0, $notch, '=' x $w0, '+', "\n"; |
54
|
0
|
|
|
|
|
|
my $pinline = '---'; |
55
|
0
|
|
|
|
|
|
for (my $i = 0; $i < $pdip; ++$i) { |
56
|
0
|
|
|
|
|
|
my $s1 = $pinnames[$i]; |
57
|
0
|
|
|
|
|
|
my $s2 = $pinnames[2 * $pdip - $i - 1]; |
58
|
0
|
|
|
|
|
|
my $l1 = $start - 1 - length($pinline) - length($s1); |
59
|
0
|
|
|
|
|
|
my $p1 = sprintf "%d", ($i + 1); |
60
|
0
|
|
|
|
|
|
my $p2 = sprintf "%d", (2 * $pdip - $i); |
61
|
0
|
|
|
|
|
|
my $w1 = $w - length($p1) - length($p2); |
62
|
0
|
|
|
|
|
|
print $fh ' ' x $l1, $s1, ' ', $pinline, '|', $p1, ' ' x $w1, $p2, '|', $pinline, ' ', $s2, "\n"; |
63
|
0
|
|
|
|
|
|
print $fh ' ' x $start, '|', ' ' x $w, '|', "\n"; |
64
|
0
|
0
|
|
|
|
|
if (($i + 1) == int($pdip / 2)) { |
65
|
0
|
|
|
|
|
|
my $w2 = int(($w - length($chip)) / 2); |
66
|
0
|
|
|
|
|
|
my $w3 = $w - $w2 - length($chip); |
67
|
0
|
|
|
|
|
|
print $fh ' ' x $start, '|', ' ' x $w2, $chip, ' ' x $w3, '|', "\n"; |
68
|
0
|
|
|
|
|
|
print $fh ' ' x $start, '|', ' ' x $w, '|', "\n"; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
print $fh ' ' x $start, '+', '=' x $w, '+', "\n"; |
72
|
0
|
|
|
|
|
|
print $fh "\n\n"; |
73
|
0
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |