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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [usbDevice/] [verilogCopy.pl] - Diff between revs 37 and 40

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 37 Rev 40
#!/usr/bin/perl -w
#!/usr/bin/perl -w
#
#
#
#
# USAGE: perl verilogCopy.pl [-i <inFile>] [-o <outFile>] 
# USAGE: perl verilogCopy.pl [-i <inFile>] [-o <outFile>] 
#  -i <inFile> : Verilog input file
#  -i <inFile> : Verilog input file
#  -0 <outFile> : Verilog output file
#  -0 <outFile> : Verilog output file
#  example: perl verilogCopy.pl -i inFileName -o outFileName
#  example: perl verilogCopy.pl -i inFileName -o outFileName
#
#
# Release notes:
# Release notes:
# 0.1 initial release
# 0.1 initial release
 
 
use strict;
use strict;
use sigtrap;
use sigtrap;
use Getopt::Std;
use Getopt::Std;
use constant TIMESTAMP => scalar localtime;
use constant TIMESTAMP => scalar localtime;
 
 
use Socket;
use Socket;
 
 
use FileHandle;
use FileHandle;
use File::stat;
use File::stat;
 
 
my %options = ();
my %options = ();
getopts( "o:i:t:",\%options );
getopts( "o:i:t:",\%options );
 
 
my $gRespStr = "";
my $gRespStr = "";
my @inFile;
my @inFile;
my $filename;
my $filename;
my $myFileAsString;
my $myFileAsString;
our $outFile = new FileHandle;
our $outFile = new FileHandle;
our $inFileSt;
our $inFileSt;
our $outFileSt;
our $outFileSt;
 
 
 
 
my $version =  "verilogCopy   ";
my $version =  "verilogCopy   ";
 
 
#print( "$version\n" );
#print( "$version\n" );
 
 
# --- open Verilog input file
# --- open Verilog input file
if (defined $options{i} ) {
if (defined $options{i} ) {
  $inFileSt = stat($options{i}) or die "Can't stat $options{i}: $!";
  $inFileSt = stat($options{i}) or die "Can't stat $options{i}: $!";
  #print ("\n in File mtime = ");
  #print ("\n in File mtime = ");
  #print $inFileSt->mtime;
  #print $inFileSt->mtime;
  #print ("\n");
  #print ("\n");
}
}
else {
else {
  print ("Input file name missing. Use -i <inputFileName> \n");
  print ("Input file name missing. Use -i <inputFileName> \n");
  exit 1;
  exit 1;
}
}
 
 
# --- open verilog output file
# --- open verilog output file
if (defined $options{o} ) {
if (defined $options{o} ) {
  $outFileSt = stat($options{o}) or die "Can't stat $options{o}: $!";
  $outFileSt = stat($options{o}) or die "Can't stat $options{o}: $!";
  #print ("\n out File mtime = ");
  #print ("\n out File mtime = ");
  #print $outFileSt->mtime;
  #print $outFileSt->mtime;
  #print ("\n");
  #print ("\n");
}
}
else {
else {
  print ("Output file name missing. Use -o <outputFileName> \n");
  print ("Output file name missing. Use -o <outputFileName> \n");
  exit 1;
  exit 1;
}
}
 
 
 
 
$/ = undef;
$/ = undef;
 
 
  if ($outFileSt->mtime < $inFileSt->mtime) {
  if ($outFileSt->mtime < $inFileSt->mtime) {
    @inFile = glob( $options{i} );
    @inFile = glob( $options{i} );
    $outFile->open(">$options{o}") or die("Cannot open write file!\n");
    $outFile->open(">$options{o}") or die("Cannot open write file!\n");
    slurpFile(\$myFileAsString, $inFile[0] );
    slurpFile(\$myFileAsString, $inFile[0] );
    parseInputFile(\$myFileAsString);
    parseInputFile(\$myFileAsString);
    patchFile(\$myFileAsString, $inFile[0] );
    patchFile(\$myFileAsString, $inFile[0] );
    $outFile->print("$myFileAsString");
    $outFile->print("$myFileAsString");
    $outFile->close();
    $outFile->close();
    print( "\"$options{i}\" has been processed and copied to \"$options{o}\".\n" );
    print( "\"$options{i}\" has been processed and copied to \"$options{o}\".\n" );
  }
  }
  else {
  else {
    print ("Input file older than output file. No update required\n");
    print ("Input file older than output file. No update required\n");
  }
  }
 
 
 
 
 
 
