source: vis_dev/vis-2.3/share/visdbgpp @ 19

Last change on this file since 19 was 14, checked in by cecile, 13 years ago

vis2.3

  • Property svn:executable set to *
File size: 1.6 KB
RevLine 
[14]1#! /usr/bin/perl
2#
3# Postprocess debug file from vis
4#   Combine bus signals
5#
6# Author: Toshi Isogai
7#
8# $Id: visdbgpp,v 1.1 2001/03/14 20:10:04 hsv Exp $
9
10%sigval = ();
11
12while (<>) {
13  if (m{^([\w\.]+(<\*\d+\*>)?)<\d+>}) { # a (possibly partial) state
14    # get lines on the same bus
15    $sig = $1;
16    $val = $sigval{$sig};
17    # Quote the signal name when using it as pattern because it may
18    # contain the metacharacter '*'.
19    while (m{^\Q$sig\E<(\d+)>:(\d)}) {
20      $val = ($val & ~(1<<$1)) | ($2 << $1); # replace value on bit
21      $_ = <ARGV>;
22    }
23    printf "$sig:0x%X\n", $val;
24    $sigval{$sig} = $val;
25    redo;
26
27  } elsif (m{<}) {              # a CTL formula
28      # combine (xyz<a+1:a> * xyz<a-1>) into xyz<a+1:a-1>
29      while (m{\(([\w\.]+(<\*\d+\*>)?)<(\d+)(:(\d+))?>=(0x)?([\da-fA-F]+)
30               \s\*\s
31               \1<(\d+)>=(\d)\)}xg) {
32        $str = $&;              # entire matched string
33        $sig = $1;              # signal name
34        $msb = $3;              # most significant bit index
35        $lsb = $5;              # optional least significant bit index
36        $val = hex ($7);        # value of left-hand side
37        $newlsb = $8;           # index being added to the vector
38        $bit = $9;              # value of the new bit
39
40        if ($lsb eq '') {
41          # new start
42          $lsb = $msb;
43        }
44
45        if ($lsb == $newlsb+1 || $msb == $newlsb-1) {
46          $val = sprintf("%X",($val << 1) + $bit);
47
48          s{\Q$str\E}{$sig<$msb:$newlsb>=0x$val};
49
50        } else {
51          # warning
52          print (STDERR "Warning: Non concecutive bits at $.. ");
53          if ($msb == $lsb) {
54            print (STDERR "Bit $msb next to Bit $newlsb\n");
55          } else {
56            print (STDERR "MSB $msb LSB $lsb next to Bit $newlsb\n");
57          }
58        }
59
60      }
61
62  }
63  print;
64  last if eof();
65
66}
Note: See TracBrowser for help on using the repository browser.