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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [bin/] [ticonv_pdpcp] - Blame information for rev 25

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

Line No. Rev Author Line
1 19 wfjm
#!/usr/bin/perl -w
2 22 wfjm
# $Id: ticonv_pdpcp 521 2013-05-20 22:16:45Z mueller $
3 19 wfjm
#
4
# Copyright 2013- by Walter F.J. Mueller 
5
#
6
# This program is free software; you may redistribute and/or modify it under
7
# the terms of the GNU General Public License as published by the Free
8
# Software Foundation, either version 2, or at your option any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
12
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13
# for complete details.
14
#
15
#  Revision History:
16
# Date         Rev Version  Comment
17 22 wfjm
# 2013-05-19   521   1.0.3  use -be subopt of -wibrb
18 19 wfjm
# 2013-04-12   504   1.0.2  renamed from pi2ti_pdpcp; fix [rm]wi handling
19
#                           use wtcpu command; use wibrbbe command;
20
# 2013-02-05   483   1.0.1  make cpucmd parametrizable
21
# 2013-02-02   480   1.0    Initial version
22
#
23
 
24
use 5.005;                                  # require Perl 5.005 or higher
25
use strict;                                 # require strict checking
26
 
27
use Getopt::Long;
28
 
29
my %opts = ();
30
 
31
GetOptions(\%opts  ) || exit 1;
32
 
33
if (scalar(@ARGV) != 2) {
34
  print STDERR "%ticonv_pdpcp-E: usage: ticonv_pdpcp  \n";
35
  exit 1;
36
}
37
 
38
my $cpu  = $ARGV[0];
39
my $fnam = $ARGV[1];
40
open IFILE, $fnam or die "failed to open '$fnam'";
41
 
