From 318b642359e0468e14bc956f2fa70fddf6f81e91 Mon Sep 17 00:00:00 2001 From: Ross Thompson Date: Thu, 11 Mar 2021 17:12:21 -0600 Subject: [PATCH] Improve version of the function radix which does not cause the wave file rendering to slow down. --- wally-pipelined/bin/extractFunctionRadix.sh | 2 + wally-pipelined/regression/wave.do | 28 +++-- wally-pipelined/testbench/function_radix.sv | 103 ++++++++---------- .../testbench/testbench-imperas.sv | 24 ++-- 4 files changed, 78 insertions(+), 79 deletions(-) diff --git a/wally-pipelined/bin/extractFunctionRadix.sh b/wally-pipelined/bin/extractFunctionRadix.sh index 487fe103..d7c6b08b 100755 --- a/wally-pipelined/bin/extractFunctionRadix.sh +++ b/wally-pipelined/bin/extractFunctionRadix.sh @@ -57,9 +57,11 @@ function processProgram { # parse out the addresses and the labels local addresses=`echo "$listOfAddr" | awk '{print $1}'` local labels=`echo "$listOfAddr" | awk '{print "\""$2"\"", "-color \"SpringGreen\","}' | tr -d '<>:'` + local labelsName=`echo "$listOfAddr" | awk '{print ""$2""}' | tr -d '<>:'` # output per program function address list echo "$addresses" > $objDumpFile.addr + echo "$labelsName" > $objDumpFile.lab # need to add some formatting to each line local numLines=`echo "$listOfAddr" | wc -l` diff --git a/wally-pipelined/regression/wave.do b/wally-pipelined/regression/wave.do index 69e7fe82..d3be0b8f 100644 --- a/wally-pipelined/regression/wave.do +++ b/wally-pipelined/regression/wave.do @@ -3,7 +3,6 @@ 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 @@ -111,16 +110,25 @@ add wave -noupdate -expand -group {alu execution stage} /testbench/dut/hart/ieu/ add wave -noupdate -expand -group {alu execution stage} /testbench/dut/hart/ieu/dp/SrcAE add wave -noupdate -expand -group {alu execution stage} /testbench/dut/hart/ieu/dp/SrcBE 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/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 /testbench/functionRadix/function_radix/FunctionAddr +add wave -noupdate /testbench/functionRadix/function_radix/reset +add wave -noupdate /testbench/functionRadix/function_radix/ProgramLabelMapLineCount +add wave -noupdate /testbench/functionRadix/function_radix/ProgramLabelMapLine +add wave -noupdate /testbench/functionRadix/function_radix/ProgramLabelMapFP +add wave -noupdate /testbench/functionRadix/function_radix/ProgramLabelMapFile +add wave -noupdate /testbench/functionRadix/function_radix/ProgramAddrMapLineCount +add wave -noupdate /testbench/functionRadix/function_radix/ProgramAddrMapLine +add wave -noupdate /testbench/functionRadix/function_radix/ProgramAddrMapFP +add wave -noupdate /testbench/functionRadix/function_radix/ProgramAddrMapFile +add wave -noupdate /testbench/functionRadix/function_radix/pc +add wave -noupdate /testbench/functionRadix/function_radix/FunctionName +add wave -noupdate /testbench/functionRadix/function_radix/FunctionAddr +add wave -noupdate /testbench/functionRadix/function_radix/ProgramAddrIndex TreeUpdate [SetDefaultTree] -WaveRestoreCursors {{Cursor 2} {6683 ns} 0} {{Cursor 3} {5926044 ns} 0} -quietly wave cursor active 2 +WaveRestoreCursors {{Cursor 2} {1091 ns} 0} {{Cursor 3} {5926044 ns} 0} +quietly wave cursor active 1 configure wave -namecolwidth 250 -configure wave -valuecolwidth 518 +configure wave -valuecolwidth 229 configure wave -justifyvalue left configure wave -signalnamewidth 1 configure wave -snapdistance 10 @@ -133,4 +141,4 @@ configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits ns update -WaveRestoreZoom {5925753 ns} {5927309 ns} +WaveRestoreZoom {0 ns} {105 us} diff --git a/wally-pipelined/testbench/function_radix.sv b/wally-pipelined/testbench/function_radix.sv index ae96ba61..b5c34c2b 100644 --- a/wally-pipelined/testbench/function_radix.sv +++ b/wally-pipelined/testbench/function_radix.sv @@ -27,45 +27,40 @@ `include "wally-config.vh" -module function_radix(reset, ProgramIndexName); - parameter FunctionRadixFile, ProgramIndexFile; +module function_radix(reset, ProgramAddrMapFile, ProgramLabelMapFile); input logic reset; - /* -----\/----- EXCLUDED -----\/----- - input string FunctionRadixFile; - input string ProgramIndexFile; - -----/\----- EXCLUDED -----/\----- */ - input string ProgramIndexName; + input string ProgramAddrMapFile; + input string ProgramLabelMapFile; - localparam TestSize = 16; - localparam TotalSize = `XLEN+TestSize; - - logic [TotalSize-1:0] FunctionRadixMemory []; - logic [TotalSize-1:0] FunctionRadixName; - - integer ProgramIndexMemory [string]; + logic [`XLEN-1:0] ProgramAddrMapMemory []; + string ProgramLabelMapMemory [integer]; + string FunctionName; - logic [`XLEN-1:0] pc; - logic [TestSize-1:0] ProgramIndexTestNumber; - logic [TotalSize-1:0] TestAddr; + + logic [`XLEN-1:0] pc, FunctionAddr; + integer ProgramAddrIndex; // *** I should look into the system verilog objects instead of signal spy. initial begin $init_signal_spy("/testbench/dut/hart/PCE", "/testbench/functionRadix/function_radix/pc"); end - assign TestAddr = {ProgramIndexTestNumber, pc}; - 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; + input logic [`XLEN-1:0] pc; + input logic [`XLEN-1:0] length; + ref logic [`XLEN-1:0] array []; + output logic [`XLEN-1:0] minval; + output logic [`XLEN-1:0] mid; - logic [TotalSize-1:0] left, right; - logic [TotalSize-1:0] mid; + logic [`XLEN-1:0] left, right; begin + if ( pc == 0 ) begin + // *** want to keep the old value for mid and minval + mid = 0; + return; + end left = 0; right = length; while (left <= right) begin @@ -98,61 +93,59 @@ module function_radix(reset, ProgramIndexName); end endtask // bin_search_min - integer FunctionRadixFP, ProgramIndexFP; - integer FunctionRadixLineCount, ProgramLineCount; - logic [TotalSize-1:0] FunctionRadixLine; - string ProgramIndexLine; + integer ProgramAddrMapFP, ProgramLabelMapFP; + integer ProgramAddrMapLineCount, ProgramLabelMapLineCount; + longint ProgramAddrMapLine; + string ProgramLabelMapLine; // preload - //always @ (posedge reset) begin - initial begin - $readmemh(FunctionRadixFile, FunctionRadixMemory); +// initial begin + always @ (posedge reset) begin + $readmemh(ProgramAddrMapFile, ProgramAddrMapMemory); // we need to count the number of lines in the file so we can set FunctionRadixLineCount. - FunctionRadixLineCount = 0; - FunctionRadixFP = $fopen(FunctionRadixFile, "r"); + ProgramAddrMapLineCount = 0; + ProgramAddrMapFP = $fopen(ProgramAddrMapFile, "r"); // read line by line to count lines - if (FunctionRadixFP) begin - while (! $feof(FunctionRadixFP)) begin - $fscanf(FunctionRadixFP, "%h\n", FunctionRadixLine); + if (ProgramAddrMapFP) begin + while (! $feof(ProgramAddrMapFP)) begin + $fscanf(ProgramAddrMapFP, "%h\n", ProgramAddrMapLine); - FunctionRadixLineCount = FunctionRadixLineCount + 1; + ProgramAddrMapLineCount = ProgramAddrMapLineCount + 1; end end else begin - $display("Cannot open file %s for reading.", FunctionRadixFile); + $display("Cannot open file %s for reading.", ProgramAddrMapFile); end - $fclose(FunctionRadixFP); - + $fclose(ProgramAddrMapFP); // ProgramIndexFile maps the program name to the compile index. // The compile index is then used to inditify the application // in the custom radix. // Build an associative array to convert the name to an index. - ProgramLineCount = 0; - ProgramIndexFP = $fopen(ProgramIndexFile, "r"); + ProgramLabelMapLineCount = 0; + ProgramLabelMapFP = $fopen(ProgramLabelMapFile, "r"); - if (ProgramIndexFP) begin - while (! $feof(ProgramIndexFP)) begin - $fscanf(ProgramIndexFP, "%s\n", ProgramIndexLine); - ProgramIndexMemory[ProgramIndexLine] = ProgramLineCount; - ProgramLineCount = ProgramLineCount + 1; + if (ProgramLabelMapFP) begin + while (! $feof(ProgramLabelMapFP)) begin + $fscanf(ProgramLabelMapFP, "%s\n", ProgramLabelMapLine); + ProgramLabelMapMemory[ProgramLabelMapLineCount] = ProgramLabelMapLine; + ProgramLabelMapLineCount = ProgramLabelMapLineCount + 1; end end else begin - $display("Cannot open file %s for reading.", ProgramIndexFile); + $display("Cannot open file %s for reading.", ProgramLabelMapFile); end - $fclose(ProgramIndexFP); + $fclose(ProgramLabelMapFP); end always @(pc) begin - bin_search_min(TestAddr, FunctionRadixLineCount, FunctionRadixMemory, FunctionRadixName); + bin_search_min(pc, ProgramAddrMapLineCount, ProgramAddrMapMemory, FunctionAddr, ProgramAddrIndex); end - // Each time there is a new program update the test number - always @(ProgramIndexName) begin - ProgramIndexTestNumber = ProgramIndexMemory[ProgramIndexName]; - end + + assign FunctionName = ProgramLabelMapMemory[ProgramAddrIndex]; + endmodule // function_radix diff --git a/wally-pipelined/testbench/testbench-imperas.sv b/wally-pipelined/testbench/testbench-imperas.sv index ce870c2e..275b4a9b 100644 --- a/wally-pipelined/testbench/testbench-imperas.sv +++ b/wally-pipelined/testbench/testbench-imperas.sv @@ -313,7 +313,7 @@ string tests32i[] = { }; string tests[]; - string testName; + string ProgramAddrMapFile, ProgramLabelMapFile; logic [`AHBW-1:0] HRDATAEXT; logic HREADYEXT, HRESPEXT; logic [31:0] HADDR; @@ -379,7 +379,8 @@ 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]; + ProgramAddrMapFile = {"../../imperas-riscv-tests/work/", tests[test], ".elf.objdump.addr"}; + ProgramLabelMapFile = {"../../imperas-riscv-tests/work/", tests[test], ".elf.objdump.lab"}; $display("Read memfile %s", memfilename); reset = 1; # 42; reset = 0; end @@ -454,24 +455,19 @@ string tests32i[] = { $readmemh(memfilename, dut.imem.RAM); $readmemh(memfilename, dut.uncore.dtim.RAM); $display("Read memfile %s", memfilename); - testName = tests[test]; + ProgramAddrMapFile = {"../../imperas-riscv-tests/work/", tests[test], ".elf.objdump.addr"}; + ProgramLabelMapFile = {"../../imperas-riscv-tests/work/", tests[test], ".elf.objdump.lab"}; reset = 1; # 17; reset = 0; end end end // always @ (negedge clk) // track the current function or global label - 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 + if (DEBUG == 1) begin : functionRadix + function_radix function_radix(.reset(reset), + .ProgramAddrMapFile(ProgramAddrMapFile), + .ProgramLabelMapFile(ProgramLabelMapFile)); + end endmodule