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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [bin/] [ti_w11] - Diff between revs 21 and 24

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 21 Rev 24
#!/usr/bin/perl -w
#!/usr/bin/perl -w
# $Id: ti_w11 516 2013-05-05 21:24:52Z mueller $
# $Id: ti_w11 516 2013-05-05 21:24:52Z mueller $
#
#
#  Revision History:
#  Revision History:
# Date         Rev Version  Comment
# Date         Rev Version  Comment
# 2013-05-05   516   1.1    renamed to ti_w11
# 2013-05-05   516   1.1    renamed to ti_w11
# 2013-04-26   510   1.0    Initial version (derived from dorri)
# 2013-04-26   510   1.0    Initial version (derived from dorri)
#
#
use 5.005;                                  # require Perl 5.005 or higher
use 5.005;                                  # require Perl 5.005 or higher
use strict;                                 # require strict checking
use strict;                                 # require strict checking
use FileHandle;
use FileHandle;
sub print_usage;
sub print_usage;
autoflush STDOUT 1;             # autoflush, so noting lost on exec later
autoflush STDOUT 1;             # autoflush, so noting lost on exec later
my $sysbase = "$ENV{RETROBASE}/rtl/sys_gen/w11a";
my $sysbase = "$ENV{RETROBASE}/rtl/sys_gen/w11a";
my $opt_b;
my $opt_b;
my $opt_io = '';
my $opt_io = '';
my $opt_f = '';
my $opt_f = '';
my $opt_tmu;
my $opt_tmu;
my $tirri;
my $tirri;
my $val_term;
my $val_term;
my $val_tb_s3 = "tbw $sysbase/s3board/tb/tb_w11a_s3";
my $val_tb_s3 = "tbw $sysbase/s3board/tb/tb_w11a_s3";
my $val_tb_n2 = "tbw $sysbase/nexys2/tb/tb_w11a_n2";
my $val_tb_n2 = "tbw $sysbase/nexys2/tb/tb_w11a_n2";
my $val_tb_n3 = "tbw $sysbase/nexys3/tb/tb_w11a_n3";
my $val_tb_n3 = "tbw $sysbase/nexys3/tb/tb_w11a_n3";
my $val_tb;
my $val_tb;
my $val_e;
my $val_e;
my @arglist;
my @arglist;
#
#
# process ti_w11 options
# process ti_w11 options
#
#
while (scalar(@ARGV)) {
while (scalar(@ARGV)) {
  my $curarg = $ARGV[0];
  my $curarg = $ARGV[0];
  if ($curarg =~ m{^-b$} ) {                # -b
  if ($curarg =~ m{^-b$} ) {                # -b
    $opt_b = 1;
    $opt_b = 1;
    shift @ARGV;
    shift @ARGV;
  } elsif ($curarg =~ m{^-tmu$} ) {         # -tmu
  } elsif ($curarg =~ m{^-tmu$} ) {         # -tmu
    $opt_tmu = 1;
    $opt_tmu = 1;
    shift @ARGV;
    shift @ARGV;
  } elsif ($curarg =~ m{^-s3$} ) {          # -s3
  } elsif ($curarg =~ m{^-s3$} ) {          # -s3
    $opt_io = 'f';
    $opt_io = 'f';
    $val_tb = $val_tb_s3;
    $val_tb = $val_tb_s3;
    shift @ARGV;
    shift @ARGV;
  } elsif ($curarg =~ m{^-n2$} ) {          # -n2
  } elsif ($curarg =~ m{^-n2$} ) {          # -n2
    $opt_io = 'f';
    $opt_io = 'f';
    $val_tb = $val_tb_n2;
    $val_tb = $val_tb_n2;
    shift @ARGV;
    shift @ARGV;
  } elsif ($curarg =~ m{^-n3$} ) {          # -n3
  } elsif ($curarg =~ m{^-n3$} ) {          # -n3
    $opt_io = 'f';
    $opt_io = 'f';
    $val_tb = $val_tb_n3;
    $val_tb = $val_tb_n3;
    shift @ARGV;
    shift @ARGV;
  } elsif ($curarg =~ m{^-f(s\d?|u)$} ) {    # -f[su]
  } elsif ($curarg =~ m{^-f(s\d?|u)$} ) {    # -f[su]
    $opt_f = $1;
    $opt_f = $1;
    shift @ARGV;
    shift @ARGV;
  } elsif ($curarg =~ m{^-t([su])(\d?),?} ) {   # -t[su]...
  } elsif ($curarg =~ m{^-t([su])(\d?),?} ) {   # -t[su]...
    my $devnam = ($1 eq 's') ? '/dev/ttyS' : '/dev/ttyUSB';
    my $devnam = ($1 eq 's') ? '/dev/ttyS' : '/dev/ttyUSB';
    my $devnum = $2;
    my $devnum = $2;
    my ($dev,$baud,$opt1,$opt2) = split /,/,$curarg;
    my ($dev,$baud,$opt1,$opt2) = split /,/,$curarg;
    $baud  = '115k' unless defined $baud;
    $baud  = '115k' unless defined $baud;
    if ($baud !~ m{^\d*k?$}) {
    if ($baud !~ m{^\d*k?$}) {
      print STDERR "ti_w11-E: invalid format of -ts or -tu option\n";
      print STDERR "ti_w11-E: invalid format of -ts or -tu option\n";
      exit 1;
      exit 1;
    }
    }
    $opt_io = 't';
    $opt_io = 't';
    $val_term = sprintf '%s%d,%s', $devnam, $devnum, $baud;
    $val_term = sprintf '%s%d,%s', $devnam, $devnum, $baud;
    $val_term .= ",$opt1" if defined $opt1;
    $val_term .= ",$opt1" if defined $opt1;
    $val_term .= ",$opt2" if defined $opt2;
    $val_term .= ",$opt2" if defined $opt2;
    shift @ARGV;
    shift @ARGV;
  } elsif ($curarg =~ m{^-u$} )  {          # -u
  } elsif ($curarg =~ m{^-u$} )  {          # -u
    $opt_io = 'u';
    $opt_io = 'u';
    shift @ARGV;
    shift @ARGV;
  } elsif ($curarg =~ m{^-e$} ) {           # -e 
  } elsif ($curarg =~ m{^-e$} ) {           # -e 
    print STDERR "ti_w11-W: multiple -e options, only last taken\n"
    print STDERR "ti_w11-W: multiple -e options, only last taken\n"
      if defined $val_e;
      if defined $val_e;
    shift @ARGV;
    shift @ARGV;
    if (scalar(@ARGV) == 0 || $ARGV[0] =~ m{^-}) {
    if (scalar(@ARGV) == 0 || $ARGV[0] =~ m{^-}) {
      print STDERR "ti_w11-E: no file name after -e option\n";
      print STDERR "ti_w11-E: no file name after -e option\n";
      exit 1;
      exit 1;
    } else {
    } else {
      $val_e = shift @ARGV;
      $val_e = shift @ARGV;
      if (not -r $val_e) {
      if (not -r $val_e) {
        print STDERR "ti_w11-E: file '$val_e' not found\n";
        print STDERR "ti_w11-E: file '$val_e' not found\n";
        exit 1;
        exit 1;
      }
      }
    }
    }
  } else {
  } else {
    last;
    last;
  }
  }
}
}
#
#
# check that either -s3/n2/n3 or -t or -u given
# check that either -s3/n2/n3 or -t or -u given
# setup pi_rri options for either case
# setup pi_rri options for either case
#
#
if ($opt_io eq 'f') {
if ($opt_io eq 'f') {
  push @arglist, '--fifo';
  push @arglist, '--fifo';
  push @arglist, "--run=$val_tb";
  push @arglist, "--run=$val_tb";
} elsif ($opt_io eq 't') {
} elsif ($opt_io eq 't') {
  push @arglist, "--term=$val_term";
  push @arglist, "--term=$val_term";
} elsif ($opt_io eq 'u') {
} elsif ($opt_io eq 'u') {
  push @arglist, '--cuff';
  push @arglist, '--cuff';
} else {
} else {
  print STDERR "ti_w11-E: neither -s3/-n2/-n3 nor -t or -u specified\n";
  print STDERR "ti_w11-E: neither -s3/-n2/-n3 nor -t or -u specified\n";
  print_usage();
  print_usage();
  exit 1;
  exit 1;
}
}
#
#
# setup all other ti_rri options
# setup all other ti_rri options
#
#
push @arglist, '--logl=2';
push @arglist, '--logl=2';
push @arglist, '--int' unless $opt_b;
push @arglist, '--int' unless $opt_b;
push @arglist, '--pack=rw11';
push @arglist, '--pack=rw11';
push @arglist, '--';
push @arglist, '--';
#
#
# actions prior to first exec
# actions prior to first exec
#   setup tmu ect
#   setup tmu ect
#   setup access path --> handle -f options
#   setup access path --> handle -f options
#
#
if ($opt_io eq 'f') {
if ($opt_io eq 'f') {
  if ($opt_tmu) {
  if ($opt_tmu) {
    push @arglist, 'rlc oob -sbcntl 13   1';
    push @arglist, 'rlc oob -sbcntl 13   1';
  }
  }
  if ($opt_f eq 'u') {
  if ($opt_f eq 'u') {
    push @arglist, 'rlc oob -sbdata  8 0x2';
    push @arglist, 'rlc oob -sbdata  8 0x2';
    push @arglist, 'rlc oob -sbdata 16 0x4';
    push @arglist, 'rlc oob -sbdata 16 0x4';
  }
  }
}
}
#
#
# initialize w11 cpu system
# initialize w11 cpu system
#
#
push @arglist, 'rw11::setup_sys';
push @arglist, 'rw11::setup_sys';
#
#
# handle -e option
# handle -e option
#
#
if (defined $val_e) {
if (defined $val_e) {
  if ($val_e =~ m/\.mac$/) {
  if ($val_e =~ m/\.mac$/) {
    push @arglist, "cpu0 ldasm -file $val_e -sym ldasm_sym -lst ldasm_lst";
    push @arglist, "cpu0 ldasm -file $val_e -sym ldasm_sym -lst ldasm_lst";
  } else {
  } else {
    push @arglist, "cpu0 ldabs $val_e";
    push @arglist, "cpu0 ldabs $val_e";
  }
  }
  push @arglist, 'rw11::cpumon';
  push @arglist, 'rw11::cpumon';
  push @arglist, 'rw11::cpucons';
  push @arglist, 'rw11::cpucons';
  push @arglist, 'cpu0 cp -stapc 0200';
  push @arglist, 'cpu0 cp -stapc 0200';
}
}
#
#
# all remaining commands
# all remaining commands
#
#
while (scalar(@ARGV)) {
while (scalar(@ARGV)) {
  my $curarg = shift @ARGV;
  my $curarg = shift @ARGV;
  if ($curarg =~ m{^@(.*)$} && ! -r $1) {
  if ($curarg =~ m{^@(.*)$} && ! -r $1) {
    print STDERR "ti_w11-E: file '$1' not found\n";
    print STDERR "ti_w11-E: file '$1' not found\n";
    exit 1;
    exit 1;
  }
  }
  push @arglist,$curarg;
  push @arglist,$curarg;
}
}
#
#
# find ti_rri executable
# find ti_rri executable
#
#
$tirri=`which ti_rri`;
$tirri=`which ti_rri`;
chomp $tirri;
chomp $tirri;
if ($tirri eq '' || ! -e $tirri) {
if ($tirri eq '' || ! -e $tirri) {
  print STDERR "ti_w11-E: failed to locate ti_rri\n";
  print STDERR "ti_w11-E: failed to locate ti_rri\n";
  exit 1;
  exit 1;
}
}
#
#
# print command file
# print command file
#
#
if (1) {
if (1) {
 print 'ti_rri ', join (' ', map {(m{\s}) ? "\"$_\"" : $_} @arglist) , "\n";
 print 'ti_rri ', join (' ', map {(m{\s}) ? "\"$_\"" : $_} @arglist) , "\n";
}
}
#
#
# and do it
# and do it
#
#
exec $tirri, @arglist
exec $tirri, @arglist
  or die "failed to exec: $!";
  or die "failed to exec: $!";
