From e1842c8da6a8a922317b93b11e646c516d9e84ac Mon Sep 17 00:00:00 2001 From: Ross Thompson Date: Tue, 23 Mar 2021 11:16:28 -0500 Subject: [PATCH] Broken commit. Trying to get exe2memfile.pl to work correctly with non 0x8000_0000 starting addresses. --- wally-pipelined/bin/exe2memfile.pl | 26 ++++++++++++------- .../config/busybear/wally-config.vh | 1 + .../config/coremark/wally-config.vh | 1 + .../config/coremark_bare/wally-config.vh | 1 + wally-pipelined/config/rv32ic/wally-config.vh | 1 + wally-pipelined/config/rv64ic/wally-config.vh | 1 + .../config/rv64icfd/wally-config.vh | 1 + .../testbench/testbench-imperas.sv | 3 +-- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/wally-pipelined/bin/exe2memfile.pl b/wally-pipelined/bin/exe2memfile.pl index 79b975c7..010e985d 100755 --- a/wally-pipelined/bin/exe2memfile.pl +++ b/wally-pipelined/bin/exe2memfile.pl @@ -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() { 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"); - } - if (/Disassembly of section .data:/) { $mode = 1;} + 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"; - if ($address > $maxaddress) { $maxaddress = $address; } +# 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) } } diff --git a/wally-pipelined/config/busybear/wally-config.vh b/wally-pipelined/config/busybear/wally-config.vh index 3a619598..cc3693f8 100644 --- a/wally-pipelined/config/busybear/wally-config.vh +++ b/wally-pipelined/config/busybear/wally-config.vh @@ -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 diff --git a/wally-pipelined/config/coremark/wally-config.vh b/wally-pipelined/config/coremark/wally-config.vh index 5f0714ae..74497064 100644 --- a/wally-pipelined/config/coremark/wally-config.vh +++ b/wally-pipelined/config/coremark/wally-config.vh @@ -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 diff --git a/wally-pipelined/config/coremark_bare/wally-config.vh b/wally-pipelined/config/coremark_bare/wally-config.vh index 8f2512f3..ce958ffd 100644 --- a/wally-pipelined/config/coremark_bare/wally-config.vh +++ b/wally-pipelined/config/coremark_bare/wally-config.vh @@ -97,3 +97,4 @@ `define TWO_BIT_PRELOAD "../config/coremark_bare/twoBitPredictor.txt" `define BTB_PRELOAD "../config/coremark_bare/BTBPredictor.txt" +`define TESTSBP 0 diff --git a/wally-pipelined/config/rv32ic/wally-config.vh b/wally-pipelined/config/rv32ic/wally-config.vh index 5ee1d170..fadbe36c 100644 --- a/wally-pipelined/config/rv32ic/wally-config.vh +++ b/wally-pipelined/config/rv32ic/wally-config.vh @@ -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 diff --git a/wally-pipelined/config/rv64ic/wally-config.vh b/wally-pipelined/config/rv64ic/wally-config.vh index c3f9849a..b27a5e1c 100644 --- a/wally-pipelined/config/rv64ic/wally-config.vh +++ b/wally-pipelined/config/rv64ic/wally-config.vh @@ -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 diff --git a/wally-pipelined/config/rv64icfd/wally-config.vh b/wally-pipelined/config/rv64icfd/wally-config.vh index 9b3dae29..853b8685 100644 --- a/wally-pipelined/config/rv64icfd/wally-config.vh +++ b/wally-pipelined/config/rv64icfd/wally-config.vh @@ -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 diff --git a/wally-pipelined/testbench/testbench-imperas.sv b/wally-pipelined/testbench/testbench-imperas.sv index 2f6f0efb..f62abdb4 100644 --- a/wally-pipelined/testbench/testbench-imperas.sv +++ b/wally-pipelined/testbench/testbench-imperas.sv @@ -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};