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 34

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

Line No. Rev Author Line
1 20 wfjm
#!/usr/bin/perl -w
2 34 wfjm
# $Id: ti_w11 712 2015-11-01 22:53:45Z mueller $
3 20 wfjm
#
4 29 wfjm
# Copyright 2013-2015 by Walter F.J. Mueller 
5
# License disclaimer see LICENSE_gpl_v2.txt in $RETROBASE directory
6
#
7 20 wfjm
#  Revision History:
8
# Date         Rev Version  Comment
9 34 wfjm
# 2015-11-01   712   1.3.2  use sb_cntl pin 12 for tmu; add -ghw option
10 30 wfjm
# 2015-05-14   680   1.3.1  use now -f1,-f1e,-f2,-f2e (fx now f1e)
11
# 2015-04-13   667   1.3    rename -fu->-fc, add -f2,-fx; setup good defaults
12 29 wfjm
# 2015-01-02   640   1.2.2  BUGFIX: allow 'M' unit in baud rates
13 28 wfjm
# 2014-12-23   619   1.2.1  use -fifo tbw option for test bench starts
14
# 2014-07-13   570   1.2    BUGFIX: split options args into ti_rri opts and cmds
15 21 wfjm
# 2013-05-05   516   1.1    renamed to ti_w11
16 20 wfjm
# 2013-04-26   510   1.0    Initial version (derived from dorri)
17
#
18
 
19
use 5.005;                                  # require Perl 5.005 or higher
20
use strict;                                 # require strict checking
21
use FileHandle;
22
 
23
sub print_usage;
24
 
25 29 wfjm
autoflush STDOUT 1;             # autoflush, so nothing lost on exec later
26 20 wfjm
 
27 21 wfjm
my $sysbase = "$ENV{RETROBASE}/rtl/sys_gen/w11a";
28
 
29 30 wfjm
my $opt_dry;
30 20 wfjm
my $opt_b;
31
my $opt_io = '';
32
my $opt_f = '';
33
my $opt_tmu;
34 34 wfjm
my $opt_ghw;
35 20 wfjm
my $tirri;
36
my $val_term;
37 29 wfjm
my $val_tb_s3  = "tbw $sysbase/s3board/tb/tb_w11a_s3 -fifo";
38
my $val_tb_n2  = "tbw $sysbase/nexys2/tb/tb_w11a_n2 -fifo";
39
my $val_tb_n3  = "tbw $sysbase/nexys3/tb/tb_w11a_n3 -fifo";
40
my $val_tb_b3  = "tbw $sysbase/basys3/tb/tb_w11a_b3 -fifo";
41
my $val_tb_n4  = "tbw $sysbase/nexys4/tb/tb_w11a_n4 -fifo";
42
my $val_tb_bn4 = "tbw $sysbase/nexys4_bram/tb/tb_w11a_br_n4 -fifo";
43 20 wfjm
my $val_tb;
44
my $val_e;
45
 
46
my @arglist;
47
 
