forked from Github_Repos/cvw
Finally I think I have the function radix mapping across all applications correctly. I still need to clean up the code a bit so it is easier to understand.
This commit is contained in:
parent
d5f151eb0f
commit
50a92247b3
@ -1,9 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
allProgramRadixFile="FunctionRadix"
|
||||
|
||||
programToIndexMap="ProgramMap.txt"
|
||||
index=0
|
||||
|
||||
# clear the files
|
||||
rm -rf $allProgramRadixFile.addr $allProgramRadixFile.do $programToIndexMap
|
||||
|
||||
echo "radix define Functions {" > $allProgramRadixFile.do
|
||||
|
||||
for objDumpFile in "$@";
|
||||
do
|
||||
# get the lines with named labels from the obj files.
|
||||
@ -38,10 +43,27 @@ do
|
||||
|
||||
# now create the all in one version
|
||||
# put the index at the begining of each line
|
||||
allAddresses=`paste -d'\0' <(printf "%04x" "$index") <(echo "$addresses")`
|
||||
|
||||
printf "%04x%s" "$index" "$addresses" >> $allProgramRadixFile.addr
|
||||
# first convert the index to a string, 16 bits length
|
||||
# then duplicate the index numlines times
|
||||
# concat the index with the address
|
||||
indexStr=`printf "%04x" "$index"`
|
||||
copyIndex=`yes "$indexStr" | head -n $numLines`
|
||||
allAddresses=`paste -d'\0' <(printf "%s" "$copyIndex") <(echo "$addresses")`
|
||||
printf "%s\n" "$allAddresses" >> $allProgramRadixFile.addr
|
||||
|
||||
allAddressesTemp=`paste -d'\0' <(echo "$prefix") <(echo "$allAddresses") <(echo "$midfix") <(echo "$labels")`
|
||||
printf "%s\n" "$allAddressesTemp" >> $allProgramRadixFile.do
|
||||
|
||||
testName=`echo "$objDumpFile" | sed -e "s/.*work\/\(.*\)\.elf\.objdump/\1/g"`
|
||||
printf "$testName\n" >> $programToIndexMap
|
||||
|
||||
index=$(($index+1))
|
||||
|
||||
done
|
||||
|
||||
# remove the last comma from the all radix
|
||||
# '$ selects the last line
|
||||
sed -i '$ s/,$//g' $allProgramRadixFile.do
|
||||
|
||||
echo "}" >> $allProgramRadixFile.do
|
||||
|
@ -30,8 +30,8 @@ vlib work
|
||||
# default to config/rv64ic, but allow this to be overridden at the command line. For example:
|
||||
# do wally-pipelined.do ../config/rv32ic
|
||||
switch $argc {
|
||||
0 {vlog +incdir+../config/rv64ic ../testbench/testbench-imperas.sv ../src/*/*.sv -suppress 2583}
|
||||
1 {vlog +incdir+$1 ../testbench/testbench-imperas.sv ../src/*/*.sv -suppress 2583}
|
||||
0 {vlog +incdir+../config/rv64ic ../testbench/testbench-imperas.sv ../testbench/function_radix.sv ../src/*/*.sv -suppress 2583}
|
||||
1 {vlog +incdir+$1 ../testbench/testbench-imperas.sv ../testbench/function_radix.sv ../src/*/*.sv -suppress 2583}
|
||||
}
|
||||
# start and run simulation
|
||||
# remove +acc flag for faster sim during regressions if there is no need to access internal signals
|
||||
@ -51,5 +51,5 @@ add log -r /*
|
||||
|
||||
-- Run the Simulation
|
||||
#run 1000
|
||||
run -all
|
||||
#run -all
|
||||
#quit
|
||||
|
@ -30,8 +30,8 @@ vlib work
|
||||
# default to config/rv64ic, but allow this to be overridden at the command line. For example:
|
||||
# do wally-pipelined.do ../config/rv32ic
|
||||
switch $argc {
|
||||
0 {vlog +incdir+../config/rv64ic ../testbench/testbench-imperas.sv ../src/*/*.sv -suppress 2583}
|
||||
1 {vlog +incdir+$1 ../testbench/testbench-imperas.sv ../src/*/*.sv -suppress 2583}
|
||||
0 {vlog +incdir+../config/rv64ic ../testbench/testbench-imperas.sv ../testbench/function_radix.sv ../src/*/*.sv -suppress 2583}
|
||||
1 {vlog +incdir+$1 ../testbench/testbench-imperas.sv ../testbench/function_radix.sv ../src/*/*.sv -suppress 2583}
|
||||
}
|
||||
# start and run simulation
|
||||
# remove +acc flag for faster sim during regressions if there is no need to access internal signals
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,7 @@
|
||||
// Written: Ross Thompson
|
||||
// email: ross1728@gmail.com
|
||||
// Created: November 9, 2019
|
||||
// Modified: March 04, 2021
|
||||
//
|
||||
// Purpose: Finds the current function or global assembly label based on PCE.
|
||||
//
|
||||
@ -26,83 +27,150 @@
|
||||
|
||||
`include "wally-config.vh"
|
||||
|
||||
module function_radix();
|
||||
module function_radix(reset, ProgramName);
|
||||
parameter FunctionRadixFile, ProgramIndexFile;
|
||||
|
||||
input logic reset;
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
input string FunctionRadixFile;
|
||||
input string ProgramIndexFile;
|
||||
-----/\----- EXCLUDED -----/\----- */
|
||||
input string ProgramName;
|
||||
|
||||
parameter PRELOAD_FILE = "funct_addr.txt";
|
||||
localparam TestSize = 16;
|
||||
localparam TotalSize = `XLEN+TestSize;
|
||||
|
||||
integer memory_bank [];
|
||||
integer index;
|
||||
logic [TotalSize-1:0] memory_bank [];
|
||||
logic [TotalSize-1:0] index;
|
||||
|
||||
logic [`XLEN-1:0] pc;
|
||||
|
||||
initial begin
|
||||
$init_signal_spy("/riscv_mram_tb/dut/pc", "/riscv_mram_tb/function_radix/pc");
|
||||
end
|
||||
integer ProgramBank [string];
|
||||
|
||||
logic [`XLEN-1:0] pc;
|
||||
logic [TestSize-1:0] TestNumber;
|
||||
logic [TotalSize-1:0] TestAddr;
|
||||
|
||||
task automatic bin_search_min;
|
||||
input integer pc;
|
||||
input integer length;
|
||||
ref integer array [];
|
||||
output integer minval;
|
||||
// *** I should look into the system verilog objects instead of signal spy.
|
||||
initial begin
|
||||
$init_signal_spy("/testbench/dut/hart/PCE", "/testbench/function_radix/pc");
|
||||
end
|
||||
|
||||
integer left, right;
|
||||
integer mid;
|
||||
assign TestAddr = {TestNumber, pc};
|
||||
|
||||
begin
|
||||
left = 0;
|
||||
right = length;
|
||||
while (left <= right) begin
|
||||
mid = left + ((right - left) / 2);
|
||||
if (array[mid] == pc) begin
|
||||
minval = array[mid];
|
||||
return;
|
||||
end
|
||||
if (array[mid] < pc) begin
|
||||
left = mid + 1;
|
||||
end else begin
|
||||
right = mid -1;
|
||||
end
|
||||
end // while (left <= right)
|
||||
// if the element pc is now found, right and left will be equal at this point.
|
||||
// we need to check if pc is less than the array at left or greather.
|
||||
// if it is less than pc, then we select left as the index.
|
||||
// if it is greather we want 1 less than left.
|
||||
if (array[left] < pc) begin
|
||||
minval = array[left];
|
||||
return;
|
||||
end else begin
|
||||
minval = array[left-1];
|
||||
return;
|
||||
end
|
||||
end
|
||||
endtask
|
||||
task automatic bin_search_min;
|
||||
input logic [TotalSize-1:0] pc;
|
||||
input logic [TotalSize-1:0] length;
|
||||
ref logic [TotalSize-1:0] array [];
|
||||
output logic [TotalSize-1:0] minval;
|
||||
|
||||
|
||||
// preload
|
||||
initial $readmemh(PRELOAD_FILE, memory_bank);
|
||||
logic [TotalSize-1:0] left, right;
|
||||
logic [TotalSize-1:0] mid;
|
||||
|
||||
// we need to count the number of lines in the file so we can set line_count.
|
||||
integer fp;
|
||||
integer line_count = 0;
|
||||
logic [31:0] line;
|
||||
initial begin
|
||||
fp = $fopen(PRELOAD_FILE, "r");
|
||||
// read line by line to count lines
|
||||
if (fp) begin
|
||||
while (! $feof(fp)) begin
|
||||
$fscanf(fp, "%h\n", line);
|
||||
line_count = line_count + 1;
|
||||
end
|
||||
begin
|
||||
left = 0;
|
||||
right = length;
|
||||
while (left <= right) begin
|
||||
mid = left + ((right - left) / 2);
|
||||
if (array[mid] == pc) begin
|
||||
minval = array[mid];
|
||||
return;
|
||||
end
|
||||
if (array[mid] < pc) begin
|
||||
left = mid + 1;
|
||||
end else if( array[mid] > pc) begin
|
||||
right = mid -1;
|
||||
end else begin
|
||||
$display("Critical Error in function radix. PC, %x not found.", pc);
|
||||
return;
|
||||
//$stop();
|
||||
end
|
||||
end // while (left <= right)
|
||||
// if the element pc is now found, right and left will be equal at this point.
|
||||
// we need to check if pc is less than the array at left or greather.
|
||||
// if it is less than pc, then we select left as the index.
|
||||
// if it is greather we want 1 less than left.
|
||||
if (array[left] < pc) begin
|
||||
minval = array[left];
|
||||
return;
|
||||
end else begin
|
||||
$display("Cannot open file %s for reading.", PRELOAD_FILE);
|
||||
$stop;
|
||||
minval = array[left-1];
|
||||
return;
|
||||
end
|
||||
end
|
||||
end
|
||||
endtask // bin_search_min
|
||||
|
||||
always @(pc) begin
|
||||
bin_search_min(pc, line_count, memory_bank, index);
|
||||
|
||||
end
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
task automatic FindProgramIndex;
|
||||
input string ProgramName;
|
||||
ref integer array [string];
|
||||
output integer ProgramIndex;
|
||||
|
||||
string line;
|
||||
|
||||
begin
|
||||
ProgramIndex = array[ProgramName];
|
||||
return;
|
||||
end
|
||||
endtask
|
||||
|
||||
-----/\----- EXCLUDED -----/\----- */
|
||||
|
||||
|
||||
// *** this is all wrong
|
||||
integer fp, ProgramFP;
|
||||
integer line_count, ProgramLineCount;
|
||||
logic [TotalSize-1:0] line;
|
||||
string ProgramLine;
|
||||
|
||||
// preload
|
||||
//always @ (posedge reset) begin
|
||||
initial begin
|
||||
$readmemh(FunctionRadixFile, memory_bank);
|
||||
// we need to count the number of lines in the file so we can set line_count.
|
||||
|
||||
line_count = 0;
|
||||
fp = $fopen(FunctionRadixFile, "r");
|
||||
|
||||
// read line by line to count lines
|
||||
if (fp) begin
|
||||
while (! $feof(fp)) begin
|
||||
$fscanf(fp, "%h\n", line);
|
||||
|
||||
line_count = line_count + 1;
|
||||
end
|
||||
end else begin
|
||||
$display("Cannot open file %s for reading.", FunctionRadixFile);
|
||||
end
|
||||
$fclose(fp);
|
||||
|
||||
ProgramLineCount = 0;
|
||||
ProgramFP = $fopen(ProgramIndexFile, "r");
|
||||
|
||||
// read line by line to count lines
|
||||
if (ProgramFP) begin
|
||||
while (! $feof(ProgramFP)) begin
|
||||
$fscanf(ProgramFP, "%s\n", ProgramLine);
|
||||
// *** missing the memory update
|
||||
ProgramBank[ProgramLine] = ProgramLineCount;
|
||||
//$display("Program name is %s", ProgramLine);
|
||||
|
||||
ProgramLineCount = ProgramLineCount + 1;
|
||||
end
|
||||
end else begin
|
||||
$display("Cannot open file %s for reading.", ProgramIndexFile);
|
||||
end
|
||||
$fclose(ProgramFP);
|
||||
|
||||
end
|
||||
|
||||
always @(pc) begin
|
||||
bin_search_min(TestAddr, line_count, memory_bank, index);
|
||||
end
|
||||
|
||||
always @(ProgramName, reset) begin
|
||||
//FindProgramIndex(ProgramName, ProgramBank, TestNumber);
|
||||
TestNumber = ProgramBank[ProgramName];
|
||||
//TestNumber = ProgramBank["rv64i/I-ADD-01"];
|
||||
end
|
||||
|
||||
endmodule // function_radix
|
||||
|
||||
|
@ -27,6 +27,9 @@
|
||||
`include "wally-config.vh"
|
||||
|
||||
module testbench();
|
||||
parameter FunctionRadixFile = "../../imperas-riscv-tests/FunctionRadix.addr";
|
||||
parameter ProgramIndexFile = "../../imperas-riscv-tests/ProgramMap.txt";
|
||||
|
||||
logic clk;
|
||||
logic reset;
|
||||
|
||||
@ -305,6 +308,7 @@ string tests32i[] = {
|
||||
|
||||
};
|
||||
string tests[];
|
||||
string testName;
|
||||
logic [`AHBW-1:0] HRDATAEXT;
|
||||
logic HREADYEXT, HRESPEXT;
|
||||
logic [31:0] HADDR;
|
||||
@ -368,6 +372,7 @@ string tests32i[] = {
|
||||
memfilename = {"../../imperas-riscv-tests/work/", tests[test], ".elf.memfile"};
|
||||
$readmemh(memfilename, dut.imem.RAM);
|
||||
$readmemh(memfilename, dut.uncore.dtim.RAM);
|
||||
testName = tests[test];
|
||||
reset = 1; # 42; reset = 0;
|
||||
end
|
||||
|
||||
@ -441,13 +446,17 @@ string tests32i[] = {
|
||||
$readmemh(memfilename, dut.imem.RAM);
|
||||
$readmemh(memfilename, dut.uncore.dtim.RAM);
|
||||
$display("Read memfile %s", memfilename);
|
||||
testName = tests[test];
|
||||
reset = 1; # 17; reset = 0;
|
||||
end
|
||||
end
|
||||
end // always @ (negedge clk)
|
||||
|
||||
// track the current function or label
|
||||
//function_rfunction_radix function_radix();
|
||||
// track the current function or global label
|
||||
function_radix #(.FunctionRadixFile(FunctionRadixFile),
|
||||
.ProgramIndexFile(ProgramIndexFile))
|
||||
function_radix(.reset(reset),
|
||||
.ProgramName(testName));
|
||||
|
||||
endmodule
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user