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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [tools/] [bin/] [ti_w11] - Blame information for rev 20

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

Line No. Rev Author Line
1 20 wfjm
#!/usr/bin/perl -w
2
# $Id: torri 511 2013-04-27 13:51:46Z mueller $
3
#
4
#  Revision History:
5
# Date         Rev Version  Comment
6
# 2013-04-26   510   1.0    Initial version (derived from dorri)
7
#
8
 
9
use 5.005;                                  # require Perl 5.005 or higher
10
use strict;                                 # require strict checking
11
use FileHandle;
12
 
13
sub print_usage;
14
 
15
autoflush STDOUT 1;             # autoflush, so noting lost on exec later
16
 
17
my $opt_b;
18
my $opt_io = '';
19
my $opt_f = '';
20
my $opt_tmu;
21
my $tirri;
22
my $val_term;
23
my $val_tb_s3='tbw ../s3board/tb/tb_w11a_s3';
24
my $val_tb_n2='tbw ../nexys2/tb/tb_w11a_n2';
25
my $val_tb_n3='tbw ../nexys3/tb/tb_w11a_n3';
26
my $val_tb;
27
my $val_e;
28
 
29
my @arglist;
30
 
31
#
32
# process torri options
33
#
34
while (scalar(@ARGV)) {
35
  my $curarg = $ARGV[0];
36
 
37
  if ($curarg =~ m{^-b$} ) {                # -b
38
    $opt_b = 1;
39
    shift @ARGV;
40
 
41
  } elsif ($curarg =~ m{^-tmu$} ) {         # -tmu
42
    $opt_tmu = 1;
43
    shift @ARGV;
44
 
45
  } elsif ($curarg =~ m{^-s3$} ) {          # -s3
46
    $opt_io = 'f';
47
    $val_tb = $val_tb_s3;
48
    shift @ARGV;
49
 
50
  } elsif ($curarg =~ m{^-n2$} ) {          # -n2
51
    $opt_io = 'f';
52
    $val_tb = $val_tb_n2;
53
    shift @ARGV;
54
 
55
  } elsif ($curarg =~ m{^-n3$} ) {          # -n3
56
    $opt_io = 'f';
57
    $val_tb = $val_tb_n3;
58
    shift @ARGV;
59
 
60
  } elsif ($curarg =~ m{^-f(s\d?|u)$} ) {    # -f[su]
61
    $opt_f = $1;
62
    shift @ARGV;
63
 
64
  } elsif ($curarg =~ m{^-t([su])(\d?),?} ) {   # -t[su]...
65
    my $devnam = ($1 eq 's') ? '/dev/ttyS' : '/dev/ttyUSB';
66
    my $devnum = $2;
67
    my ($dev,$baud,$opt1,$opt2) = split /,/,$curarg;
68
    $baud  = '115k' unless defined $baud;
69
 
70
    if ($baud !~ m{^\d*k?$}) {
71
      print STDERR "torri-E: invalid format of -ts or -tu option\n";
72
      exit 1;
73
    }
74
 
75
    $opt_io = 't';
76
    $val_term = sprintf '%s%d,%s', $devnam, $devnum, $baud;
77
    $val_term .= ",$opt1" if defined $opt1;
78
    $val_term .= ",$opt2" if defined $opt2;
79
    shift @ARGV;
80
 
81
  } elsif ($curarg =~ m{^-u$} )  {          # -u
82
    $opt_io = 'u';
83
    shift @ARGV;
84
 
85
  } elsif ($curarg =~ m{^-e$} ) {           # -e 
86
    print STDERR "torri-W: multiple -e options, only last taken\n"
87
      if defined $val_e;
88
    shift @ARGV;
89
    if (scalar(@ARGV) == 0 || $ARGV[0] =~ m{^-}) {
90
      print STDERR "torri-E: no file name after -e option\n";
91
      exit 1;
92
    } else {
93
      $val_e = shift @ARGV;
94
      if (not -r $val_e) {
95
        print STDERR "torri-E: file '$val_e' not found\n";
96
        exit 1;
97
      }
98
    }
99
  } else {
100
    last;
101
  }
102
}
103
 
104
#
105
# check that either -s3/n2/n3 or -t or -u given
106
# setup pi_rri options for either case
107
#
108
 