48
#
49 21 wfjm
# process ti_w11 options
50 20 wfjm
#
51
while (scalar(@ARGV)) {
52
  my $curarg = $ARGV[0];
53
 
54 30 wfjm
  if ($curarg =~ m{^-dry$} ) {              # -dry
55
    $opt_dry = 1;
56
    shift @ARGV;
57
 
58
  } elsif ($curarg =~ m{^-b$} ) {           # -b
59 20 wfjm
    $opt_b = 1;
60
    shift @ARGV;
61
 
62
  } elsif ($curarg =~ m{^-tmu$} ) {         # -tmu
63
    $opt_tmu = 1;
64
    shift @ARGV;
65
 
66 34 wfjm
  } elsif ($curarg =~ m{^-ghw$} ) {         # -ghw
67
    $opt_ghw = 1;
68
    shift @ARGV;
69
 
70 30 wfjm
  } elsif ($curarg =~ m{^-s3$} ) {          # -s3 (use -f2 by default)
71 20 wfjm
    $opt_io = 'f';
72 30 wfjm
    $opt_f  = '2';
73 20 wfjm
    $val_tb = $val_tb_s3;
74
    shift @ARGV;
75
 
76 30 wfjm
  } elsif ($curarg =~ m{^-n2$} ) {          # -n2 (use -fc by default)
77 20 wfjm
    $opt_io = 'f';
78 30 wfjm
    $opt_f  = 'c';
79 20 wfjm
    $val_tb = $val_tb_n2;
80
    shift @ARGV;
81
 
82 30 wfjm
  } elsif ($curarg =~ m{^-n3$} ) {          # -n3 (use -fc by default)
83 20 wfjm
    $opt_io = 'f';
84 30 wfjm
    $opt_f  = 'c';
85 20 wfjm
    $val_tb = $val_tb_n3;
86
    shift @ARGV;
87
 
88 30 wfjm
  } elsif ($curarg =~ m{^-b3$} ) {          # -b3 (use -f1x by default)
89 29 wfjm
    $opt_io = 'f';
90 30 wfjm
    $opt_f  = '1x';
91 29 wfjm
    $val_tb = $val_tb_b3;
92
    shift @ARGV;
93
 
94 30 wfjm
  } elsif ($curarg =~ m{^-n4$} ) {          # -n4 (prim serport fine)
95 29 wfjm
    $opt_io = 'f';
96 30 wfjm
    $opt_f  = '1';
97 29 wfjm
    $val_tb = $val_tb_n4;
98
    shift @ARGV;
99
 
100 30 wfjm
  } elsif ($curarg =~ m{^-bn4$} ) {         # -bn4 (prim serport fine)
101 29 wfjm
    $opt_io = 'f';
102 30 wfjm
    $opt_f  = '1';
103 29 wfjm
    $val_tb = $val_tb_bn4;
104
    shift @ARGV;
105
 
106 30 wfjm
  } elsif ($curarg =~ m{^-f(c|1|1x|2|2x)$} ) { # -f..
107 20 wfjm
    $opt_f = $1;
108
    shift @ARGV;
109
 
110
  } elsif ($curarg =~ m{^-t([su])(\d?),?} ) {   # -t[su]...
111
    my $devnam = ($1 eq 's') ? '/dev/ttyS' : '/dev/ttyUSB';
112
    my $devnum = $2;
113
    my ($dev,$baud,$opt1,$opt2) = split /,/,$curarg;
114
    $baud  = '115k' unless defined $baud;
115
 
116 29 wfjm
    if ($baud !~ m{^\d*[kM]?$}) {
117 21 wfjm
      print STDERR "ti_w11-E: invalid format of -ts or -tu option\n";
118 20 wfjm
      exit 1;
119
    }
120
 
121
    $opt_io = 't';
122
    $val_term = sprintf '%s%d,%s', $devnam, $devnum, $baud;
123
    $val_term .= ",$opt1" if defined $opt1;
124
    $val_term .= ",$opt2" if defined $opt2;
125
    shift @ARGV;
126
 
127
  } elsif ($curarg =~ m{^-u$} )  {          # -u
128
    $opt_io = 'u';
129
    shift @ARGV;
130
 
131
  } elsif ($curarg =~ m{^-e$} ) {           # -e 
132 21 wfjm
    print STDERR "ti_w11-W: multiple -e options, only last taken\n"
133 20 wfjm
      if defined $val_e;
134
    shift @ARGV;
135
    if (scalar(@ARGV) == 0 || $ARGV[0] =~ m{^-}) {
136 21 wfjm
      print STDERR "ti_w11-E: no file name after -e option\n";
137 20 wfjm
      exit 1;
138
    } else {
139
      $val_e = shift @ARGV;
140
      if (not -r $val_e) {
141 21 wfjm
        print STDERR "ti_w11-E: file '$val_e' not found\n";
142 20 wfjm
        exit 1;
143
      }
144
    }
145
  } else {
146
    last;
147
  }
148
}
149
 
