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

Subversion Repositories w11

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

powered by: WebSVN 2.1.0

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