3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-13 04:28:18 +00:00

tests: Run async2sync before sat and/or sim to handle $check cells

Right now neither `sat` nor `sim` have support for the `$check` cell.
For formal verification it is a good idea to always run either
async2sync or clk2fflogic which will (in a future commit) lower `$check`
to `$assert`, etc.

While `sim` should eventually support `$check` directly, using
`async2sync` is ok for the current tests that use `sim`, so this commit
also runs `async2sync` before running sim on designs containing
assertions.
This commit is contained in:
Jannis Harder 2024-01-22 17:44:05 +01:00
parent 2baa578d94
commit 331ac5285f
41 changed files with 59 additions and 19 deletions

View file

@ -107,7 +107,7 @@ reg [7:0] i = 0;
always @(posedge clk) begin always @(posedge clk) begin
if (i < VECTORLEN) begin if (i < VECTORLEN) begin
// FIXME: for some reason the first assert fails (despite comparing zero to zero) // FIXME: for some reason the first assert fails (despite comparing zero to zero)
if (i > 0) if (i > 0)
assert(y == y_expected); assert(y == y_expected);
i <= i + 1; i <= i + 1;
end end
@ -117,4 +117,5 @@ EOF
read_verilog +/quicklogic/qlf_k6n10f/dsp_sim.v read_verilog +/quicklogic/qlf_k6n10f/dsp_sim.v
hierarchy -top testbench hierarchy -top testbench
proc proc
async2sync
sim -assert -q -clock clk -n 20 sim -assert -q -clock clk -n 20

View file