150
#
151 25 wfjm
# process remaining arguments, separate ti_rri options and commands
152
#
153
 
154
# handle options (all starting with -)
155
my @tiopts;
156
while (scalar(@ARGV)) {
157
  last unless $ARGV[0] =~ m{^--};
158
  push @tiopts, shift @ARGV;
159
}
160
 
161
# handle comands
162
my @ticmds;
163
while (scalar(@ARGV)) {
164
  my $curarg = shift @ARGV;
165
  if ($curarg =~ m{^@(.*)$} && ! -r $1) {
166
    print STDERR "ti_w11-E: file '$1' not found\n";
167
    exit 1;
168
  }
169
  push @ticmds,$curarg;
170
}
171
 
172
#
173 29 wfjm
# check that either -(s3|n2|n3|n4|bn4) or -t or -u given
174 30 wfjm
# setup options for either case
175 20 wfjm
#
176
 
177
if ($opt_io eq 'f') {
178 30 wfjm
  my $fifoopts = ",noinit";                 # fifo always with deferred init
179
  $fifoopts .= ",xon" if $opt_f eq 'x';
180
  push @arglist, "--fifo=$fifoopts";
181 34 wfjm
  my $run_opts = "";
182
  if ($opt_ghw) {
183
    my $ghw_stem = "ti_w11";
184
    $ghw_stem = $1 if ($val_tb =~ m|^.*\s+.*/(\w*)\s+|); # get stem of tb file
185
    $run_opts .= " --wave=${ghw_stem}.ghw";
186
  }
187
  push @arglist, "--run=${val_tb}${run_opts}";
188 20 wfjm
} elsif ($opt_io eq 't') {
189
  push @arglist, "--term=$val_term";
190
} elsif ($opt_io eq 'u') {
191
  push @arglist, '--cuff';
192
} else {
193 30 wfjm
  print STDERR "ti_w11-E: neither -(s3|n2|n3|b3|n4|bn4) nor -t,-u specified\n";
194 20 wfjm
  print_usage();
195
  exit 1;
196
}
197
 
198
#
199
# setup all other ti_rri options
200
#
201
 
202
push @arglist, '--logl=2';
203
push @arglist, '--int' unless $opt_b;
204
push @arglist, '--pack=rw11';
205 25 wfjm
push @arglist, @tiopts;                     # add options from ARGV
206 20 wfjm
push @arglist, '--';
207
 
208
#
209
# actions prior to first exec
210
#   setup tmu ect
211
#   setup access path --> handle -f options
212
#
213
if ($opt_io eq 'f') {
214
  if ($opt_tmu) {
215 34 wfjm
    push @arglist, 'rlc oob -sbcntl 12   1';
216 20 wfjm
  }
217 30 wfjm
  if ($opt_f eq 'c') {
218
    push @arglist, 'rlc oob -sbdata  8 0x4'; # portsel = 0100 -> fx2
219
    push @arglist, 'rlc oob -sbdata 16 0x4'; # swi     = 0100 -> fx2
220
  } elsif ($opt_f eq '1x') {
221
    push @arglist, 'rlc oob -sbdata  8 0x2'; # portsel = 0010 -> 1st ser XON
222
    push @arglist, 'rlc oob -sbdata 16 0x2'; # swi     = 0010 -> 1st ser XON
223
  } elsif ($opt_f eq '2') {
224
    push @arglist, 'rlc oob -sbdata  8 0x1'; # portsel = 0001 -> 2nd ser
225
    push @arglist, 'rlc oob -sbdata 16 0x1'; # swi     = 0001 -> 2nd ser
226
  } elsif ($opt_f eq '2x') {
227
    push @arglist, 'rlc oob -sbdata  8 0x3'; # portsel = 0011 -> 2nd ser XON
228
    push @arglist, 'rlc oob -sbdata 16 0x3'; # swi     = 0011 -> 2nd ser XON
229 20 wfjm
  }
230
}
231
 
