Add old (without --timing) verilator test

This commit is contained in:
Nikolay Puzanov 2024-10-02 17:25:04 +03:00
parent 8b8f63105c
commit c277e3482a
17 changed files with 70 additions and 28 deletions

View File

@ -68,7 +68,9 @@
соответствует времени сборки на XSIM (Xcelium ближе к Modelsim). соответствует времени сборки на XSIM (Xcelium ближе к Modelsim).
В таблице ниже показано относительное время выполнения теста, приведенное к времени В таблице ниже показано относительное время выполнения теста, приведенное к времени
выполнения на многопоточном Вериляторе. выполнения на многопоточном Вериляторе. Вериляторы 5.028 и 4.120 показали практически
одинаковую скорость, разность в пределах погрешности. Но в 5.028 была включена опция
`--timing`, а клок формировался в верилоге.
"По просьбе выживших, имена были изменены. Из уважения к погибшим, остальное было "По просьбе выживших, имена были изменены. Из уважения к погибшим, остальное было
рассказано в точности так, как это произошло." рассказано в точности так, как это произошло."

View File

@ -216,13 +216,11 @@ module md5calculator
); );
// Print console output // Print console output
initial always @(posedge clock) begin
forever begin if (!reset && console_send) begin
@(posedge clock); $write("%c", o_console_data);
if (!reset && console_send) begin $fflush;
$write("%c", o_console_data); end
$fflush; end
end
end
endmodule // testbench endmodule // testbench

View File

@ -9,8 +9,11 @@ module testbench #(parameter CPU_COUNT = 1024)
logic [31:0] data_len; logic [31:0] data_len;
logic [CPU_COUNT-1:0] done_all; logic [CPU_COUNT-1:0] done_all;
int cycle = 0;
always @(posedge clock) cycle <= cycle + 1;
for (genvar ncpu = 0; ncpu < CPU_COUNT; ncpu = ncpu + 1) begin : cpus for (genvar ncpu = 0; ncpu < CPU_COUNT; ncpu = ncpu + 1) begin : cpus
logic done; logic done, done_ack = 1'b0;
logic reset; logic reset;
logic [127:0] md5; logic [127:0] md5;
@ -30,27 +33,27 @@ module testbench #(parameter CPU_COUNT = 1024)
if(!$value$plusargs("dlen=%d", data_len)) if(!$value$plusargs("dlen=%d", data_len))
data_len = DATA_LEN; data_len = DATA_LEN;
initial begin int reset_duration;
reset = 1'b1; initial reset_duration = $urandom % CPU_COUNT + 2;
repeat($urandom % 5 + 2) @(posedge clock); assign reset = cycle <= reset_duration;
reset = 1'b0;
@(posedge clock);
while(!done) @(posedge clock); always @(posedge clock) begin
$display("MD5(0x%x) = %x", ncpu, md5); if (cycle > reset_duration && done && !done_ack) begin
done_ack <= 1'b1;
$display("MD5(0x%x) = %x", ncpu, md5);
end
end end
end end
// Wait for complete // Wait for complete
initial begin always @(posedge clock) begin
$display("--- BENCH BEGIN ---"); if (cycle == 0) $display("--- BENCH BEGIN ---");
else if (cycle > 5) begin
repeat(5) @(posedge clock); if (&done_all) begin
while ((&done_all) == 1'b0) @(posedge clock); $display("--- BENCH DONE ---");
@(posedge clock); $finish;
end
$display("--- BENCH DONE ---"); end
$finish;
end end
endmodule // testbench endmodule // testbench

View File

@ -7,8 +7,8 @@ PARAMS :=
THREADS := 1 THREADS := 1
FLAGS = -Wno-WIDTH -cc --top-module $(TOP_MODULE) +1800-2017ext+sv \ FLAGS = -Wno-WIDTH -cc --top-module $(TOP_MODULE) +1800-2017ext+sv \
--timing --Mdir $(TOP_MODULE) -o $(TOP_MODULE) -f $(FLAGS_FILE) \ --Mdir $(TOP_MODULE) -o $(TOP_MODULE) -f $(FLAGS_FILE) \
$(PARAMS) --timescale "1ps/1ps" --threads $(THREADS) -j 0 $(PARAMS) --timescale "1ps/1ps" --threads $(THREADS) -j 16
# FLAGS += --trace # FLAGS += --trace

1
test-verilator5/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
top

19
test-verilator5/Makefile Normal file
View File

@ -0,0 +1,19 @@
TOP_MODULE = top
SOURCES = top.sv
FLAGS_FILE = ../source/sources.f
INCLUDES =
PARAMS :=
THREADS := 1
FLAGS = -Wno-WIDTH --top-module $(TOP_MODULE) +1800-2017ext+sv \
--timing --Mdir $(TOP_MODULE) -o $(TOP_MODULE) -f $(FLAGS_FILE) \
$(PARAMS) --timescale "1ps/1ps" --threads $(THREADS) -j 0
# FLAGS += --trace
all: $(SOURCES)
verilator $(FLAGS) --binary $(INCLUDES) $(SOURCES)
clean:
rm -rf $(TOP_MODULE)

7
test-verilator5/__build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e
. ../scripts/sim_vars.sh
make clean
make OPT_FAST="-Os -march=native" VM_PARALLEL_BUILDS=0 PARAMS="-GCPU_COUNT=$CPU_COUNT" THREADS=$THREADS

5
test-verilator5/__run.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
. ../scripts/sim_vars.sh
./top/top +dlen=$BLOCK_SIZE

7
test-verilator5/top.sv Normal file
View File

@ -0,0 +1,7 @@
`timescale 1ps/1ps
module top #(parameter CPU_COUNT = 2);
logic clock = 1'b0;
initial forever #(10ns/2) clock = ~clock;
testbench #(CPU_COUNT) testbench (clock);
endmodule