Broken commit. Trying to get exe2memfile.pl to work correctly with non 0x8000_0000 starting addresses.

This commit is contained in:
Ross Thompson 2021-03-23 11:16:28 -05:00
parent 1d6a2989ed
commit e1842c8da6
8 changed files with 23 additions and 12 deletions

View File

@ -43,43 +43,48 @@ for(my $i=0; $i<=$#ARGV; $i++) {
my $address;
# initialize to all zeros;
# *** need to fix the zeroing range. Not always 64K
for (my $i=0; $i < 65536*4; $i++) {
$memfilebytes[$i] = "00";
}
while(<FILE>) {
if ($mode == 0) { # Parse code
# print("Examining $_\n");
if (/^\s*(\S\S\S\S\S\S\S\S):\s+(\S+)\s+/) {
# print("Examining $_\n");
if (/^\s*(\S{1,16}):\s+(\S+)\s+/) {
$address = &fixadr($1);
my $instr = $2;
my $len = length($instr);
for (my $i=0; $i<$len/2; $i++) {
$memfilebytes[$address+$i] = substr($instr, $len-2-2*$i, 2);
}
# print ("address $address $instr\n");
print ("address $address $instr\n");
}
if (/Disassembly of section .data:/) { $mode = 1;}
} elsif ($mode == 1) { # Parse data segment
if (/^\s*(\S\S\S\S\S\S\S\S):\s+(.*)/) {
if (/^\s*(\S{1,16}):\s+(.*)/) {
$address = &fixadr($1);
# print "addresss $address maxaddress $maxaddress\n";
# print "addresss $address maxaddress $maxaddress\n";
if ($address > $maxaddress) { $maxaddress = $address; }
my $line = $2;
# merge chunks with spaces
# *** might need to change
$line =~ s/(\S)\s(\S)/$1$2/g;
# strip off comments
$line =~ /^(\S*)/;
$payload = $1;
&emitData($address, $payload);
}
if (/Disassembly of section .riscv.attributes:/) { $mode = 2; }
if (/Disassembly of section .comment:/) { $mode = 2; }
} elsif ($mode == 2) { # parse the comment section
if (/Disassembly of section .riscv.attributes:/) { $mode = 3; }
}
}
close(FILE);
$maxaddress += 32; # pad some zeros at the end
# print to memory file
# *** this is a problem
if ($fname =~ /rv32/) {
open(MEMFILE, ">$memfile") || die("Can't write $memfile");
for (my $i=0; $i<= $maxaddress; $i = $i + 4) {
@ -133,7 +138,8 @@ sub emitData {
sub fixadr {
# strip off leading 8 from address and convert to decimal
# if the leading 8 is not present don't remove.
my $adr = shift;
if ($adr =~ s/^8/0/) { return hex($adr); }
else { die("address $adr lacks leading 8\n"); }
else { return hex($adr) }
}

View File

@ -99,3 +99,4 @@
`define TWO_BIT_PRELOAD "../config/busybear/twoBitPredictor.txt"
`define BTB_PRELOAD "../config/busybear/BTBPredictor.txt"
`define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE
`define TESTSBP 0

View File

@ -101,3 +101,4 @@
`define TWO_BIT_PRELOAD "../config/coremark/twoBitPredictor.txt"
`define BTB_PRELOAD "../config/coremark/BTBPredictor.txt"
`define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE
`define TESTSBP 0

View File

@ -97,3 +97,4 @@
`define TWO_BIT_PRELOAD "../config/coremark_bare/twoBitPredictor.txt"
`define BTB_PRELOAD "../config/coremark_bare/BTBPredictor.txt"
`define TESTSBP 0

View File

@ -95,3 +95,4 @@
`define TWO_BIT_PRELOAD "../config/rv32ic/twoBitPredictor.txt"
`define BTB_PRELOAD "../config/rv32ic/BTBPredictor.txt"
`define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE
`define TESTSBP 0

View File

@ -98,3 +98,4 @@
`define TWO_BIT_PRELOAD "../config/rv64ic/twoBitPredictor.txt"
`define BTB_PRELOAD "../config/rv64ic/BTBPredictor.txt"
`define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE
`define TESTSBP 0

View File

@ -98,3 +98,4 @@
`define TWO_BIT_PRELOAD "../config/rv64icfd/twoBitPredictor.txt"
`define BTB_PRELOAD "../config/rv64icfd/BTBPredictor.txt"
`define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE
`define TESTSBP 0

View File

@ -28,7 +28,6 @@
module testbench();
parameter DEBUG = 0;
parameter TESTSBP = 0;
logic clk;
logic reset;
@ -337,7 +336,7 @@ string tests32i[] = {
// pick tests based on modes supported
initial
if (`XLEN == 64) begin // RV64
if(TESTSBP) begin
if(`TESTSBP) begin
tests = testsBP64;
end else begin
tests = {tests64i};