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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [bin/] [ti_w11] - Blame information for rev 40

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

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

powered by: WebSVN 2.1.0

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