forked from Github_Repos/cvw
cleanup
This commit is contained in:
parent
18fe5c7c93
commit
46d02d3818
@ -5,6 +5,9 @@
|
|||||||
# Converts an executable file to a series of 32-bit hex instructions
|
# Converts an executable file to a series of 32-bit hex instructions
|
||||||
# to read into a Verilog simulation with $readmemh
|
# to read into a Verilog simulation with $readmemh
|
||||||
|
|
||||||
|
use File::stat;
|
||||||
|
use IO::Handle;
|
||||||
|
|
||||||
if ($#ARGV == -1) {
|
if ($#ARGV == -1) {
|
||||||
die("Usage: $0 executable_file");
|
die("Usage: $0 executable_file");
|
||||||
}
|
}
|
||||||
@ -13,12 +16,27 @@ if ($#ARGV == -1) {
|
|||||||
my @memfilebytes = (0)*16384*4;
|
my @memfilebytes = (0)*16384*4;
|
||||||
my $maxaddress = 0;
|
my $maxaddress = 0;
|
||||||
|
|
||||||
|
STDOUT->autoflush(1);
|
||||||
|
print ("Processing $#ARGV memfiles: ");
|
||||||
|
my $frac = $#ARGV/10;
|
||||||
for(my $i=0; $i<=$#ARGV; $i++) {
|
for(my $i=0; $i<=$#ARGV; $i++) {
|
||||||
|
if ($i % $frac == 0) { print ("$i ") };
|
||||||
my $fname = $ARGV[$i];
|
my $fname = $ARGV[$i];
|
||||||
# print "fname = $fname";
|
# print "fname = $fname";
|
||||||
my $ofile = $fname.".objdump";
|
my $ofile = $fname.".objdump";
|
||||||
my $memfile = $fname.".memfile";
|
my $memfile = $fname.".memfile";
|
||||||
|
|
||||||
|
my $needsprocessing = 0;
|
||||||
|
if (!-e $memfile) { $needsprocessing = 1; } # create memfile if it doesn't exist
|
||||||
|
else {
|
||||||
|
my $osb = stat($ofile) || die("Can't stat $ofile");
|
||||||
|
my $msb = stat($memfile) || die("Can't stat $memfile");
|
||||||
|
my $otime = $osb->mtime;
|
||||||
|
my $mtime = $msb->mtime;
|
||||||
|
if ($otime > $mtime) { $needsprocessing = 1; } # is memfile out of date?
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($needsprocessing == 1) {
|
||||||
open(FILE, $ofile) || die("Can't read $ofile");
|
open(FILE, $ofile) || die("Can't read $ofile");
|
||||||
my $mode = 0; # parse for code
|
my $mode = 0; # parse for code
|
||||||
my $address;
|
my $address;
|
||||||
@ -81,6 +99,8 @@ for(my $i=0; $i<=$#ARGV; $i++) {
|
|||||||
close(MEMFILE);
|
close(MEMFILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
print("\n");
|
||||||
|
|
||||||
sub emitData {
|
sub emitData {
|
||||||
# print the data portion of the ELF into a memroy file, including 0s for empty stuff
|
# print the data portion of the ELF into a memroy file, including 0s for empty stuff
|
||||||
|
Loading…
Reference in New Issue
Block a user