Added debug option to disable the function radix if not needed.

Function radix slows the simulation by 70 to 76 s (8.5%) for the rv64i tests.
This commit is contained in:
Ross Thompson 2021-03-10 15:17:02 -06:00
parent 4d7e926dbb
commit 149c9aa0f2
5 changed files with 52 additions and 52 deletions

3
.gitignore vendored
View File

@ -8,3 +8,6 @@ transcript
vsim.wlf
wally-pipelined/wlft*
wlft*
/imperas-riscv-tests/FunctionRadix_32.addr
/imperas-riscv-tests/FunctionRadix_64.addr
/imperas-riscv-tests/ProgramMap.txt

View File

@ -51,5 +51,5 @@ add log -r /*
-- Run the Simulation
#run 1000
#run -all
run -all
#quit

View File

@ -1,9 +1,9 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /testbench/clk
add wave -noupdate /testbench/reset
add wave -noupdate /testbench/test
add wave -noupdate -radix ascii /testbench/memfilename
add wave -noupdate -label {Function Name} -radix Functions /testbench/functionRadix/function_radix/FunctionRadixName
add wave -noupdate -expand -group {Execution Stage} /testbench/dut/hart/ifu/PCE
add wave -noupdate -expand -group {Execution Stage} /testbench/InstrEName
add wave -noupdate -expand -group {Execution Stage} /testbench/dut/hart/ifu/InstrE
@ -113,14 +113,12 @@ add wave -noupdate -expand -group {alu execution stage} /testbench/dut/hart/ieu/
add wave -noupdate /testbench/dut/hart/ieu/dp/ALUResultM
add wave -noupdate -expand -group {Function Radix} -radix ascii /testbench/functionRadix/function_radix/FunctionRadixFile
add wave -noupdate -expand -group {Function Radix} -radix ascii /testbench/functionRadix/function_radix/ProgramIndexFile
add wave -noupdate -expand -group {Function Radix} -radix ascii /testbench/functionRadix/function_radix/ProgramName
add wave -noupdate -expand -group {Function Radix} -radix ascii /testbench/functionRadix/function_radix/ProgramIndexName
add wave -noupdate -expand -group {Function Radix} /testbench/testName
add wave -noupdate -expand -group {Function Radix} /testbench/functionRadix/function_radix/TestAddr
add wave -noupdate -expand -group {Function Radix} -radix Functions /testbench/functionRadix/function_radix/index
add wave -noupdate -expand -group {Function Radix} /testbench/functionRadix/function_radix/TestNumber
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 2} {6683 ns} 0} {{Cursor 3} {6455941 ns} 0}
quietly wave cursor active 1
WaveRestoreCursors {{Cursor 2} {6683 ns} 0} {{Cursor 3} {5926044 ns} 0}
quietly wave cursor active 2
configure wave -namecolwidth 250
configure wave -valuecolwidth 518
configure wave -justifyvalue left
@ -135,4 +133,4 @@ configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ns
update
WaveRestoreZoom {0 ns} {131270 ns}
WaveRestoreZoom {5925753 ns} {5927309 ns}

View File

@ -27,7 +27,7 @@
`include "wally-config.vh"
module function_radix(reset, ProgramName);
module function_radix(reset, ProgramIndexName);
parameter FunctionRadixFile, ProgramIndexFile;
input logic reset;
@ -35,18 +35,18 @@ module function_radix(reset, ProgramName);
input string FunctionRadixFile;
input string ProgramIndexFile;
-----/\----- EXCLUDED -----/\----- */
input string ProgramName;
input string ProgramIndexName;
localparam TestSize = 16;
localparam TotalSize = `XLEN+TestSize;
logic [TotalSize-1:0] memory_bank [];
logic [TotalSize-1:0] index;
logic [TotalSize-1:0] FunctionRadixMemory [];
logic [TotalSize-1:0] FunctionRadixName;
integer ProgramBank [string];
integer ProgramIndexMemory [string];
logic [`XLEN-1:0] pc;
logic [TestSize-1:0] TestNumber;
logic [TestSize-1:0] ProgramIndexTestNumber;
logic [TotalSize-1:0] TestAddr;
// *** I should look into the system verilog objects instead of signal spy.
@ -54,7 +54,7 @@ module function_radix(reset, ProgramName);
$init_signal_spy("/testbench/dut/hart/PCE", "/testbench/functionRadix/function_radix/pc");
end
assign TestAddr = {TestNumber, pc};
assign TestAddr = {ProgramIndexTestNumber, pc};
task automatic bin_search_min;
input logic [TotalSize-1:0] pc;
@ -98,31 +98,31 @@ module function_radix(reset, ProgramName);
end
endtask // bin_search_min
integer fp, ProgramFP;
integer line_count, ProgramLineCount;
logic [TotalSize-1:0] line;
string ProgramLine;
integer FunctionRadixFP, ProgramIndexFP;
integer FunctionRadixLineCount, ProgramLineCount;
logic [TotalSize-1:0] FunctionRadixLine;
string ProgramIndexLine;
// 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.
$readmemh(FunctionRadixFile, FunctionRadixMemory);
// we need to count the number of lines in the file so we can set FunctionRadixLineCount.
line_count = 0;
fp = $fopen(FunctionRadixFile, "r");
FunctionRadixLineCount = 0;
FunctionRadixFP = $fopen(FunctionRadixFile, "r");
// read line by line to count lines
if (fp) begin
while (! $feof(fp)) begin
$fscanf(fp, "%h\n", line);
if (FunctionRadixFP) begin
while (! $feof(FunctionRadixFP)) begin
$fscanf(FunctionRadixFP, "%h\n", FunctionRadixLine);
line_count = line_count + 1;
FunctionRadixLineCount = FunctionRadixLineCount + 1;
end
end else begin
$display("Cannot open file %s for reading.", FunctionRadixFile);
end
$fclose(fp);
$fclose(FunctionRadixFP);
// ProgramIndexFile maps the program name to the compile index.
@ -130,28 +130,28 @@ module function_radix(reset, ProgramName);
// in the custom radix.
// Build an associative array to convert the name to an index.
ProgramLineCount = 0;
ProgramFP = $fopen(ProgramIndexFile, "r");
ProgramIndexFP = $fopen(ProgramIndexFile, "r");
if (ProgramFP) begin
while (! $feof(ProgramFP)) begin
$fscanf(ProgramFP, "%s\n", ProgramLine);
ProgramBank[ProgramLine] = ProgramLineCount;
if (ProgramIndexFP) begin
while (! $feof(ProgramIndexFP)) begin
$fscanf(ProgramIndexFP, "%s\n", ProgramIndexLine);
ProgramIndexMemory[ProgramIndexLine] = ProgramLineCount;
ProgramLineCount = ProgramLineCount + 1;
end
end else begin
$display("Cannot open file %s for reading.", ProgramIndexFile);
end
$fclose(ProgramFP);
$fclose(ProgramIndexFP);
end
always @(pc) begin
bin_search_min(TestAddr, line_count, memory_bank, index);
bin_search_min(TestAddr, FunctionRadixLineCount, FunctionRadixMemory, FunctionRadixName);
end
// Each time there is a new program update the test number
always @(ProgramName) begin
TestNumber = ProgramBank[ProgramName];
always @(ProgramIndexName) begin
ProgramIndexTestNumber = ProgramIndexMemory[ProgramIndexName];
end
endmodule // function_radix

