Root/m1rc3/norruption/2/bscmp

Source at commit 57b53c61c1b37a913fc963c3c0bec0364efbcb7e created 10 years 1 month ago.
By Werner Almesberger, ircstat/ML: update for 2014-01
1#!/usr/bin/perl
2
3$REF = "standby.fpg"; # reference bitstream
4$LEN = 0x78dd0; # cut off trailing junk
5
6open(FILE, $REF) || die "$REF: $!";
7$ref = substr(join("", <FILE>), 0, $LEN);
8close FILE;
9
10die "reference bitstream is too short" unless length $ref == $LEN;
11
12for (@ARGV) {
13    open(FILE, $_) || die "$_: $!";
14    $c{$_} = substr(join("", <FILE>), 0, $LEN);
15    close FILE;
16    die "$_ is too short" unless length $c{$_} == $LEN;
17}
18
19# @@@ not quite perfect - we should extract the cycle numbers and sort by them
20
21for (sort keys %c) {
22    $n = 0;
23    @a = ();
24    for ($i = 0; $i != $LEN; $i += 2) {
25        next unless substr($ref, $i, 2) ne substr($c{$_}, $i, 2);
26        $r = unpack("B*", substr($ref, $i, 2));
27        $c = unpack("B*", substr($c{$_}, $i, 2));
28        if (defined $s{$i}) {
29            $s = " " x 26;
30        } else {
31            $s = sprintf("%05x ", $i);
32            for ($j = 19; $j >= 0; $j--) {
33                $s .= $i & (1 << $j) ? "1" : "_";
34            }
35        }
36        $s .= " | ";
37        for ($j = 0; $j != 16; $j++) {
38            $s .= " " if $j == 8;
39            $s .= substr($r, $j, 1) ?
40                substr($c, $j, 1) ? "1" : "0" :
41                substr($c, $j, 1) ? die : "_";
42# substr($c, $j, 1) ? "\033[7m \033[m" : "_";
43        }
44        if ($i >= 0x10) { # count only fatal corruptions
45            push(@a, $i);
46            $n++;
47        } else {
48            $s .= " | $_\n";
49        }
50        $s{$i} .= $s;
51    }
52    $i = 0;
53    for $a (@a) {
54        $i++;
55        $s{$a} .= " | $_ $i/$n\n";
56    }
57}
58
59for (sort { $a <=> $b } keys %s) {
60    print $s{$_};
61}
62

Archive Download this file

Branches:
master



interactive