#---------------------------------- slurpFile -------------------------------------------#
#---------------------------------- slurpFile -------------------------------------------#
sub slurpFile
sub slurpFile
{
{
        my $fileAsString = shift();
        my $fileAsString = shift();
        my $filename = shift();
        my $filename = shift();
        my $read  = new FileHandle;             # The input file
        my $read  = new FileHandle;             # The input file
 
 
        $read->open( $filename ) or print( "Cannot open $filename for reading!\n" ) and return(0);
        $read->open( $filename ) or print( "Cannot open $filename for reading!\n" ) and return(0);
     $$fileAsString = $read->getline();     # Read in the entire file as a list
     $$fileAsString = $read->getline();     # Read in the entire file as a list
        $read->close() or die( "Cannot close $_!\n" );
        $read->close() or die( "Cannot close $_!\n" );
        return(1);
        return(1);
}
}
 
 
 
 
#---------------------------------- parseInputFile -------------------------------------------#
#---------------------------------- parseInputFile -------------------------------------------#
sub parseInputFile
sub parseInputFile
{
{
  my $fileAsString = shift();
  my $fileAsString = shift();
 
 
  $$fileAsString =~ s/! =/!=/gs;      #patch ActiveHDL 4.2 FSM2HDL bug
  $$fileAsString =~ s/! =/!=/gs;      #patch ActiveHDL 4.2 FSM2HDL bug
  $$fileAsString =~ s/ = / <= /gs;    #patch ActiveHDL 4.2 FSM2HDL bug
  $$fileAsString =~ s/ = / <= /gs;    #patch ActiveHDL 4.2 FSM2HDL bug
  $$fileAsString =~ s/\r//gs;         #delete DOS carriage returns
  $$fileAsString =~ s/\r//gs;         #delete DOS carriage returns
  $$fileAsString =~ s/\t/  /gs;       #replace tabs with two spaces
  $$fileAsString =~ s/\t/  /gs;       #replace tabs with two spaces
 
 
 
 
}
}
 
 
#---------------------------------- patchFile -------------------------------------------#
#---------------------------------- patchFile -------------------------------------------#
sub patchFile
sub patchFile
{
{
  my $fileAsString = shift();
  my $fileAsString = shift();
  my $filename = shift();
  my $filename = shift();
 
 
  if ($filename =~ /spiCtrl.v/) {
  if ($filename =~ /spiCtrl.v/) {
    unless(
    unless(
      $$fileAsString =~ s/\(spiTransCtrl or rxDataRdy/\(spiTransCtrl or rxDataRdy or spiTransType/
      $$fileAsString =~ s/\(spiTransCtrl or rxDataRdy/\(spiTransCtrl or rxDataRdy or spiTransType/
    ) {print "-------- ERROR, patch failed \n"; exit;}
    ) {print "-------- ERROR, patch failed \n"; exit;}
    print ("--Patched $filename\n");
    print ("--Patched $filename\n");
  }
  }
  if ($filename =~ /readWriteSDBlock.v/) {
  if ($filename =~ /readWriteSDBlock.v/) {
    unless(
    unless(
      $$fileAsString =~ s/\(blockAddr or sendCmdRdy/\(blockAddr or sendCmdRdy or respTout or respByte/
      $$fileAsString =~ s/\(blockAddr or sendCmdRdy/\(blockAddr or sendCmdRdy or respTout or respByte/
    ) {print "-------- ERROR, patch failed \n"; exit;}
    ) {print "-------- ERROR, patch failed \n"; exit;}
    print ("--Patched $filename\n");
    print ("--Patched $filename\n");
  }
  }
  if ($filename =~ /tx_pkt_sched.v/) {
  if ($filename =~ /tx_pkt_sched.v/) {
    unless(
    unless(
      $$fileAsString =~ s/\(buffLoadGnt or buffUnLoadGnt/\(buffLoadGnt or buffUnLoadGnt or txBufferLoaded/
      $$fileAsString =~ s/\(buffLoadGnt or buffUnLoadGnt/\(buffLoadGnt or buffUnLoadGnt or txBufferLoaded/
    ) {print "-------- ERROR, patch failed \n"; exit;}
    ) {print "-------- ERROR, patch failed \n"; exit;}
    print ("--Patched $filename\n");
    print ("--Patched $filename\n");
  }
  }
}
}
 
 
 
 
 
 
 
 
 
 
 
 

powered by: WebSVN 2.1.0

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