mirror of
https://github.com/wfjm/w11.git
synced 2026-03-07 19:51:43 +00:00
91 lines
2.2 KiB
Perl
Executable File
91 lines
2.2 KiB
Perl
Executable File
#!/usr/bin/perl -w
|
|
# $Id: xilinx_tsim_xon 1172 2019-06-29 07:27:24Z mueller $
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
# Copyright 2010-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
|
#
|
|
# Revision History:
|
|
# Date Rev Version Comment
|
|
# 2010-05-06 289 1.0 Initial version
|
|
#
|
|
#
|
|
# Add "XON => false," defs in X_FF and X_SFF instances when name of the
|
|
# instance is matched by a regexp found in a descriptor file.
|
|
#
|
|
# Logic:
|
|
# looks for lines like
|
|
# <name> : X_FF
|
|
# generic map(
|
|
# and adds
|
|
# XON => false, -- added by xilinx_tsim_xon tool --
|
|
# if <name> is matched by a regexp found in file stem..tsim_xon_dat
|
|
#
|
|
# all old 'XON => false' lines in input file are removed first, so this
|
|
# tool can be rerun with changing desciptor files.
|
|
#
|
|
|
|
use strict;
|
|
|
|
my $stem = shift;
|
|
|
|
if (not defined $stem) {
|
|
print "xilinx_tsim_xon-E: call with file stem\n";
|
|
exit 1;
|
|
}
|
|
|
|
my $file_vhd = $stem . "_tsim.vhd";
|
|
my $file_dsc = $stem . ".tsim_xon_dat";
|
|
|
|
if (! -r $file_vhd) {
|
|
print "xilinx_tsim_xon-E: $file_vhd not found or readable\n";
|
|
exit 1;
|
|
}
|
|
if (! -r $file_dsc) {
|
|
print "xilinx_tsim_xon-E: $file_dsc not found or readable\n";
|
|
exit 1;
|
|
}
|
|
|
|
my @dsc_list;
|
|
open(DFILE, "<$file_dsc") || die ("Can't open descriptor file $file_dsc: $!");
|
|
while (<DFILE>) {
|
|
chomp;
|
|
s/^\s*//;
|
|
s/\s*$//;
|
|
next if m/^#/;
|
|
next if m/^$/;
|
|
push @dsc_list, $_;
|
|
}
|
|
close(DFILE);
|
|
|
|
my $file_tmp = $stem . "_tsim_new.vhd";
|
|
open(OFILE, ">$file_tmp") || die ("Can't open output file $file_tmp: $!");
|
|
open(IFILE, "<$file_vhd") || die ("Can't open input file $file_vhd: $!");
|
|
|
|
my $match_1 = 0;
|
|
my $name_1;
|
|
|
|
while (<IFILE>) {
|
|
my $line = $_;
|
|
next if m/-- added by xilinx_tsim_xon tool --$/;
|
|
print OFILE $line;
|
|
my $match = 0;
|
|
my $name;
|
|
if ($line =~ m/\s*([a-zA-Z0-9_]+)\s*:\s*(X_FF|X_SFF)/) {
|
|
$name = $1;
|
|
foreach my $pat (@dsc_list) {
|
|
$match = 1 if ($name =~ m/^$pat$/);
|
|
}
|
|
}
|
|
if ($match_1 && $line =~ m/generic map/) {
|
|
## print "xilinx_tsim_xon-I: XON=>false for $name_1\n";
|
|
print OFILE
|
|
" XON => false, -- added by xilinx_tsim_xon tool --\n";
|
|
}
|
|
$match_1 = $match;
|
|
$name_1 = $name;
|
|
}
|
|
|
|
close(IFILE);
|
|
close(OFILE);
|
|
|
|
rename $file_tmp, $file_vhd or die ("Can't rename $file_tmp: $!");
|