42
while () {
43
  chomp;
44
  s/--.*//;                                 # drop all -- style comments
45
  s/\s*$//;                                 # drop traing blanks
46
  next if m/^#/;
47
 
48
  # print "$_\n";
49
 
50
  my $cmd = $_;
51
 
52
  $cmd =~ s/^rsp/rr6/;                      # rsp -> rr6
53
  $cmd =~ s/^rpc/rr7/;                      # rpc -> rr7
54
  $cmd =~ s/^wsp/wr6/;                      # wsp -> wr6
55
  $cmd =~ s/^wpc/wr7/;                      # wpc -> wr7
56
 
57
  # C... comments -> write to rlc log --------------------------------
58
  if ($cmd =~ /^C(.*)/) {
59
    my $msg = $1;
60
    $msg =~ s/"/'/g;
61
    $msg =~ s/\[/\{/g;
62
    $msg =~ s/\]/\}/g;
63
    print "rlc log \"C $msg\"\n";
64
 
65
  # .tocmd,.tostp,.togo,.cerr,.merr -> ignore, like pi_rri -----------
66
  } elsif ($cmd =~ /^\.(tocmd|tostp|togo|[cm]err)\s+(\d*)/) {
67
    print "# $cmd currently ignored\n";
68
 
69
  # .mode mode -> accept only 'pdpcp', quit otherwise ----------------
70
  } elsif ($cmd =~ /^\.mode\s+(.*)/) {
71
    if ($1 ne "pdpcp") {
72
      print "# FAIL: $cmd not supported\n";
73
      exit 1;
74
    }
75
 
76
  # .rlmon,.rbmon ----------------------------------------------------
77
  } elsif ($cmd =~ /^\.(r[lb]mon)\s+(\d)/) {
78
    print "rlc oob -$1 $2\n";
79
 
80
  # .scntl -----------------------------------------------------------
81
  } elsif ($cmd =~ /^\.scntl\s+(\d+)\s+(\d)/) {
82
    print "rlc oob -sbcntl $1 $2\n";
83
 
84
  # .anena (0|1) -> rlc exec -init -----------------------------------
85
  } elsif ($cmd =~ /^\.anena\s+(\d)/) {
86
    my $dat = $1 ? '[regbld rlink::INIT anena]' : '0';
87
    print "rlc exec -init 0xff $dat\n";
88
    print "rlc exec -attn\n";
89
 
90
  # .reset -----------------------------------------------------------
91
  } elsif ($cmd =~ /^\.reset/) {
92
    print "rlc exec -init 0 1\n";
93
 
94
  # (write) data type commands: wrx,wps,wal,wah,wm,wmi,stapc ---
95
  # Note: 'stapc' must be decoeded before 'sta' !!
96
  # Note: 'wibrb' must be handled separately
97
  # Note: 'wmi' must be matched before 'wm'
98
  } elsif ($cmd =~ /^(wr[0-7]|wps|wal|wah|wmi|wm|stapc)\s+([0-7]+)/) {
99
    print "$cpu cp -$1 0$2\n";
100
 
101
  # (write) data type commands: wibrb ---
102
  } elsif ($cmd =~ /^(wibrb)\s+([0-7]+)/) {
103
    my $base = oct($2);
104
    my $be   = $base & 0x3;
105
    if ($be == 0) {
106
      print "$cpu cp -wibrb 0$2\n";
107
    } else {
108 22 wfjm
      printf "$cpu cp -wibrb 0%6.6o -be %o\n", $base&0177700, $be;
109 19 wfjm
    }
110
 
111
  # (read) [d=data] type commands: rrx,rps,rm,rmi --------------------
112
  # Note: 'rmi' must be matched before 'rm'
113
  } elsif ($cmd =~ /^(rr[0-7]|rps|rmi|rm)/) {
114
    print "$cpu cp -$1 ";
115
    add_edata($');
116
    print "\n";
117
 
118
  # bwm n ------------------------------------------------------------
119
  } elsif ($cmd =~ /^bwm\s+(\d+)/) {
120
    my $nw = $1;
121
    print "$cpu cp -bwm {";
122
    for (my $i=0; $i<$nw;) {
123
      my $dat = ;
124
      $dat =~ s/--.*//;
125
      $dat =~ s/\s*//g;
126
      next if $dat =~ m/^#/;
127
      print " 0$dat";
128
      $i++;
129
    }
130
    print "}\n";
131
 
132
  # brm n ------------------------------------------------------------
133
  } elsif ($cmd =~ /^brm\s+(\d+)/) {
134
    my $nw = $1;
135
    print "$cpu cp -brm $1";
136
    my @data;
137
    my @mask;
138
    my $domask;
139
    for (my $i=0; $i<$nw;) {
140
      my $dat = ;
141
      $dat =~ s/--.*//;
142
      $dat =~ s/\s*//g;
143
      next if $dat =~ m/^#/;
144
      if ($dat =~ m/d=([0-7]+)/ ) {
145
        push @data, "0$1";
146
        push @mask, "0";
147
      } elsif ($dat =~ m/d=-/) {
148
        push @data, "0";
149
        push @mask, "0177777";
150
        $domask = 1;
151
      } else {
152
        exit 1;
153
      }
154
      $i++;
155
    }
156
    print " -edata {", join(" ",@data), "} ";
157
    print " {", join(" ",@mask), "} " if $domask;
158
    print "\n";
159
 
160
  # wibr off data ---------------------------------------------------
161
  } elsif ($cmd =~ /^(wibr)\s+([0-7]+)\s+([0-7]+)/) {
162
    print "$cpu cp -$1 0$2 0$3";
163
    print "\n";
164
 
165
  # ribr off [d=data] ------------------------------------------------
166
  } elsif ($cmd =~ /^(ribr)\s+([0-7]+)/) {
167
    print "$cpu cp -$1 0$2";
168
    add_edata($');
169
    print "\n";
170
 
171
  # simple action commands: sta,sto,cont,step,rst --------------------
172
  } elsif ($cmd =~ /^(sta|sto|cont|step|rst)/) {
173
    my %cmdmap = (sta  => 'start',
174
                  sto  => 'stop',
175
                  cont => 'continue',
176
                  step => 'step',
177
                  rst  => 'reset');
178
    printf "$cpu cp -%s", $cmdmap{$1};
179
    print "\n";
180
 
181
  # wtgo -> wtcpu ----------------------------------------------------
182
  } elsif ($cmd =~ /^(wtgo)/) {
183
    print "$cpu wtcpu 10.";
184
    print "\n";
185
 
186
  # wtlam apat -------------------------------------------------------
187
  # Note: apat currently ignored !!
188
  } elsif ($cmd =~ /^(wtlam)/) {
189
    print "$cpu wtcpu 10.";
190
    print "\n";
191
 
192
  # currently unimplemented commands ... -----------------------------
193
  } elsif ($cmd =~ /^(\.wait|\.sdef)/) {
194
    print "## TODO... $cmd\n";
195
 
196
  } else {
197
    print "# FAIL: no match for '$cmd'\n";
198
    exit 1;
199
  }
200
 
201
}
202
 
203
sub add_edata {
204
  my ($crest) = @_;
205
  $crest =~ s/\s+//;
206
  if ($crest =~ m/d=([0-7]+)/) {
207
    print " -edata 0$1";
208
  }
209
}

powered by: WebSVN 2.1.0

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