mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
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
|
#!/bin/bash
|
||||||
|
|
||||||
allProgramRadixFile="FunctionRadix"
|
allProgramRadixFile="FunctionRadix"
|
||||||
|
programToIndexMap="ProgramMap.txt"
|
||||||
index=0
|
index=0
|
||||||
|
|
||||||
|
# clear the files
|
||||||
|
rm -rf $allProgramRadixFile.addr $allProgramRadixFile.do $programToIndexMap
|
||||||
|
|
||||||
|
echo "radix define Functions {" > $allProgramRadixFile.do
|
||||||
|
|
||||||
for objDumpFile in "$@";
|
for objDumpFile in "$@";
|
||||||
do
|
do
|
||||||
# get the lines with named labels from the obj files.
|
# get the lines with named labels from the obj files.
|
||||||
@ -38,10 +43,27 @@ do
|
|||||||
|
|
||||||
# now create the all in one version
|
# now create the all in one version
|
||||||
# put the index at the begining of each line
|
# 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))
|
index=$(($index+1))
|
||||||
|
|
||||||
done
|
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:
|
# default to config/rv64ic, but allow this to be overridden at the command line. For example:
|
||||||
# do wally-pipelined.do ../config/rv32ic
|
# do wally-pipelined.do ../config/rv32ic
|
||||||
switch $argc {
|
switch $argc {
|
||||||
0 {vlog +incdir+../config/rv64ic ../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 ../src/*/*.sv -suppress 2583}
|
1 {vlog +incdir+$1 ../testbench/testbench-imperas.sv ../testbench/function_radix.sv ../src/*/*.sv -suppress 2583}
|
||||||
}
|
}
|
||||||
# start and run simulation
|
# start and run simulation
|
||||||
# remove +acc flag for faster sim during regressions if there is no need to access internal signals
|
# 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 the Simulation
|
||||||
#run 1000
|
#run 1000
|
||||||
run -all
|
#run -all
|
||||||
#quit
|
#quit
|
||||||
|
@ -30,8 +30,8 @@ vlib work
|
|||||||
# default to config/rv64ic, but allow this to be overridden at the command line. For example:
|
# default to config/rv64ic, but allow this to be overridden at the command line. For example:
|
||||||
# do wally-pipelined.do ../config/rv32ic
|
# do wally-pipelined.do ../config/rv32ic
|
||||||
switch $argc {
|
switch $argc {
|
||||||
0 {vlog +incdir+../config/rv64ic ../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 ../src/*/*.sv -suppress 2583}
|
1 {vlog +incdir+$1 ../testbench/testbench-imperas.sv ../testbench/function_radix.sv ../src/*/*.sv -suppress 2583}
|
||||||
}
|
}
|
||||||
# start and run simulation
|
# start and run simulation
|
||||||
# remove +acc flag for faster sim during regressions if there is no need to access internal signals
|
# 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
|
// Written: Ross Thompson
|
||||||
// email: ross1728@gmail.com
|
// email: ross1728@gmail.com
|
||||||
// Created: November 9, 2019
|
// Created: November 9, 2019
|
||||||
|
// Modified: March 04, 2021
|
||||||
//
|
//
|
||||||
// Purpose: Finds the current function or global assembly label based on PCE.
|
// Purpose: Finds the current function or global assembly label based on PCE.
|
||||||
//
|
//
|
||||||
@ -26,83 +27,150 @@
|
|||||||
|
|
||||||
`include "wally-config.vh"
|
`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 [];
|
logic [TotalSize-1:0] memory_bank [];
|
||||||
integer index;
|
logic [TotalSize-1:0] index;
|
||||||
|
|
||||||
logic [`XLEN-1:0] pc;
|
integer ProgramBank [string];
|
||||||
|
|
||||||
initial begin
|
logic [`XLEN-1:0] pc;
|
||||||
$init_signal_spy("/riscv_mram_tb/dut/pc", "/riscv_mram_tb/function_radix/pc");
|
logic [TestSize-1:0] TestNumber;
|
||||||
end
|
logic [TotalSize-1:0] TestAddr;
|
||||||
|
|
||||||
task automatic bin_search_min;
|
// *** I should look into the system verilog objects instead of signal spy.
|
||||||
input integer pc;
|
initial begin
|
||||||
input integer length;
|
$init_signal_spy("/testbench/dut/hart/PCE", "/testbench/function_radix/pc");
|
||||||
ref integer array [];
|
end
|
||||||
output integer minval;
|
|
||||||
|
|
||||||
integer left, right;
|
assign TestAddr = {TestNumber, pc};
|
||||||
integer mid;
|
|
||||||
|
|
||||||
begin
|
task automatic bin_search_min;
|
||||||
left = 0;
|
input logic [TotalSize-1:0] pc;
|
||||||
right = length;
|
input logic [TotalSize-1:0] length;
|
||||||
while (left <= right) begin
|
ref logic [TotalSize-1:0] array [];
|
||||||
mid = left + ((right - left) / 2);
|
output logic [TotalSize-1:0] minval;
|
||||||
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
|
|
||||||
|
|
||||||
|
logic [TotalSize-1:0] left, right;
|
||||||
// preload
|
logic [TotalSize-1:0] mid;
|
||||||
initial $readmemh(PRELOAD_FILE, memory_bank);
|
|
||||||
|
|
||||||
// we need to count the number of lines in the file so we can set line_count.
|
begin
|
||||||
integer fp;
|
left = 0;
|
||||||
integer line_count = 0;
|
right = length;
|
||||||
logic [31:0] line;
|
while (left <= right) begin
|
||||||
initial begin
|
mid = left + ((right - left) / 2);
|
||||||
fp = $fopen(PRELOAD_FILE, "r");
|
if (array[mid] == pc) begin
|
||||||
// read line by line to count lines
|
minval = array[mid];
|
||||||
if (fp) begin
|
return;
|
||||||
while (! $feof(fp)) begin
|
end
|
||||||
$fscanf(fp, "%h\n", line);
|
if (array[mid] < pc) begin
|
||||||
line_count = line_count + 1;
|
left = mid + 1;
|
||||||
end
|
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
|
end else begin
|
||||||
$display("Cannot open file %s for reading.", PRELOAD_FILE);
|
minval = array[left-1];
|
||||||
$stop;
|
return;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
endtask // bin_search_min
|
||||||
|
|
||||||
always @(pc) begin
|
/* -----\/----- EXCLUDED -----\/-----
|
||||||
bin_search_min(pc, line_count, memory_bank, index);
|
task automatic FindProgramIndex;
|
||||||
|
input string ProgramName;
|
||||||
end
|
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
|
endmodule // function_radix
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
`include "wally-config.vh"
|
`include "wally-config.vh"
|
||||||
|
|
||||||
module testbench();
|
module testbench();
|
||||||
|
parameter FunctionRadixFile = "../../imperas-riscv-tests/FunctionRadix.addr";
|
||||||
|
parameter ProgramIndexFile = "../../imperas-riscv-tests/ProgramMap.txt";
|
||||||
|
|
||||||
logic clk;
|
logic clk;
|
||||||
logic reset;
|
logic reset;
|
||||||
|
|
||||||
@ -305,6 +308,7 @@ string tests32i[] = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
string tests[];
|
string tests[];
|
||||||
|
string testName;
|
||||||
logic [`AHBW-1:0] HRDATAEXT;
|
logic [`AHBW-1:0] HRDATAEXT;
|
||||||
logic HREADYEXT, HRESPEXT;
|
logic HREADYEXT, HRESPEXT;
|
||||||
logic [31:0] HADDR;
|
logic [31:0] HADDR;
|
||||||
@ -368,6 +372,7 @@ string tests32i[] = {
|
|||||||
memfilename = {"../../imperas-riscv-tests/work/", tests[test], ".elf.memfile"};
|
memfilename = {"../../imperas-riscv-tests/work/", tests[test], ".elf.memfile"};
|
||||||
$readmemh(memfilename, dut.imem.RAM);
|
$readmemh(memfilename, dut.imem.RAM);
|
||||||
$readmemh(memfilename, dut.uncore.dtim.RAM);
|
$readmemh(memfilename, dut.uncore.dtim.RAM);
|
||||||
|
testName = tests[test];
|
||||||
reset = 1; # 42; reset = 0;
|
reset = 1; # 42; reset = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -441,13 +446,17 @@ string tests32i[] = {
|
|||||||
$readmemh(memfilename, dut.imem.RAM);
|
$readmemh(memfilename, dut.imem.RAM);
|
||||||
$readmemh(memfilename, dut.uncore.dtim.RAM);
|
$readmemh(memfilename, dut.uncore.dtim.RAM);
|
||||||
$display("Read memfile %s", memfilename);
|
$display("Read memfile %s", memfilename);
|
||||||
|
testName = tests[test];
|
||||||
reset = 1; # 17; reset = 0;
|
reset = 1; # 17; reset = 0;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end // always @ (negedge clk)
|
end // always @ (negedge clk)
|
||||||
|
|
||||||
// track the current function or label
|
// track the current function or global label
|
||||||
//function_rfunction_radix function_radix();
|
function_radix #(.FunctionRadixFile(FunctionRadixFile),
|
||||||
|
.ProgramIndexFile(ProgramIndexFile))
|
||||||
|
function_radix(.reset(reset),
|
||||||
|
.ProgramName(testName));
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user