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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [bin/] [isemsg_filter] - Blame information for rev 40

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

Line No. Rev Author Line
1 12 wfjm
#!/usr/bin/perl -w
2 22 wfjm
# $Id: isemsg_filter 550 2014-02-03 08:16:57Z mueller $
3 12 wfjm
#
4 22 wfjm
# Copyright 2011-2014 by Walter F.J. Mueller 
5 12 wfjm
#
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
# 2014-02-01   550   1.1.1  rename --pack to --pacc (accepted is meant here)
18 17 wfjm
# 2012-01-04   450   1.1    preliminary check for par 'all constraints met'
19 12 wfjm
# 2011-08-14   406   1.0    Initial version
20
#
21
 
22
use 5.005;                                  # require Perl 5.005 or higher
23
use strict;                                 # require strict checking
24
use FileHandle;
25
 
26
use Getopt::Long;
27
 
28
my %opts = ();
29
 
30 22 wfjm
GetOptions(\%opts, "help", "pacc") || exit 1;
31 12 wfjm
 
32
sub print_help;
33
sub read_mfs;
34
sub read_log;
35
 
36
my $type   = shift @ARGV;
37
my $mfsnam = shift @ARGV;
38
my $lognam = shift @ARGV;
39
my @flist;
40
my @mlist;
41
my $nackcnt = 0;
42
my $ackcnt  = 0;
43
my $misscnt = 0;
44
 
45
 
46
autoflush STDOUT 1;             # autoflush, so noting lost on exec later
47
 
48
if (exists $opts{help}) {
49
  print_help;
50
  exit 0;
51
}
52
 
53
if (!defined $type || !defined $mfsnam || !defined $lognam) {
54 22 wfjm
  print STDERR "%isemsg_filter-E: one of 'type mfset log' missing \n\n";
55 12 wfjm
  print_help;
56
  exit 1;
57
}
58
 
59
if ($type !~ m{^(xst|tra|map|par|twr|bgn)$}) {
60
  print STDERR "%isemsg_filter-E: type must be  xst,tra,map,par,twr, or bgn\n";
61
  exit 1;
62
}
63
 
64
if (read_mfs()) {exit 1;}
65
if (read_log()) {exit 1;}
66
 
67
foreach (@mlist) {
68
  my $msgorig = $_->[0];
69
  my $msgflat = $_->[1];
70
  my $msgmatch = 0;
71
  foreach (@flist) {
72
    my $filt = $_->[0];
73
    if ($msgflat =~ m{$filt}) {
74
      $_->[1] += 1;
75
      $msgmatch = 1;
76
      last;
77
    }
78
  }
79
  if ($msgmatch) {
80
    $_->[2] += 1;
81
  } else {
82
    $nackcnt += 1;
83
  }
84
}
85
 
86
if ($nackcnt) {
87 22 wfjm
  print "Unexpected messages of type [$type] from $lognam:\n";
88 12 wfjm
  foreach (@mlist) {
89
    next if $_->[2];
90
    print $_->[0] . "\n";
91
  }
92
  print "\n";
93
}
94
 
95
foreach (@flist) {
96
  if ($_->[1]) {
97
    $ackcnt  += 1;
98
  } else {
99
    $misscnt += 1;
100
  }
101
}
102
 
103 22 wfjm
if ($ackcnt && exists $opts{pacc}) {
104
  print "Accepted messages of type [$type] from $lognam:\n";
105 12 wfjm
  foreach (@flist) {
106
    next if $_->[1] == 0;
107
    printf "%4d: %s\n", $_->[1], $_->[0];
108
  }
109
  print "\n";
110
}
111
 
112
if ($misscnt) {
113 22 wfjm
  print "Missed messages of type [$type] from $lognam:\n";
114 12 wfjm
  foreach (@flist) {
115
    next if $_->[1] != 0;
116
    printf "%4d: %s\n", $_->[1], $_->[0];
117
  }
118
  print "\n";
119
}
120
 
121
#-------------------------------------------------------------------------------
122
sub read_mfs {
123
  if (not -r $mfsnam) {
124
    print STDERR "%isemsg_filter-E: \'$mfsnam\' not existing or readable\n";
125
    return 1;
126
  }
127
 
128
  open (FFILE, $mfsnam)    or die "can't open for read $mfsnam: $!";
129
 
130
  my $intyp = 0;
131
 
132
  while () {
133
    chomp;
134
    next if /^\s*#/;                        # drop comments
135
    next if /^\s*$/;                        # drop empty lines
136
 
137
    if (m{^\[([a-z]{3})\]$}) {
138
      if ($1 eq $type) {
139
        $intyp = 1;
140
      } else {
141
        $intyp = 0;
142
      }
143
    } else {
144
      if ($intyp) {
145
        push @flist, [$_, 0];
146
      }
147
    }
148
  }
149
 
150
  close (FFILE);
151 17 wfjm
 
152 12 wfjm
  return 0;
153
}
154
 
155
#-------------------------------------------------------------------------------
156
sub read_log {
157
  if (not -r $lognam) {
158
    print STDERR "%isemsg_filter-E: \'$lognam\' not existing or readable\n";
159
    return 1;
160
  }
161
 
162
  open (LFILE, $lognam)    or die "can't open for read $lognam: $!";
163
 
164
  my $msgorig = "";
165
  my $msgflat = "";
166
  my $inmsg = 0;
167 17 wfjm
  my $parallmet = 0;
168 12 wfjm
 
169
  while () {
170
    chomp;
171 17 wfjm
 
172
    $parallmet = 1 if ($type eq "par" && m/All c/);
173
 
174 12 wfjm
    if (m{^(INFO|WARNING|ERROR):}) {
175
      if ($inmsg) {push @mlist, [$msgorig, $msgflat, 0];}
176
      $inmsg = 1;
177
      $msgorig = $_;
178
      $msgflat = $_;
179
    } elsif ($inmsg && m{^\s\s\s\S}) {
180
      $msgorig .= "\n" . $_;
181
      my $txt = $_;
182
      $txt =~ s{\s\s}{};                    # replace 3 leading blanks by one !
183
      $msgflat .= $txt;
184
    } else {
185
      if ($inmsg) {push @mlist, [$msgorig, $msgflat, 0];}
186
      $inmsg = 0;
187
    }
188
  }
189
 
190
  if ($inmsg) {push @mlist, [$msgorig, $msgflat, 0];}
191
 
192
  close (LFILE);
193
 
194 17 wfjm
  if ($type eq "par" && $parallmet==0) {
195
    printf "!! ----------------------------------- !!\n";
196
    printf "!! par: FAILED TO REACH TIMING CLOSURE !!\n";
197
    printf "!! ----------------------------------- !!\n";
198
  }
199
 
200 12 wfjm
  return 0;
201
}
202
 
203
#-------------------------------------------------------------------------------
204
 
205
sub print_help {
206 22 wfjm
  print "usage: isemsg_filter [options] type mfset log\n";
207
  print "  type   log file type: xst,tra,map,par,twr, or bgn\n";
208
  print "  mfset  message filter set file\n";
209
  print "  log    log file\n";
210 12 wfjm
  print "  Options:\n";
211 22 wfjm
  print "    --pacc           print summary of accepted messages\n";
212 12 wfjm
  print "    --help           this message\n";
213
}

powered by: WebSVN 2.1.0

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