| 1 | package VIC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 33 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 33 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 33 | ▶ | use Env qw(@PATH); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 33 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 33 | ▶ | use File::Which qw(which); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 33 | ▶ | use Capture::Tiny ':all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 33 | ▶ | use VIC::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 33 | ▶ | use VIC::Grammar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 33 | ▶ | use VIC::Receiver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 33 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 33 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | compile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | assemble | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | simulate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | supported_chips | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | supported_simulators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | gpasm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | gplink | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | gputils | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | bindir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | is_chip_supported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | is_simulator_supported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | list_chip_features | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 33 | our $Debug = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 33 | our $Verbose = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 33 | our $Intermediate = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 33 | our $GPASM; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 33 | our $GPLINK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 33 | our $GPUTILSDIR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 33 | our $VERSION = '0.29'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 33 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | sub compile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 33 | ▶ | my ($input, $pic) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compile: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 33 | ▶ | die "No code given to compile\n" unless $input; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 33 | my $parser = VIC::Parser->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | grammar => VIC::Grammar->new, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | receiver => VIC::Receiver->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | pic_override => $pic, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | intermediate_inline => $Intermediate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | debug => $Debug, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | throw_on_error => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 33 | my $output = $parser->parse($input); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 31 | my $chip = $parser->receiver->current_chip(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 31 | my $sim = $parser->receiver->current_simulator(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 31 | ▶ | return wantarray ? ($output, $chip, $sim) : $output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | sub supported_chips { return VIC::Receiver::supported_chips(); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supported_chips: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | ▶ | sub supported_simulators { return VIC::Receiver::supported_simulators(); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supported_simulators: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 19 | ▶ | sub is_chip_supported { return VIC::Receiver::is_chip_supported(@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_chip_supported: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub is_simulator_supported { return VIC::Receiver::is_simulator_supported(@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_simulator_supported: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub list_chip_features { return VIC::Receiver::list_chip_features(@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_chip_features: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub print_pinout { return VIC::Receiver::print_pinout(@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_pinout: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | sub _load_gputils { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 21 | ▶ | my ($gpasm, $gplink, $bindir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_gputils: called CC=8 SCAR=26.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | my ($stdo, $stde) = capture { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 21 | ▶ | my $alien; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=40.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 21 | ▶ | eval q{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | require Alien::gputils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | $alien = Alien::gputils->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } or warn "Cannot find Alien::gputils. Ignoring\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 21 | ▶ | if ($alien) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | print "Looking for gpasm and gplink using Alien::gputils\n" if $Verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $gpasm = $alien->gpasm() if $alien->can('gpasm'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $gplink = $alien->gplink() if $alien->can('gplink'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | $bindir = $alien->bin_dir() if $alien->can('bin_dir'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 21 | ▶ | unless (defined $gpasm and defined $gplink) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $gpasm and defined $gplink
MC/DC0%0/2
defined $gpasm and defined $gplink
defined $gpasm
defined $gplink
Truth table33%1/3
A and B
A= defined $gpasmB= defined $gplink
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 21 | ▶ | print "Looking for gpasm and gplink in \$ENV{PATH}\n" if $Verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 21 | $gpasm = which('gpasm'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 21 | $gplink = which('gplink'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 21 | ▶ | unless (defined $bindir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 21 | ▶ | if ($gpasm) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my @dirs = File::Spec->splitpath($gpasm); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | pop @dirs if @dirs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | $bindir = File::Spec->catdir(@dirs) if @dirs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 21 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 21 | ▶ | if ($Verbose) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 18 | ▶ | print $stdo if $stdo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 18 | ▶ | print STDERR $stde if $stde; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 18 | ▶ | print "Using gpasm: $gpasm\n" if $gpasm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 18 | ▶ | print "Using gplink: $gplink\n" if $gplink; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 18 | ▶ | print "gputils installed in: $bindir\n" if $bindir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 21 | $GPASM = $gpasm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 21 | $GPLINK = $gplink; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 21 | $GPUTILSDIR = $bindir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 21 | ▶ | return wantarray ? ($gpasm, $gplink, $bindir) : [$gpasm, $gplink, $bindir]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | sub _load_simulator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my $simtype = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_simulator: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $simexe; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | die "Simulator type $simtype not supported yet\n" unless $simtype eq 'gpsim'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($^O =~ /mswin32/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | foreach (qw{PROGRAMFILES ProgramFiles PROGRAMFILES(X86) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ProgramFiles(X86) ProgamFileW6432 PROGRAMFILESW6432}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | next unless exists $ENV{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | my $dir = ($ENV{$_} =~ /\s+/) ? Win32::GetShortPathName($ENV{$_}) : $ENV{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | push @PATH, File::Spec->catdir($dir, $simtype, 'bin') if $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $simexe = which("$simtype.exe"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | $simexe = which($simtype) unless $simexe; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $simexe = which($simtype); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | print "$simtype found at $simexe\n" if ($Verbose and $simexe); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$VIC::Verbose and $simexe
MC/DC0%0/2
$VIC::Verbose and $simexe
$VIC::Verbose
$simexe
Truth table0%0/3
A and B
A= $VIC::VerboseB= $simexe
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | warn "$simtype not found\n" unless $simexe; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | return $simexe; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | sub gputils { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 19 | ▶ | return ($GPASM, $GPLINK, $GPUTILSDIR) if (defined $GPASM and defined $GPLINK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gputils: called CC=4 SCAR=17.9
Pod
undocumented
Branch: 1 branch
Condition33%2/6
defined $VIC::GPASM and defined $VIC::GPLINK and defined $VIC::GPUTILSDIR
defined $VIC::GPASM and defined $VIC::GPLINK
MC/DC0%0/3
defined $VIC::GPASM and defined $VIC::GPLINK and defined $VIC::GPUTILSDIR
defined $VIC::GPASM
defined $VIC::GPLINK
defined $VIC::GPUTILSDIR
Truth table25%1/4
A and B and C
A= defined $VIC::GPASMB= defined $VIC::GPLINKC= defined $VIC::GPUTILSDIR
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | and defined $GPUTILSDIR); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 19 | return &_load_gputils(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | sub gpasm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | ▶ | return $GPASM if defined $GPASM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gpasm: called CC=2 SCAR=7.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | my @out = &_load_gputils(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | return $out[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | sub gplink { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | ▶ | return $GPLINK if defined $GPLINK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gplink: called CC=2 SCAR=7.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | my @out = &_load_gputils(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | return $out[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | sub bindir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | return $GPUTILSDIR if defined $GPUTILSDIR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bindir: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my @out = &_load_gputils(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return $out[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | sub assemble($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | my ($chip, $output) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assemble: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | return unless defined $chip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | return unless defined $output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $hexfile = $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $objfile = $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $codfile = $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $stcfile = $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if ($output =~ /\.asm$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $hexfile =~ s/\.asm$/\.hex/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $objfile =~ s/\.asm$/\.o/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $codfile =~ s/\.asm$/\.cod/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $stcfile =~ s/\.asm$/\.stc/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $hexfile = $output . '.hex'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $objfile = $output . '.o'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $codfile = $output . '.hex'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $stcfile = $output . '.o'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my ($gpasm, $gplink, $bindir) = VIC::gputils(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | unless (defined $gpasm and defined $gplink and -e $gpasm and -e $gplink) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $gpasm and defined $gplink and -e $gpasm and -e $gplink
defined $gpasm and defined $gplink and -e $gpasm
defined $gpasm and defined $gplink
MC/DC0%0/4
defined $gpasm and defined $gplink and -e $gpasm and -e $gplink
defined $gpasm
defined $gplink
-e $gpasm
-e $gplink
Truth table0%0/5
A and B and C and D
A= defined $gpasmB= defined $gplinkC= -e $gpasmD= -e $gplink
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | die "Cannot find gpasm/gplink to compile $output into a hex file $hexfile."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my ($inc1, $inc2) = ('', ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if (defined $bindir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my @dirs = File::Spec->splitdir($bindir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | my $l = pop @dirs if @dirs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if (defined $l and $l ne 'bin') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $l and $l ne "bin"
MC/DC0%0/2
defined $l and $l ne "bin"
defined $l
$l ne "bin"
Truth table0%0/3
A and B
A= defined $lB= $l ne "bin"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | push @dirs, $l; # return the last directory | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my @includes = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my @linkers = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | push @includes, File::Spec->catdir(@dirs, 'header'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | push @linkers, File::Spec->catdir(@dirs, 'lkr'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | push @includes, File::Spec->catdir(@dirs, 'share', 'gputils', 'header'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | push @linkers, File::Spec->catdir(@dirs, 'share', 'gputils', 'lkr'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | foreach (@includes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | $inc1 .= " -I $_ " if -d $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | foreach (@linkers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | $inc2 .= " -I $_ " if -d $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $codfile = File::Spec->rel2abs($codfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $stcfile = File::Spec->rel2abs($stcfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $hexfile = File::Spec->rel2abs($hexfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $objfile = File::Spec->rel2abs($objfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $gpasm_cmd = "$gpasm $inc1 -p $chip -M -c $output"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $gplink_cmd = "$gplink $inc2 -q -m -o $hexfile $objfile "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | print "$gpasm_cmd\n" if $Verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | system($gpasm_cmd) == 0 or die "Unable to run '$gpasm_cmd': $?"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | print "$gplink_cmd\n" if $Verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | system($gplink_cmd) == 0 or die "Unable to run '$gplink_cmd': $?"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | open $fh, ">$stcfile" or die "Unable to write $stcfile: $?"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | print $fh "load s '$codfile'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return { hex => $hexfile, obj => $objfile, cod => $codfile, stc => $stcfile }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | sub simulate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | my ($sim, $hh) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
simulate: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $stc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if (ref $hh eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $stc = $hh->{stc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } elsif (ref $hh eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ($stc) = grep {/\.stc$/} @$hh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $stc = $hh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | die "Cannot find $stc to run the simulator $sim on\n" unless (defined $stc and -e $stc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $stc and -e $stc
MC/DC0%0/2
defined $stc and -e $stc
defined $stc
-e $stc
Truth table0%0/3
A and B
A= defined $stcB= -e $stc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my $simexe = &_load_simulator($sim); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | die "$sim is not present in your system PATH for simulation\n" unless $simexe; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $sim_cmd = "$simexe $stc"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | print "$sim_cmd\n" if $Verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | system($sim_cmd) == 0 or die "Unable to run '$sim_cmd': $?"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 33 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | VIC - A Viciously Simple Syntax for PIC Microcontrollers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | $ vic program.vic -o program.asm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | $ vic -h | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | Refer documentation at L<http://selectiveintellect.github.io/vic/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | Vikas N Kumar <vikas@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | Copyright (c) 2014-2016. Vikas N Kumar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | See http://www.perl.com/perl/misc/Artistic.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||