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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [tools/] [bin/] [ticonv_pdpcp] - Blame information for rev 19

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

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

powered by: WebSVN 2.1.0

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