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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [bin/] [xst_count_bels] - Blame information for rev 24

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wfjm
#!/usr/bin/perl -w
2
# $Id: xst_count_bels 314 2010-07-09 17:38:41Z mueller $
3
#
4
# Copyright 2007-2010 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
# 2010-04-26   284   1.2.1  add error check for GetOptions
18
# 2007-10-28    93   1.2    added -xsts (_ssim based device summary)
19
# 2007-06-30    62   1.1    fixed parser, now all bels counted
20
# 2007-06-16    57   1.0    Initial version
21
 
22
use 5.005;                                  # require Perl 5.005 or higher
23
use strict;                                 # require strict checking
24
 
25
use Getopt::Long;
26
 
27
sub do_file;
28
 
29
my %opts = ();
30
 
31
GetOptions(\%opts, "xstl", "xsts")
32
  or die "bad options";
33
 
34
my $do_xstl  = defined $opts{xstl};
35
my $do_xsts  = defined $opts{xsts};
36
my $do_plain = not ($do_xstl or $do_xsts);
37
 
38
foreach (@ARGV) { do_file($_); }
39
 
40
#-------------------------------------------------------------------------------
41
 
42
sub do_file {
43
  my ($filename) = @_;
44
  my %bels;
45
  my $cur_bel;
46
 
47
  open (IFILE, $filename)    or die "can't open for read $filename";
48
  while() {
49
    chomp;
50
    if (m{^\s*[a-zA-Z0-9_]+\s*:\s*([a-zA-Z0-9_]+)\s*$}) {
51
      $cur_bel = $1;
52
    } elsif (m{\s*(generic|port)\s+map\s*\(\s*}) {
53
      $bels{$cur_bel} += 1 if $cur_bel;
54
    } else {
55
      $cur_bel = "";
56
    }
57
  }
58
  close (IFILE);
59
 
60
  if ($do_plain) {
61
    foreach (sort keys %bels) {
62
      printf "%16s : %5d\n", $_, $bels{$_};
63
    }
64
  }
65
 
66
  if ($do_xsts) {
67
    my $n_flop = 0;
68
    my $n_luts = 0;
69
    my $n_luts_log = 0;
70
    my $n_luts_ram = 0;
71
    my $n_bram = 0;
72
    my $n_mult = 0;
73
    my $n_iob  = 0;
74
 
75
    foreach (sort keys %bels) {
76
      if (/^FD/) {
77
        $n_flop += $bels{$_};
78
      } elsif (/^LUT/) {
79
        $n_luts += $bels{$_};
80
        $n_luts_log += $bels{$_};
81
      } elsif (/^RAMB/) {
82
        $n_bram += $bels{$_};
83
      } elsif (/^RAM\d*X.*D$/) {
84
        $n_luts += 2 * $bels{$_};
85
        $n_luts_ram += 2 * $bels{$_};
86
      } elsif (/^RAM\d*X.*S$/) {
87
        $n_luts += $bels{$_};
88
        $n_luts_ram += $bels{$_};
89
      } elsif (/^[IO]BUF$/) {
90
        $n_iob += $bels{$_};
91
      } elsif (/^MULT/) {
92
        $n_mult += $bels{$_};
93
      }
94
    }
95
 
96
    print  "Device utilization summary (_ssim BELS scan):\n";
97
    print  "---------------------------------------------\n";
98
    printf " Number of Flip Flops:      %5d\n", $n_flop;
99
    printf " Number of LUTs:            %5d\n", $n_luts;
100
    printf "    Number used as logic:   %5d\n", $n_luts_log;
101
    printf "    Number used as RAMs:    %5d\n", $n_luts_ram;
102
    printf " Number of bonded IOBs:     %5d\n", $n_iob;
103
    printf " Number of BRAMs:           %5d\n", $n_bram;
104
    printf " Number of MULT18X18s:      %5d\n", $n_mult;
105
  }
106
}

powered by: WebSVN 2.1.0

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