URL
https://opencores.org/ocsvn/w11/w11/trunk
Subversion Repositories w11
[/] [w11/] [tags/] [w11a_V0.5/] [tools/] [bin/] [impact_wrapper] - Rev 11
Go to most recent revision | Compare with Previous | Blame | View Log
#!/usr/bin/perl -w
# $Id: impact_wrapper 314 2010-07-09 17:38:41Z mueller $
#
# Copyright 2010- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# This program is free software; you may redistribute and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 2, or at your option any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for complete details.
#
# Revision History:
# Date Rev Version Comment
# 2010-05-24 294 1.0.2 support nexys2/xc3s1200e
# 2010-04-24 282 1.0.1 proper error exit for GetOptions()
# 2010-04-24 281 1.0 Initial version
#
use 5.005; # require Perl 5.005 or higher
use strict; # require strict checking
use FileHandle;
use Getopt::Long;
my %opts = ();
$opts{board} = "s3board";
$opts{path} = "xc3s1000";
GetOptions(\%opts, "help", "board=s", "path=s") or exit 1;
sub print_help;
autoflush STDOUT 1 if (-p STDOUT); # autoflush if output into pipe
if (exists $opts{help}) {
print_help;
exit 0;
}
my $board = $opts{board};
my $ipath = $opts{path};
$ipath =~ s/-.*$//; # trim all after first '-'
# at this point just support Digilent s3board with xc3s200 or xc3s1000
my $part2;
if ($board eq "s3board" && $ipath eq "xc3s200") {
$part2 = "xcf02s";
} elsif ($board eq "s3board" && $ipath eq "xc3s1000") {
$part2 = "xcf04s";
} elsif ($board eq "nexys2" && $ipath eq "xc3s1200e") {
$part2 = "xcf04s";
} else {
print STDERR "impact_wrapper-E: only s3board/nexys2 supported\n";
exit 1;
}
my $file = shift @ARGV;
if (! defined $file) {
print STDERR "impact_wrapper-E: no bit file specified\n";
exit 1;
}
if (! -r $file) {
print STDERR "impact_wrapper-E: input file not found or readable\n";
exit 1;
}
my $tmpfile = "tmp_impact_wrapper.cmd";
open (OFILE, ">$tmpfile") or die "Couldn't open tmp cmd file: $!";
print OFILE "setMode -bs\n";
print OFILE "setCable -p auto\n";
print OFILE "addDevice -p 1 -part $ipath\n";
print OFILE "addDevice -p 2 -part $part2\n";
print OFILE "assignFile -p 1 -file $file\n";
print OFILE "program -p 1 -verify\n";
print OFILE "quit\n";
close (OFILE) or die "Couldn't close tmp cmd file: $!";
my $wrc = system "/bin/sh", "-c", "impact -batch $tmpfile";
my $rc = 0;
if ($wrc != 0) {
my $rc = int($wrc/256);
if ($rc == 0) {
my $sig = $wrc % 256;
print STDERR "impact_wrapper-I impact aborted by signal $sig\n";
$rc = 1;
} else {
print STDERR "impact_wrapper-I impact failed (rc=$rc) $?\n";
}
}
unlink $tmpfile or die "Couldn't delete tmp cmd file: $!";
exit $rc;
#-------------------------------------------------------------------------------
sub print_help {
print "usage: impact_wrapper [--help] [--board=b] [--path=p] file\n";
print " --help this message\n";
print " --board=b type of board\n";
print " --path=p type of fpga\n";
}
Go to most recent revision | Compare with Previous | Blame | View Log