View File

@ -30,7 +30,8 @@ module testbench();
parameter FunctionRadixFile32 = "../../imperas-riscv-tests/FunctionRadix_32.addr";
parameter FunctionRadixFile64 = "../../imperas-riscv-tests/FunctionRadix_64.addr";
parameter ProgramIndexFile = "../../imperas-riscv-tests/ProgramMap.txt";
parameter DEBUG = 1;
logic clk;
logic reset;
@ -454,20 +455,18 @@ string tests32i[] = {
end // always @ (negedge clk)
// track the current function or global label
generate
if (`XLEN == 32) begin : functionRadix
function_radix #(.FunctionRadixFile(FunctionRadixFile32),
.ProgramIndexFile(ProgramIndexFile))
function_radix(.reset(reset),
.ProgramName(testName));
end else begin : functionRadix
function_radix #(.FunctionRadixFile(FunctionRadixFile64),
.ProgramIndexFile(ProgramIndexFile))
function_radix(.reset(reset),
.ProgramName(testName));
end
endgenerate
if (`XLEN == 32 && DEBUG == 1) begin : functionRadix
function_radix #(.FunctionRadixFile(FunctionRadixFile32),
.ProgramIndexFile(ProgramIndexFile))
function_radix(.reset(reset),
.ProgramIndexName(testName));
end else if (`XLEN == 64 && DEBUG == 1) begin : functionRadix
function_radix #(.FunctionRadixFile(FunctionRadixFile64),
.ProgramIndexFile(ProgramIndexFile))
function_radix(.reset(reset),
.ProgramIndexName(testName));
end
endmodule
/* verilator lint_on STMTDLY */