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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wfjm
#!/usr/bin/perl -w
2
# $Id: xilinx_tsim_xon 314 2010-07-09 17:38:41Z mueller $
3
#
4
# Copyright 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-05-06   289   1.0    Initial version
18
#
19
#
20
# Add "XON => false," defs in X_FF and X_SFF instances when name of the
21
# instance is matched by a regexp found in a descriptor file.
22
#
23
# Logic:
24
#   looks for lines like
25
#       : X_FF
26
#        generic map(
27
#   and adds
28
#      XON => false,   -- added by xilinx_tsim_xon tool --
29
#   if  is matched by a regexp found in file stem..tsim_xon_dat
30
#
31
#   all old 'XON => false' lines in input file are removed first, so this
32
#   tool can be rerun with changing desciptor files.
33
#
34
 
35
use strict;
36
 
37
my $stem = shift;
38
 
39
if (not defined $stem) {
40
  print "xilinx_tsim_xon-E: call with file stem\n";
41
  exit 1;
42
}
43
 
44
my $file_vhd = $stem . "_tsim.vhd";
45
my $file_dsc = $stem . ".tsim_xon_dat";
46
 
47
if (! -r $file_vhd) {
48
  print "xilinx_tsim_xon-E: $file_vhd not found or readable\n";
49
  exit 1;
50
}
51
if (! -r $file_dsc) {
52
  print "xilinx_tsim_xon-E: $file_dsc not found or readable\n";
53
  exit 1;
54
}
55
 
56
my @dsc_list;
57
open(DFILE, "<$file_dsc") || die ("Can't open descriptor file $file_dsc: $!");
58
while () {
59
  chomp;
60
  s/^\s*//;
61
  s/\s*$//;
62
  next if m/^#/;
63
  next if m/^$/;
64
  push @dsc_list, $_;
65
}
66
close(DFILE);
67
 
68
my $file_tmp = $stem . "_tsim_new.vhd";
69
open(OFILE, ">$file_tmp")  || die ("Can't open output file $file_tmp: $!");
70
open(IFILE, "<$file_vhd")  || die ("Can't open input file $file_vhd: $!");
71
 
72
my $match_1 = 0;
73
my $name_1;
74
 
75
while () {
76
  my $line = $_;
77
  next if m/-- added by xilinx_tsim_xon tool --$/;
78
  print OFILE $line;
79
  my $match = 0;
80
  my $name;
81
  if ($line =~ m/\s*([a-zA-Z0-9_]+)\s*:\s*(X_FF|X_SFF)/) {
82
    $name = $1;
83
    foreach my $pat (@dsc_list) {
84
      $match = 1 if ($name =~ m/^$pat$/);
85
    }
86
  }
87
  if ($match_1 && $line =~ m/generic map/) {
88
    ## print "xilinx_tsim_xon-I: XON=>false for $name_1\n";
89
    print OFILE
90
      "      XON => false,      -- added by xilinx_tsim_xon tool --\n";
91
  }
92
  $match_1 = $match;
93
  $name_1 = $name;
94
}
95
 
96
close(IFILE);
97
close(OFILE);
98
 
99
rename $file_tmp, $file_vhd or die  ("Can't rename $file_tmp: $!");

powered by: WebSVN 2.1.0

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