@ -36,7 +36,7 @@ blockram_tests: "list[tuple[list[tuple[str, int]], str, list[str]]]" = [
([("ADDRESS_WIDTH", 14), ("DATA_WIDTH", 2)], "sync_ram_*dp", ["-assert-count 1 t:TDP36K", "-assert-count 1 t:TDP36K a:port_a_width=2 %i"]), ([("ADDRESS_WIDTH", 14), ("DATA_WIDTH", 2)], "sync_ram_*dp", ["-assert-count 1 t:TDP36K", "-assert-count 1 t:TDP36K a:port_a_width=2 %i"]),
([("ADDRESS_WIDTH", 15), ("DATA_WIDTH", 1)], "sync_ram_*dp", ["-assert-count 1 t:TDP36K", "-assert-count 1 t:TDP36K a:port_a_width=1 %i"]), ([("ADDRESS_WIDTH", 15), ("DATA_WIDTH", 1)], "sync_ram_*dp", ["-assert-count 1 t:TDP36K", "-assert-count 1 t:TDP36K a:port_a_width=1 %i"]),
# 2x asymmetric (1024x36bit write / 2048x18bit read or vice versa = 1TDP36K) # 2x asymmetric (1024x36bit write / 2048x18bit read or vice versa = 1TDP36K)
([("ADDRESS_WIDTH", 11), ("DATA_WIDTH", 18), ("SHIFT_VAL", 1)], "sync_ram_sdp_w*r", ["-assert-count 1 t:TDP36K"]), ([("ADDRESS_WIDTH", 11), ("DATA_WIDTH", 18), ("SHIFT_VAL", 1)], "sync_ram_sdp_w*r", ["-assert-count 1 t:TDP36K"]),
([("ADDRESS_WIDTH", 11), ("DATA_WIDTH", 16), ("SHIFT_VAL", 1)], "sync_ram_sdp_w*r", ["-assert-count 1 t:TDP36K"]), ([("ADDRESS_WIDTH", 11), ("DATA_WIDTH", 16), ("SHIFT_VAL", 1)], "sync_ram_sdp_w*r", ["-assert-count 1 t:TDP36K"]),
([("ADDRESS_WIDTH", 12), ("DATA_WIDTH", 9), ("SHIFT_VAL", 1)], "sync_ram_sdp_w*r", ["-assert-count 1 t:TDP36K"]), ([("ADDRESS_WIDTH", 12), ("DATA_WIDTH", 9), ("SHIFT_VAL", 1)], "sync_ram_sdp_w*r", ["-assert-count 1 t:TDP36K"]),
@ -131,6 +131,7 @@ read_verilog -defer -formal mem_tb.v
chparam{param_str} -set VECTORLEN {vectorlen} TB chparam{param_str} -set VECTORLEN {vectorlen} TB
hierarchy -top TB -check hierarchy -top TB -check
prep prep
async2sync
log ** CHECKING SIMULATION FOR TEST {top} WITH PARAMS{param_str} log ** CHECKING SIMULATION FOR TEST {top} WITH PARAMS{param_str}
sim -clock clk -n {vectorlen} -assert sim -clock clk -n {vectorlen} -assert
""" """
@ -254,16 +255,16 @@ sim_tests: list[TestClass] = [
{"rq_a": 0x5678}, {"rq_a": 0x5678},
] ]
), ),
TestClass( # basic TDP test TestClass( # basic TDP test
# note that the testbench uses ra and wa, while the common TDP model # note that the testbench uses ra and wa, while the common TDP model
# uses a shared address # uses a shared address
params={"ADDRESS_WIDTH": 10, "DATA_WIDTH": 36}, params={"ADDRESS_WIDTH": 10, "DATA_WIDTH": 36},
top="sync_ram_tdp", top="sync_ram_tdp",
assertions=[], assertions=[],
test_steps=[ test_steps=[
{"wce_a": 1, "ra_a": 0x0A, "wce_b": 1, "ra_b": 0xBA, {"wce_a": 1, "ra_a": 0x0A, "wce_b": 1, "ra_b": 0xBA,
"wd_a": 0xdeadbeef, "wd_b": 0x5a5a5a5a}, "wd_a": 0xdeadbeef, "wd_b": 0x5a5a5a5a},
{"wce_a": 1, "ra_a": 0xFF, {"wce_a": 1, "ra_a": 0xFF,
"wd_a": 0}, "wd_a": 0},
{"rce_a": 1, "ra_a": 0x0A, "rce_b": 1, "ra_b": 0x0A}, {"rce_a": 1, "ra_a": 0x0A, "rce_b": 1, "ra_b": 0x0A},
{"rq_a": 0xdeadbeef, "rq_b": 0xdeadbeef}, {"rq_a": 0xdeadbeef, "rq_b": 0xdeadbeef},
@ -276,9 +277,9 @@ sim_tests: list[TestClass] = [
top="sync_ram_tdp", top="sync_ram_tdp",
assertions=[], assertions=[],
test_steps=[ test_steps=[
{"wce_a": 1, "ra_a": 0x0F, "wce_b": 1, "ra_b": 0xBA, {"wce_a": 1, "ra_a": 0x0F, "wce_b": 1, "ra_b": 0xBA,
"wd_a": 0xdeadbeef, "wd_b": 0x5a5a5a5a}, "wd_a": 0xdeadbeef, "wd_b": 0x5a5a5a5a},
{"wce_a": 1, "ra_a": 0xFF, {"wce_a": 1, "ra_a": 0xFF,
"wd_a": 0}, "wd_a": 0},
{"rce_a": 1, "ra_a": 0x0F, "rce_b": 1, "ra_b": 0x0A}, {"rce_a": 1, "ra_a": 0x0F, "rce_b": 1, "ra_b": 0x0A},
{"rq_a": 0, "rq_b": 0x00005a5a}, {"rq_a": 0, "rq_b": 0x00005a5a},
@ -291,7 +292,7 @@ sim_tests: list[TestClass] = [
top="sync_ram_tdp", top="sync_ram_tdp",
assertions=[], assertions=[],
test_steps=[ test_steps=[
{"wce_a": 1, "ra_a": 0x0A, "wce_b": 1, "ra_b": 0xBA, {"wce_a": 1, "ra_a": 0x0A, "wce_b": 1, "ra_b": 0xBA,
"wd_a": 0xdeadbeef, "wd_b": 0x5a5a5a5a}, "wd_a": 0xdeadbeef, "wd_b": 0x5a5a5a5a},
{"wce_a": 1, "ra_a": 0xBA, "rce_b": 1, "ra_b": 0xBA, {"wce_a": 1, "ra_a": 0xBA, "rce_b": 1, "ra_b": 0xBA,
"wd_a": 0xa5a5a5a5}, "wd_a": 0xa5a5a5a5},
@ -409,7 +410,7 @@ for sim_test in sim_tests:
fn = f"t_mem{i}.ys" fn = f"t_mem{i}.ys"
f = open(fn, mode="w") f = open(fn, mode="w")
j = 0 j = 0
# output yosys script test file # output yosys script test file
print( print(
blockram_template.format(param_str=param_str, top=top), blockram_template.format(param_str=param_str, top=top),

View file

@ -10,5 +10,6 @@ select -assert-count 1 t:TDP36K a:is_split=0 %i
select -assert-count 1 t:TDP36K a:was_split_candidate=0 %i select -assert-count 1 t:TDP36K a:was_split_candidate=0 %i
read_verilog +/quicklogic/common/cells_sim.v +/quicklogic/qlf_k6n10f/cells_sim.v +/quicklogic/qlf_k6n10f/brams_sim.v +/quicklogic/qlf_k6n10f/sram1024x18_mem.v +/quicklogic/qlf_k6n10f/ufifo_ctl.v +/quicklogic/qlf_k6n10f/TDP18K_FIFO.v read_verilog +/quicklogic/common/cells_sim.v +/quicklogic/qlf_k6n10f/cells_sim.v +/quicklogic/qlf_k6n10f/brams_sim.v +/quicklogic/qlf_k6n10f/sram1024x18_mem.v +/quicklogic/qlf_k6n10f/ufifo_ctl.v +/quicklogic/qlf_k6n10f/TDP18K_FIFO.v
prep prep
async2sync
hierarchy -top top hierarchy -top top
sim -assert -q -n 12 -clock clk sim -assert -q -n 12 -clock clk

View file

@ -30,6 +30,7 @@ module top(output [42:0] P);
assert property (P == 42*42); assert property (P == 42*42);
endmodule endmodule
EOT EOT
async2sync
techmap -map +/xilinx/xc7_dsp_map.v techmap -map +/xilinx/xc7_dsp_map.v
verilog_defaults -add -D ALLOW_WHITEBOX_DSP48E1 verilog_defaults -add -D ALLOW_WHITEBOX_DSP48E1
synth_xilinx -abc9 synth_xilinx -abc9

View file

@ -75,7 +75,7 @@ generate_tests() {
if [[ $do_sv = true ]]; then if [[ $do_sv = true ]]; then
for x in *.sv; do for x in *.sv; do
if [ ! -f "${x%.sv}.ys" ]; then if [ ! -f "${x%.sv}.ys" ]; then
generate_ys_test "$x" "-p \"prep -top top; sat -enable_undef -verify -prove-asserts\" $yosys_args" generate_ys_test "$x" "-p \"prep -top top; async2sync; sat -enable_undef -verify -prove-asserts\" $yosys_args"
fi; fi;
done done
fi; fi;

View file

@ -1,3 +1,3 @@
read_verilog -sv asserts.v read_verilog -sv asserts.v
hierarchy; proc; opt hierarchy; proc; opt; async2sync
sat -verify -seq 1 -set-at 1 rst 1 -tempinduct -prove-asserts sat -verify -seq 1 -set-at 1 rst 1 -tempinduct -prove-asserts

View file

@ -1,5 +1,5 @@
read_verilog -sv asserts_seq.v read_verilog -sv asserts_seq.v
hierarchy; proc; opt hierarchy; proc; opt; async2sync
sat -verify -prove-asserts -tempinduct -seq 1 test_001 sat -verify -prove-asserts -tempinduct -seq 1 test_001
sat -falsify -prove-asserts -tempinduct -seq 1 test_002 sat -falsify -prove-asserts -tempinduct -seq 1 test_002

View file

@ -1,5 +1,5 @@
read_verilog -sv initval.v read_verilog -sv initval.v
proc;; proc; async2sync;;
sat -seq 10 -prove-asserts sat -seq 10 -prove-asserts

View file

@ -1,2 +1,2 @@
read_verilog -sv sizebits.sv read_verilog -sv sizebits.sv
prep; sat -verify -prove-asserts prep; async2sync; sat -verify -prove-asserts

View file

@ -1,5 +1,5 @@
read_verilog -sv enum_simple.sv read_verilog -sv enum_simple.sv
hierarchy; proc; opt hierarchy; proc; opt; async2sync
sat -verify -seq 1 -set-at 1 rst 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -set-at 1 rst 1 -tempinduct -prove-asserts -show-all

View file

@ -4,4 +4,5 @@ select -assert-count 2 t:$shift
select -assert-count 2 t:$shiftx select -assert-count 2 t:$shiftx
prep -top top prep -top top
flatten flatten
async2sync
sat -enable_undef -verify -prove-asserts sat -enable_undef -verify -prove-asserts

View file

@ -9,6 +9,6 @@ logger -expect warning "reg '\\var_18' is assigned in a continuous assignment" 1
logger -expect warning "reg '\\var_19' is assigned in a continuous assignment" 1 logger -expect warning "reg '\\var_19' is assigned in a continuous assignment" 1
read_verilog -sv typedef_initial_and_assign.sv read_verilog -sv typedef_initial_and_assign.sv
hierarchy; proc; opt hierarchy; proc; opt; async2sync
select -module top select -module top
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -1,5 +1,5 @@
read_verilog -sv typedef_struct_port.sv read_verilog -sv typedef_struct_port.sv
hierarchy; proc; opt hierarchy; proc; opt; async2sync
select -module top select -module top
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all
select -module test_parser select -module test_parser

View file

@ -13,6 +13,8 @@ EOT
prep -top top prep -top top
async2sync
select -assert-count 1 t:$cover select -assert-count 1 t:$cover
chformal -cover -coverenable chformal -cover -coverenable

View file

@ -37,14 +37,17 @@ EOT
if ../../yosys -q -p 'verific -sv chparam1.sv'; then if ../../yosys -q -p 'verific -sv chparam1.sv'; then
../../yosys -q -p 'verific -sv chparam1.sv; hierarchy -chparam X 123123123 -top top; prep -flatten' \ ../../yosys -q -p 'verific -sv chparam1.sv; hierarchy -chparam X 123123123 -top top; prep -flatten' \
-p 'async2sync' \
-p 'sat -verify -prove-asserts -show-ports -set din[0] 1' \ -p 'sat -verify -prove-asserts -show-ports -set din[0] 1' \
-p 'sat -falsify -prove-asserts -show-ports -set din[0] 0' -p 'sat -falsify -prove-asserts -show-ports -set din[0] 0'
../../yosys -q -p 'verific -sv chparam2.sv; hierarchy -chparam X 123123123 -top top; prep -flatten' \ ../../yosys -q -p 'verific -sv chparam2.sv; hierarchy -chparam X 123123123 -top top; prep -flatten' \
-p 'async2sync' \
-p 'sat -verify -prove-asserts -show-ports -set din[0] 1' \ -p 'sat -verify -prove-asserts -show-ports -set din[0] 1' \
-p 'sat -falsify -prove-asserts -show-ports -set din[0] 0' -p 'sat -falsify -prove-asserts -show-ports -set din[0] 0'
fi fi
../../yosys -q -p 'read_verilog -sv chparam2.sv; hierarchy -chparam X 123123123 -top top; prep -flatten' \ ../../yosys -q -p 'read_verilog -sv chparam2.sv; hierarchy -chparam X 123123123 -top top; prep -flatten' \
-p 'async2sync' \
-p 'sat -verify -prove-asserts -show-ports -set din[0] 1' \ -p 'sat -verify -prove-asserts -show-ports -set din[0] 1' \
-p 'sat -falsify -prove-asserts -show-ports -set din[0] 0' -p 'sat -falsify -prove-asserts -show-ports -set din[0] 0'

View file

@ -3,4 +3,5 @@ hierarchy
proc proc
opt -full opt -full
select -module top select -module top
async2sync
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -4,4 +4,5 @@ proc
flatten flatten
opt -full opt -full
select -module top select -module top
async2sync
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -4,4 +4,5 @@ proc
flatten flatten
opt -full opt -full
select -module top select -module top
async2sync
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -47,4 +47,5 @@ end
endmodule endmodule
EOF EOF
hierarchy; proc; opt hierarchy; proc; opt
async2sync
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -2,4 +2,5 @@ read_verilog -sv struct_access.sv
hierarchy hierarchy
proc proc
opt opt
async2sync
sat -verify -seq 1 -prove-asserts -show-all sat -verify -seq 1 -prove-asserts -show-all

View file

@ -1,3 +1,4 @@
read_verilog -sv asgn_expr.sv read_verilog -sv asgn_expr.sv
proc proc
async2sync
sat -verify -prove-asserts -show-all sat -verify -prove-asserts -show-all

View file

@ -14,6 +14,6 @@ always_comb begin
end end
endmodule endmodule
EOT EOT
hierarchy; proc; opt hierarchy; proc; opt; async2sync
select -module dut select -module dut
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -17,6 +17,7 @@ output reg b
endmodule endmodule
EOT EOT
proc proc
async2sync
sat -verify -prove-asserts sat -verify -prove-asserts
@ -42,6 +43,7 @@ output b, c
endmodule endmodule
EOT EOT
proc proc
async2sync
sat -verify -prove-asserts sat -verify -prove-asserts

View file

@ -1,4 +1,5 @@
read_verilog -sv func_tern_hint.sv read_verilog -sv func_tern_hint.sv
proc proc
opt opt
async2sync
sat -verify -seq 1 -prove-asserts -show-all sat -verify -seq 1 -prove-asserts -show-all

View file

@ -3,5 +3,6 @@ hierarchy -top top
proc proc
flatten flatten
opt -full opt -full
async2sync
select -module top select -module top
sat -verify -seq 1 -prove-asserts -enable_undef sat -verify -seq 1 -prove-asserts -enable_undef

View file

@ -3,5 +3,6 @@ hierarchy
proc proc
flatten flatten
opt -full opt -full
async2sync
select -module top select -module top
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -3,4 +3,5 @@ proc
flatten flatten
opt -full opt -full
select -module top select -module top
async2sync
sat -verify -seq 1 -tempinduct -prove-asserts -show-all -enable_undef sat -verify -seq 1 -tempinduct -prove-asserts -show-all -enable_undef

View file

@ -2,4 +2,5 @@ read_verilog -sv net_types.sv
hierarchy hierarchy
proc proc
opt -full opt -full
async2sync
sat -verify -prove-asserts -show-all sat -verify -prove-asserts -show-all

View file

@ -1,4 +1,5 @@
read_verilog -sv package_task_func.sv read_verilog -sv package_task_func.sv
proc proc
opt -full opt -full
async2sync
sat -verify -seq 1 -prove-asserts -show-all sat -verify -seq 1 -prove-asserts -show-all

View file

@ -3,5 +3,6 @@ hierarchy
proc proc
flatten flatten
opt -full opt -full
async2sync
select -module top select -module top
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -16,5 +16,6 @@ hierarchy
proc proc
flatten flatten
opt -full opt -full
async2sync
select -module top select -module top
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -14,6 +14,7 @@ endmodule
EOT EOT
prep -top top prep -top top
async2sync
sim -n 3 -clock clk sim -n 3 -clock clk
design -reset design -reset
@ -32,4 +33,5 @@ endmodule
EOT EOT
prep -top top prep -top top
async2sync
sim -n 3 -clock clk sim -n 3 -clock clk

View file

@ -2,4 +2,5 @@ read_verilog -sv prefix.sv
hierarchy hierarchy
proc proc
select -module top select -module top
async2sync
sat -verify -seq 1 -prove-asserts -show-all sat -verify -seq 1 -prove-asserts -show-all

View file

@ -14,6 +14,7 @@ endmodule
EOT EOT
prep -top top prep -top top
async2sync
sim -n 3 -clock clk sim -n 3 -clock clk
design -reset design -reset
@ -32,6 +33,7 @@ endmodule
EOT EOT
prep -top top prep -top top
async2sync
sim -n 3 -clock clk sim -n 3 -clock clk
design -reset design -reset
@ -49,4 +51,5 @@ endmodule
EOT EOT
prep -top top prep -top top
async2sync
sim -n 3 -clock clk sim -n 3 -clock clk

View file

@ -2,4 +2,5 @@ read_verilog -sv size_cast.sv
proc proc
opt -full opt -full
select -module top select -module top
async2sync
sat -verify -prove-asserts -show-all sat -verify -prove-asserts -show-all

View file

@ -1,4 +1,5 @@
read_verilog -formal -sv struct_access.sv read_verilog -formal -sv struct_access.sv
proc proc
opt -full opt -full
async2sync
sat -verify -seq 1 -prove-asserts -show-all sat -verify -seq 1 -prove-asserts -show-all

View file

@ -19,5 +19,6 @@ EOF
proc proc
opt -full opt -full
async2sync
select -module top select -module top
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -33,5 +33,6 @@ hierarchy
proc proc
flatten flatten
opt -full opt -full
async2sync
select -module top select -module top
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -3,5 +3,6 @@ hierarchy
proc proc
flatten flatten
opt -full opt -full
async2sync
select -module top select -module top
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -3,5 +3,6 @@ hierarchy
proc proc
flatten flatten
opt -full opt -full
async2sync
select -module top select -module top
sat -verify -seq 1 -tempinduct -prove-asserts -show-all sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -12,6 +12,7 @@ endmodule
EOT EOT
prep -top top prep -top top
async2sync
sim -n 3 -clock clk sim -n 3 -clock clk
design -reset design -reset
@ -29,5 +30,6 @@ endmodule
EOT EOT
prep -top top prep -top top
async2sync
sim -n 3 -clock clk sim -n 3 -clock clk