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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.5/] [rtl/] [sys_gen/] [w11a/] [tb/] [dorri] - Blame information for rev 11

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: dorri 311 2010-06-30 17:52:37Z mueller $
3
#
4
#  Revision History:
5
# Date         Rev Version  Comment
6
# 2010-05-29   296   1.4    allow -ux,baud (usb devnum and baudrate)
7
# 2010-05-28   295   1.3    w11a_s3/w11a_n2 support: -s3 and -n2 instead of -f
8
#                           add -tmu option
9
# 2010-05-03   287   1.2    add -u[123] options for fast usb serport
10
# 2009-08-01   237   1.1.1  use 115200 instead of 38400 as default baud rate
11
# 2009-04-26   209   1.1    add -b (batch) option
12
# 2009-04-11   206   1.0    Initial version
13
#
14
 
15
use 5.005;                                  # require Perl 5.005 or higher
16
use strict;                                 # require strict checking
17
use FileHandle;
18
 
19
sub print_usage;
20
 
21
autoflush STDOUT 1;             # autoflush, so noting lost on exec later
22
 
23
my $opt_b;
24
my $opt_io;
25
my $opt_tmu;
26
my $pirri;
27
my $val_cmax="3";
28
my $val_time="3.";
29
my $val_term=",115200,1";
30
my $val_log="rri.log";
31
my $val_tb_s3="tbw ../s3board/tb/tb_w11a_s3";
32
my $val_tb_n2="tbw ../nexys2/tb/tb_w11a_n2";
33
my $val_tb;
34
my $val_e;
35
 
36
my @arglist;
37
 
38
my %baudtbl = (
39
       "57" =>   57600,
40
      "115" =>  115200,
41
      "230" =>  230400,
42
      "460" =>  460800,
43
      "500" =>  500000,
44
     "1000" => 1000000,
45
     "2000" => 2000000,
46
     "3000" => 2000000
47
   );
48
 
49
#
50
# process dorri options
51
#
52
while (scalar(@ARGV)) {
53
  my $curarg = $ARGV[0];
54
  if ($curarg =~ m{^-b$} ) {                # -b
55
    $opt_b = 1;
56
    shift @ARGV;
57
  } elsif ($curarg =~ m{^-tmu$} ) {         # -tmu
58
    $opt_tmu = 1;
59
    shift @ARGV;
60
  } elsif ($curarg =~ m{^-s3$} ) {          # -s3
61
    $opt_io = "f";
62
    $val_tb = $val_tb_s3;
63
    shift @ARGV;
64
  } elsif ($curarg =~ m{^-n2$} ) {          # -n2
65
    $opt_io = "f";
66
    $val_tb = $val_tb_n2;
67
    shift @ARGV;
68
  } elsif ($curarg =~ m{^-t$} ) {           # -t
69
    $opt_io = "t";
70
 
71
  } elsif ($curarg =~ m{^-u(\d)} )  {      # -ux...
72
    my $devnum   = $1;
73
    my $rest     = $';
74
    my $baudspec = "115";
75
    my $baudrate;
76
    if ($rest ne "") {
77
      if ($rest =~ m{^,(\d*)$}) {
78
        $baudspec = $1;
79
      } else {
80
        print STDERR "dorri-E: invalid format of -u option\n";
81
        exit 1;
82
      }
83
    }
84
    if (defined $baudtbl{$baudspec}) {
85
      $baudrate = $baudtbl{$baudspec};
86
    } else {
87
      print STDERR "dorri-E: invalid baudrate specification\n";
88
      exit 1;
89
    }
90
    $opt_io = "t";
91
    $val_term = sprintf "/dev/ttyUSB%d,%d,1", $devnum, $baudrate;
92
    shift @ARGV;
93
 
94
  } elsif ($curarg =~ m{^-e$} ) {           # -e 
95
    print STDERR "dorri-W: multiple -e options, only last taken\n"
96
      if defined $val_e;
97
    shift @ARGV;
98
    if (scalar(@ARGV) == 0 || $ARGV[0] =~ m{^-}) {
99
      print STDERR "dorri-E: no file name after -e option\n";
100
      exit 1;
101
    } else {
102
      $val_e = shift @ARGV;
103
      if (not -r $val_e) {
104
        print STDERR "dorri-E: file '$val_e' not found\n";
105
        exit 1;
106
      }
107
    }
108
  } else {
109
    last;
110
  }
111
}
112
 
113
#
114
# rename old log file
115
#
116
if (-r $val_log) {
117
  my $old_log = $val_log;
118
  $old_log =~ s{\.log}{\.old\.log};
119
  rename $val_log, $old_log
120
    or die "failed to rename: $!";
121
}
122
 
123
#
124
# check that either -s3/n2 or -t given
125
# setup pi_rri options for either case
126
#
127
 
128
if ($opt_io eq "f") {
129
  push @arglist, "--fifo";
130
  push @arglist, "--run";
131
  push @arglist, $val_tb;
132
} elsif ($opt_io eq "t") {
133
  push @arglist, "--term=$val_term";
134
} else {
135
  print STDERR "dorri-E: neither -s3/-n2 nor -t specified\n";
136
  print_usage();
137
  exit 1;
138
}
139
 
140
#
141
# setup all other options
142
#
143
 
144
push @arglist, "--timeout=$val_time";
145
push @arglist, "--cmax=$val_cmax";
146
push @arglist, "--log=$val_log";
147
push @arglist, "--dserv";
148
push @arglist, "--tserv";
149
push @arglist, "--int" unless $opt_b;
150
 
151
if (defined $val_e) {
152
  push @arglist, ".mode serv11";
153
  push @arglist, "ldabs $val_e";
154
  push @arglist, "set sim tmu 1" if $opt_tmu;
155
  push @arglist, "start 200";
156
}
157
 
158
while (scalar(@ARGV)) {
159
  my $curarg = shift @ARGV;
160
  if ($curarg =~ m{^@(.*)$} && ! -r $1) {
161
    print STDERR "dorri-E: file '$1' not found\n";
162
    exit 1;
163
  }
164
  push @arglist,$curarg;
165
}
166
 
167
if (defined $val_e) {
168
  push @arglist, "server";
169
}
170
 
171
#
172
# find pi_rri executable
173
#
174
 
175
$pirri=`which pi_rri`;
176
chomp $pirri;
177
if ($pirri eq "" || ! -e $pirri) {
178
  print STDERR "dorri-E: failed to locate pi_rri\n";
179
  exit 1;
180
}
181
 
182
#
183
# print command file
184
#
185
if (1) {
186
 print "pi_rri ", join (" ", map {(m{\s}) ? "\"$_\"" : $_} @arglist) , "\n";
187
}
188
 
189
#
190
# and do it
191
#
192
exec $pirri, @arglist
193
  or die "failed to exec: $!";
194
 
195
exit 1;
196
 
197
# ----------------------------------------------------------------------------
198
sub print_usage {
199
  print "usage: dorri [-f] [-t] [-u(123) [-e file] ...\n";
200
}

powered by: WebSVN 2.1.0

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