109
if ($opt_io eq 'f') {
110
  push @arglist, '--fifo';
111
  push @arglist, "--run=$val_tb";
112
} elsif ($opt_io eq 't') {
113
  push @arglist, "--term=$val_term";
114
} elsif ($opt_io eq 'u') {
115
  push @arglist, '--cuff';
116
} else {
117
  print STDERR "torri-E: neither -s3/-n2/-n3 nor -t or -u specified\n";
118
  print_usage();
119
  exit 1;
120
}
121
 
122
#
123
# setup all other ti_rri options
124
#
125
 
126
push @arglist, '--logl=2';
127
push @arglist, '--int' unless $opt_b;
128
push @arglist, '--pack=rw11';
129
push @arglist, '--';
130
 
131
#
132
# actions prior to first exec
133
#   setup tmu ect
134
#   setup access path --> handle -f options
135
#
136
if ($opt_io eq 'f') {
137
  if ($opt_tmu) {
138
    push @arglist, 'rlc oob -sbcntl 13   1';
139
  }
140
  if ($opt_f eq 'u') {
141
    push @arglist, 'rlc oob -sbdata  8 0x2';
142
    push @arglist, 'rlc oob -sbdata 16 0x4';
143
  }
144
 
145
}
146
 
147
#
148
# initialize w11 cpu system
149
#
150
push @arglist, 'rw11::setup_sys';
151
 
152
#
153
# handle -e option
154
#
155
 
156
if (defined $val_e) {
157
  if ($val_e =~ m/\.mac$/) {
158
    push @arglist, "cpu0 ldasm -file $val_e -sym ldasm_sym -lst ldasm_lst";
159
  } else {
160
    push @arglist, "cpu0 ldabs $val_e";
161
  }
162
  push @arglist, 'rw11::cpumon';
163
  push @arglist, 'rw11::cpucons';
164
  push @arglist, 'cpu0 cp -stapc 0200';
165
}
166
 
167
#
168
# all remaining commands
169
#
170
 
171
while (scalar(@ARGV)) {
172
  my $curarg = shift @ARGV;
173
  if ($curarg =~ m{^@(.*)$} && ! -r $1) {
174
    print STDERR "torri-E: file '$1' not found\n";
175
    exit 1;
176
  }
177
  push @arglist,$curarg;
178
}
179
 
180
#
181
# find ti_rri executable
182
#
183
 
184
$tirri=`which ti_rri`;
185
chomp $tirri;
186
if ($tirri eq '' || ! -e $tirri) {
187
  print STDERR "torri-E: failed to locate ti_rri\n";
188
  exit 1;
189
}
190
 
191
#
192
# print command file
193
#
194
if (1) {
195
 print 'ti_rri ', join (' ', map {(m{\s}) ? "\"$_\"" : $_} @arglist) , "\n";
196
}
197
 
198
#
199
# and do it
200
#
201
exec $tirri, @arglist
202
  or die "failed to exec: $!";
203
 
204
exit 1;
205
 
206
# ----------------------------------------------------------------------------
207
sub print_usage {
208
  print "usage: torri  ...\n";
209
  print "  setup options for ghdl simulation runs:\n";
210
  print "    -s3       start tb_w11a_s3 simulation\n";
211
  print "    -n2       start tb_w11a_n2 simulation\n";
212
  print "    -n3       start tb_w11a_n3 simulation\n";
213
  print "    -f..      simulation communication options\n";
214
  print "      -fu       use cuff data path\n";
215
  print "    -tmu      activate trace and monitoring unit\n";
216
  print "  setup options for FPGA connects:\n";
217
  print "    -u        use --cuff connect\n";
218
  print "    -t..      use --term connect\n";
219
  print "      -ts*[,opts]   use /dev/ttyS*   (* is device number)\n";
220
  print "      -tu*[,opts]   use /dev/ttyUSB* (* is device number)\n";
221
  print "                    opts can be ',break', ',xon'\n";
222
  print "  common options:\n";
223
  print "    -e  load and execute file\n";
224
  print "                file type '.mac': on the fly compile with asm-11\n";
225
  print "                any other file type: assume lda format\n";
226
  print "\n";
227
  print "  either one of -s3,-n2, or -n3 must be given -> sim run\n";
228
  print "  or one of -t or -u must be given            -> fpga run\n";
229
}

powered by: WebSVN 2.1.0

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