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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [bin/] [xise_msg_filter] - Blame information for rev 33

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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