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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [usbDevice/] [verilogCopy.pl] - Blame information for rev 43

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 37 sfielding
#!/usr/bin/perl -w
2
#
3
#
4
# USAGE: perl verilogCopy.pl [-i <inFile>] [-o <outFile>] 
5
#  -i <inFile> : Verilog input file
6
#  -0 <outFile> : Verilog output file
7
#  example: perl verilogCopy.pl -i inFileName -o outFileName
8
#
9
# Release notes:
10
# 0.1 initial release
11
 
12
use strict;
13
use sigtrap;
14
use Getopt::Std;
15
use constant TIMESTAMP => scalar localtime;
16
 
17
use Socket;
18
 
19
use FileHandle;
20
use File::stat;
21
 
22
my %options = ();
23
getopts( "o:i:t:",\%options );
24
 
25
my $gRespStr = "";
26
my @inFile;
27
my $filename;
28
my $myFileAsString;
29
our $outFile = new FileHandle;
30
our $inFileSt;
31
our $outFileSt;
32
 
33
 
34
my $version =  "verilogCopy   ";
35
 
36
#print( "$version\n" );
37
 
38
# --- open Verilog input file
39
if (defined $options{i} ) {
40
  $inFileSt = stat($options{i}) or die "Can't stat $options{i}: $!";
41
  #print ("\n in File mtime = ");
42
  #print $inFileSt->mtime;
43
  #print ("\n");
44
}
45
else {
46
  print ("Input file name missing. Use -i <inputFileName> \n");
47
  exit 1;
48
}
49
 
50
# --- open verilog output file
51
if (defined $options{o} ) {
52
  $outFileSt = stat($options{o}) or die "Can't stat $options{o}: $!";
53
  #print ("\n out File mtime = ");
54
  #print $outFileSt->mtime;
55
  #print ("\n");
56
}
57
else {
58
  print ("Output file name missing. Use -o <outputFileName> \n");
59
  exit 1;
60
}
61
 
62
 
63
$/ = undef;
64
 
65
  if ($outFileSt->mtime < $inFileSt->mtime) {
66
    @inFile = glob( $options{i} );
67
    $outFile->open(">$options{o}") or die("Cannot open write file!\n");
68
    slurpFile(\$myFileAsString, $inFile[0] );
69
    parseInputFile(\$myFileAsString);
70
    patchFile(\$myFileAsString, $inFile[0] );
71
    $outFile->print("$myFileAsString");
72
    $outFile->close();
73
    print( "\"$options{i}\" has been processed and copied to \"$options{o}\".\n" );
74
  }
75
  else {
76
    print ("Input file older than output file. No update required\n");
77
  }
78
 
79
 
80
 
81
#---------------------------------- slurpFile -------------------------------------------#
82
sub slurpFile
83
{
84
        my $fileAsString = shift();
85
        my $filename = shift();
86
        my $read  = new FileHandle;             # The input file
87
 
88
        $read->open( $filename ) or print( "Cannot open $filename for reading!\n" ) and return(0);
89
     $$fileAsString = $read->getline();     # Read in the entire file as a list
90
        $read->close() or die( "Cannot close $_!\n" );
91
        return(1);
92
}
93
 
94
 
95
#---------------------------------- parseInputFile -------------------------------------------#
96
sub parseInputFile
97
{
98
  my $fileAsString = shift();
99
 
100
  $$fileAsString =~ s/! =/!=/gs;      #patch ActiveHDL 4.2 FSM2HDL bug
101
  $$fileAsString =~ s/ = / <= /gs;    #patch ActiveHDL 4.2 FSM2HDL bug
102
  $$fileAsString =~ s/\r//gs;         #delete DOS carriage returns
103
  $$fileAsString =~ s/\t/  /gs;       #replace tabs with two spaces
104
 
105
 
106
}
107
 
108
#---------------------------------- patchFile -------------------------------------------#
109
sub patchFile
110
{
111
  my $fileAsString = shift();
112
  my $filename = shift();
113
 
114
  if ($filename =~ /spiCtrl.v/) {
115
    unless(
116
      $$fileAsString =~ s/\(spiTransCtrl or rxDataRdy/\(spiTransCtrl or rxDataRdy or spiTransType/
117
    ) {print "-------- ERROR, patch failed \n"; exit;}
118
    print ("--Patched $filename\n");
119
  }
120
  if ($filename =~ /readWriteSDBlock.v/) {
121
    unless(
122
      $$fileAsString =~ s/\(blockAddr or sendCmdRdy/\(blockAddr or sendCmdRdy or respTout or respByte/
123
    ) {print "-------- ERROR, patch failed \n"; exit;}
124
    print ("--Patched $filename\n");
125
  }
126
  if ($filename =~ /tx_pkt_sched.v/) {
127
    unless(
128
      $$fileAsString =~ s/\(buffLoadGnt or buffUnLoadGnt/\(buffLoadGnt or buffUnLoadGnt or txBufferLoaded/
129
    ) {print "-------- ERROR, patch failed \n"; exit;}
130
    print ("--Patched $filename\n");
131
  }
132
}
133
 
134
 
135
 
136
 
137
 

powered by: WebSVN 2.1.0

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