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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [bin/] [ti_w11] - Blame information for rev 36

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

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

powered by: WebSVN 2.1.0

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