exit 1;
exit 1;
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
sub print_usage {
sub print_usage {
  print "usage: ti_w11  ...\n";
  print "usage: ti_w11  ...\n";
  print "  setup options for ghdl simulation runs:\n";
  print "  setup options for ghdl simulation runs:\n";
  print "    -s3       start tb_w11a_s3 simulation\n";
  print "    -s3       start tb_w11a_s3 simulation\n";
  print "    -n2       start tb_w11a_n2 simulation\n";
  print "    -n2       start tb_w11a_n2 simulation\n";
  print "    -n3       start tb_w11a_n3 simulation\n";
  print "    -n3       start tb_w11a_n3 simulation\n";
  print "    -f..      simulation communication options\n";
  print "    -f..      simulation communication options\n";
  print "      -fu       use cuff data path\n";
  print "      -fu       use cuff data path\n";
  print "    -tmu      activate trace and monitoring unit\n";
  print "    -tmu      activate trace and monitoring unit\n";
  print "  setup options for FPGA connects:\n";
  print "  setup options for FPGA connects:\n";
  print "    -u        use --cuff connect\n";
  print "    -u        use --cuff connect\n";
  print "    -t..      use --term connect\n";
  print "    -t..      use --term connect\n";
  print "      -ts*[,opts]   use /dev/ttyS*   (* is device number)\n";
  print "      -ts*[,opts]   use /dev/ttyS*   (* is device number)\n";
  print "      -tu*[,opts]   use /dev/ttyUSB* (* is device number)\n";
  print "      -tu*[,opts]   use /dev/ttyUSB* (* is device number)\n";
  print "                    opts can be ',break', ',xon'\n";
  print "                    opts can be ',break', ',xon'\n";
  print "  common options:\n";
  print "  common options:\n";
  print "    -e  load and execute file\n";
  print "    -e  load and execute file\n";
  print "                file type '.mac': on the fly compile with asm-11\n";
  print "                file type '.mac': on the fly compile with asm-11\n";
  print "                any other file type: assume lda format\n";
  print "                any other file type: assume lda format\n";
  print "\n";
  print "\n";
  print "  either one of -s3,-n2, or -n3 must be given -> sim run\n";
  print "  either one of -s3,-n2, or -n3 must be given -> sim run\n";
  print "  or one of -t or -u must be given            -> fpga run\n";
  print "  or one of -t or -u must be given            -> fpga run\n";
}
}
 
 

powered by: WebSVN 2.1.0

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