232
#
233 30 wfjm
# --fifo always uses deferred init, so add a rlc init after the oob's
234
#
235
push @arglist, 'rlc init' if $opt_io eq 'f';
236
 
237
#
238 20 wfjm
# initialize w11 cpu system
239
#
240
push @arglist, 'rw11::setup_sys';
241
 
242
#
243
# handle -e option
244
#
245
 
246
if (defined $val_e) {
247
  if ($val_e =~ m/\.mac$/) {
248
    push @arglist, "cpu0 ldasm -file $val_e -sym ldasm_sym -lst ldasm_lst";
249
  } else {
250
    push @arglist, "cpu0 ldabs $val_e";
251
  }
252
  push @arglist, 'rw11::cpumon';
253
  push @arglist, 'rw11::cpucons';
254
  push @arglist, 'cpu0 cp -stapc 0200';
255
}
256
 
257 25 wfjm
push @arglist, @ticmds;                     # add commands from ARGV
258 20 wfjm
 
259
#
260
# find ti_rri executable
261
#
262
 
263
$tirri=`which ti_rri`;
264
chomp $tirri;
265
if ($tirri eq '' || ! -e $tirri) {
266 21 wfjm
  print STDERR "ti_w11-E: failed to locate ti_rri\n";
267 20 wfjm
  exit 1;
268
}
269
 
270
#
271 30 wfjm
# print command line
272 20 wfjm
#
273
if (1) {
274
 print 'ti_rri ', join (' ', map {(m{\s}) ? "\"$_\"" : $_} @arglist) , "\n";
275
}
276
 
277
#
278 30 wfjm
# if dry run, stop here
279
#
280
exit 0 if $opt_dry;
281
#
282 20 wfjm
# and do it
283
#
284
exec $tirri, @arglist
285
  or die "failed to exec: $!";
286
 
287
exit 1;
288
 
289
# ----------------------------------------------------------------------------
290
sub print_usage {
291 21 wfjm
  print "usage: ti_w11  ...\n";
292 20 wfjm
  print "  setup options for ghdl simulation runs:\n";
293 30 wfjm
  print "    -b3       start tb_w11a_b3 simulation (default: -f1x)\n";
294 29 wfjm
  print "    -n4       start tb_w11a_n4 simulation\n";
295
  print "    -bn4      start tb_w11a_br_n4 simulation\n";
296 30 wfjm
  print "    -n3       start tb_w11a_n3 simulation (default: -fc)\n";
297
  print "    -n2       start tb_w11a_n2 simulation (default: -fc)\n";
298
  print "    -s3       start tb_w11a_s3 simulation (default: -f2)\n";
299 20 wfjm
  print "    -f..      simulation communication options\n";
300 30 wfjm
  print "      -fc       use fx2 data path (cuff)\n";
301
  print "      -f1       use 1st serport\n";
302
  print "      -f1x      use 1st serport with xon\n";
303
  print "      -f2       use 2nd serport   (fusp)\n";
304
  print "      -f2x      use 2nd serport with xon\n";
305 20 wfjm
  print "    -tmu      activate trace and monitoring unit\n";
306
  print "  setup options for FPGA connects:\n";
307
  print "    -u        use --cuff connect\n";
308
  print "    -t..      use --term connect\n";
309
  print "      -ts*[,opts]   use /dev/ttyS*   (* is device number)\n";
310
  print "      -tu*[,opts]   use /dev/ttyUSB* (* is device number)\n";
311
  print "                    opts can be ',break', ',xon'\n";
312
  print "  common options:\n";
313
  print "    -e  load and execute file\n";
314
  print "                file type '.mac': on the fly compile with asm-11\n";
315
  print "                any other file type: assume lda format\n";
316
  print "\n";
317 29 wfjm
  print "  either one of -s3,-n2,-n3,-b3,-n4,-bn4  must be given -> sim run\n";
318 20 wfjm
  print "  or one of -t or -u must be given            -> fpga run\n";
319
}

powered by: WebSVN 2.1.0

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