forked from Github_Repos/cvw
		
	Broken commit. Trying to get exe2memfile.pl to work correctly with non 0x8000_0000 starting addresses.
This commit is contained in:
		
							parent
							
								
									1d6a2989ed
								
							
						
					
					
						commit
						e1842c8da6
					
				| @ -43,43 +43,48 @@ for(my $i=0; $i<=$#ARGV; $i++) { | |||||||
|         my $address; |         my $address; | ||||||
| 
 | 
 | ||||||
|     # initialize to all zeros; |     # initialize to all zeros; | ||||||
|  | 	# *** need to fix the zeroing range.  Not always 64K | ||||||
|         for (my $i=0; $i < 65536*4; $i++) { |         for (my $i=0; $i < 65536*4; $i++) { | ||||||
|             $memfilebytes[$i] = "00"; |             $memfilebytes[$i] = "00"; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         while(<FILE>) { |         while(<FILE>) { | ||||||
|             if ($mode == 0) { # Parse code |             if ($mode == 0) { # Parse code | ||||||
|     #	    print("Examining $_\n"); | #	    print("Examining $_\n"); | ||||||
|             if (/^\s*(\S\S\S\S\S\S\S\S):\s+(\S+)\s+/) { | 		if (/^\s*(\S{1,16}):\s+(\S+)\s+/) { | ||||||
|                     $address = &fixadr($1); |                     $address = &fixadr($1); | ||||||
|                     my $instr = $2; |                     my $instr = $2; | ||||||
|                     my $len = length($instr); |                     my $len = length($instr); | ||||||
|                     for (my $i=0; $i<$len/2; $i++) { |                     for (my $i=0; $i<$len/2; $i++) { | ||||||
|                         $memfilebytes[$address+$i] = substr($instr, $len-2-2*$i, 2); |                         $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;} | 		if (/Disassembly of section .data:/) { $mode = 1;} | ||||||
|             } elsif ($mode == 1) { # Parse data segment |             } 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); |                     $address = &fixadr($1); | ||||||
|     #		print "addresss $address maxaddress $maxaddress\n"; | #		        print "addresss $address maxaddress $maxaddress\n"; | ||||||
|             if ($address > $maxaddress) { $maxaddress = $address; } | 		    if ($address > $maxaddress) { $maxaddress = $address; } | ||||||
|                     my $line = $2; |                     my $line = $2; | ||||||
|                     # merge chunks with spaces |                     # merge chunks with spaces | ||||||
|  | 		    # *** might need to change | ||||||
|                     $line =~ s/(\S)\s(\S)/$1$2/g; |                     $line =~ s/(\S)\s(\S)/$1$2/g; | ||||||
|                     # strip off comments |                     # strip off comments | ||||||
|                     $line =~ /^(\S*)/; |                     $line =~ /^(\S*)/; | ||||||
|                     $payload = $1; |                     $payload = $1; | ||||||
|                     &emitData($address, $payload); |                     &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); |         close(FILE); | ||||||
|         $maxaddress += 32; # pad some zeros at the end |         $maxaddress += 32; # pad some zeros at the end | ||||||
| 
 | 
 | ||||||
|         # print to memory file |         # print to memory file | ||||||
|  | 	# *** this is a problem | ||||||
|         if ($fname =~ /rv32/) { |         if ($fname =~ /rv32/) { | ||||||
|         open(MEMFILE, ">$memfile") || die("Can't write $memfile"); |         open(MEMFILE, ">$memfile") || die("Can't write $memfile"); | ||||||
|         for (my $i=0; $i<= $maxaddress; $i = $i + 4) { |         for (my $i=0; $i<= $maxaddress; $i = $i + 4) { | ||||||
| @ -133,7 +138,8 @@ sub emitData { | |||||||
| 
 | 
 | ||||||
| sub fixadr { | sub fixadr { | ||||||
|     # strip off leading 8 from address and convert to decimal |     # strip off leading 8 from address and convert to decimal | ||||||
|  |     # if the leading 8 is not present don't remove. | ||||||
|     my $adr = shift; |     my $adr = shift; | ||||||
|     if ($adr =~ s/^8/0/) { return hex($adr); } |     if ($adr =~ s/^8/0/) { return hex($adr); } | ||||||
|     else { die("address $adr lacks leading 8\n"); } |     else { return hex($adr) } | ||||||
| } | } | ||||||
|  | |||||||
| @ -99,3 +99,4 @@ | |||||||
| `define TWO_BIT_PRELOAD "../config/busybear/twoBitPredictor.txt" | `define TWO_BIT_PRELOAD "../config/busybear/twoBitPredictor.txt" | ||||||
| `define BTB_PRELOAD "../config/busybear/BTBPredictor.txt" | `define BTB_PRELOAD "../config/busybear/BTBPredictor.txt" | ||||||
| `define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE | `define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE | ||||||
|  | `define TESTSBP 0 | ||||||
|  | |||||||
| @ -101,3 +101,4 @@ | |||||||
| `define TWO_BIT_PRELOAD "../config/coremark/twoBitPredictor.txt" | `define TWO_BIT_PRELOAD "../config/coremark/twoBitPredictor.txt" | ||||||
| `define BTB_PRELOAD "../config/coremark/BTBPredictor.txt" | `define BTB_PRELOAD "../config/coremark/BTBPredictor.txt" | ||||||
| `define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE | `define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE | ||||||
|  | `define TESTSBP 0 | ||||||
|  | |||||||
| @ -97,3 +97,4 @@ | |||||||
| 
 | 
 | ||||||
| `define TWO_BIT_PRELOAD "../config/coremark_bare/twoBitPredictor.txt" | `define TWO_BIT_PRELOAD "../config/coremark_bare/twoBitPredictor.txt" | ||||||
| `define BTB_PRELOAD "../config/coremark_bare/BTBPredictor.txt" | `define BTB_PRELOAD "../config/coremark_bare/BTBPredictor.txt" | ||||||
|  | `define TESTSBP 0 | ||||||
|  | |||||||
| @ -95,3 +95,4 @@ | |||||||
| `define TWO_BIT_PRELOAD "../config/rv32ic/twoBitPredictor.txt" | `define TWO_BIT_PRELOAD "../config/rv32ic/twoBitPredictor.txt" | ||||||
| `define BTB_PRELOAD "../config/rv32ic/BTBPredictor.txt" | `define BTB_PRELOAD "../config/rv32ic/BTBPredictor.txt" | ||||||
| `define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE | `define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE | ||||||
|  | `define TESTSBP 0 | ||||||
|  | |||||||
| @ -98,3 +98,4 @@ | |||||||
| `define TWO_BIT_PRELOAD "../config/rv64ic/twoBitPredictor.txt" | `define TWO_BIT_PRELOAD "../config/rv64ic/twoBitPredictor.txt" | ||||||
| `define BTB_PRELOAD "../config/rv64ic/BTBPredictor.txt" | `define BTB_PRELOAD "../config/rv64ic/BTBPredictor.txt" | ||||||
| `define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE | `define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE | ||||||
|  | `define TESTSBP 0 | ||||||
|  | |||||||
| @ -98,3 +98,4 @@ | |||||||
| `define TWO_BIT_PRELOAD "../config/rv64icfd/twoBitPredictor.txt" | `define TWO_BIT_PRELOAD "../config/rv64icfd/twoBitPredictor.txt" | ||||||
| `define BTB_PRELOAD "../config/rv64icfd/BTBPredictor.txt" | `define BTB_PRELOAD "../config/rv64icfd/BTBPredictor.txt" | ||||||
| `define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE | `define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE | ||||||
|  | `define TESTSBP 0 | ||||||
|  | |||||||
| @ -28,7 +28,6 @@ | |||||||
| 
 | 
 | ||||||
| module testbench(); | module testbench(); | ||||||
|   parameter DEBUG = 0; |   parameter DEBUG = 0; | ||||||
|   parameter TESTSBP = 0; |  | ||||||
|    |    | ||||||
|   logic        clk; |   logic        clk; | ||||||
|   logic        reset; |   logic        reset; | ||||||
| @ -337,7 +336,7 @@ string tests32i[] = { | |||||||
|   // pick tests based on modes supported
 |   // pick tests based on modes supported
 | ||||||
|   initial  |   initial  | ||||||
|     if (`XLEN == 64) begin // RV64
 |     if (`XLEN == 64) begin // RV64
 | ||||||
|       if(TESTSBP) begin |       if(`TESTSBP) begin | ||||||
| 	tests = testsBP64;	 | 	tests = testsBP64;	 | ||||||
|       end else begin  |       end else begin  | ||||||
| 	tests = {tests64i}; | 	tests = {tests64i}; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user