OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [bin/] [config_wrapper] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wfjm
#!/usr/bin/perl -w
2
# $Id: impact_wrapper 314 2010-07-09 17:38:41Z mueller $
3
#
4
# Copyright 2010- by Walter F.J. Mueller 
5
#
6
# This program is free software; you may redistribute and/or modify it under
7
# the terms of the GNU General Public License as published by the Free
8
# Software Foundation, either version 2, or at your option any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
12
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13
# for complete details.
14
#
15
#  Revision History:
16
# Date         Rev Version  Comment
17
# 2010-05-24   294   1.0.2  support nexys2/xc3s1200e
18
# 2010-04-24   282   1.0.1  proper error exit for GetOptions()
19
# 2010-04-24   281   1.0    Initial version
20
#
21
 
22
use 5.005;                                  # require Perl 5.005 or higher
23
use strict;                                 # require strict checking
24
use FileHandle;
25
 
26
use Getopt::Long;
27
 
28
my %opts = ();
29
 
30
$opts{board} = "s3board";
31
$opts{path}  = "xc3s1000";
32
 
33
GetOptions(\%opts, "help", "board=s", "path=s") or exit 1;
34
 
35
sub print_help;
36
 
37
autoflush STDOUT 1 if (-p STDOUT);          # autoflush if output into pipe
38
 
39
if (exists $opts{help}) {
40
  print_help;
41
  exit 0;
42
}
43
 
44
my $board = $opts{board};
45
my $ipath = $opts{path};
46
 
47
$ipath =~ s/-.*$//;                         # trim all after first '-'
48
 
49
# at this point just support Digilent s3board with xc3s200 or xc3s1000
50
 
51
my $part2;
52
 
53
if ($board eq "s3board" && $ipath eq "xc3s200") {
54
  $part2 = "xcf02s";
55
} elsif ($board eq "s3board" && $ipath eq "xc3s1000") {
56
  $part2 = "xcf04s";
57
} elsif ($board eq "nexys2" && $ipath eq "xc3s1200e") {
58
  $part2 = "xcf04s";
59
} else {
60
  print STDERR "impact_wrapper-E: only s3board/nexys2 supported\n";
61
  exit 1;
62
}
63
 
64
my $file = shift @ARGV;
65
 
66
if (! defined $file) {
67
  print STDERR "impact_wrapper-E: no bit file specified\n";
68
  exit 1;
69
}
70
if (! -r $file) {
71
  print STDERR "impact_wrapper-E: input file not found or readable\n";
72
  exit 1;
73
}
74
 
75
my $tmpfile = "tmp_impact_wrapper.cmd";
76
 
77
open (OFILE, ">$tmpfile") or die "Couldn't open tmp cmd file: $!";
78
 
79
print  OFILE "setMode -bs\n";
80
print  OFILE "setCable -p auto\n";
81
print  OFILE "addDevice -p 1 -part $ipath\n";
82
print  OFILE "addDevice -p 2 -part $part2\n";
83
print  OFILE "assignFile -p 1 -file $file\n";
84
print  OFILE "program -p 1 -verify\n";
85
print  OFILE "quit\n";
86
 
87
close (OFILE) or die "Couldn't close tmp cmd file: $!";
88
 
89
my $wrc = system "/bin/sh", "-c", "impact -batch $tmpfile";
90
my $rc  = 0;
91
if ($wrc != 0) {
92
  my $rc = int($wrc/256);
93
  if ($rc == 0) {
94
    my $sig = $wrc % 256;
95
    print STDERR "impact_wrapper-I impact aborted by signal $sig\n";
96
    $rc = 1;
97
  } else {
98
    print STDERR "impact_wrapper-I impact failed (rc=$rc) $?\n";
99
  }
100
}
101
 
102
unlink $tmpfile or die "Couldn't delete tmp cmd file: $!";
103
 
104
exit $rc;
105
 
106
#-------------------------------------------------------------------------------
107
 
108
sub print_help {
109
  print "usage: impact_wrapper [--help] [--board=b] [--path=p] file\n";
110
  print "  --help           this message\n";
111
  print "  --board=b        type of board\n";
112
  print "  --path=p         type of fpga\n";
113
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.