mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-07 01:54:10 +00:00
Added test cases for sat command
This commit is contained in:
parent
6891fd79a3
commit
7a66b38c3e
1
Makefile
1
Makefile
|
@ -135,6 +135,7 @@ test: yosys
|
||||||
cd tests/simple && bash run-test.sh
|
cd tests/simple && bash run-test.sh
|
||||||
cd tests/hana && bash run-test.sh
|
cd tests/hana && bash run-test.sh
|
||||||
cd tests/asicworld && bash run-test.sh
|
cd tests/asicworld && bash run-test.sh
|
||||||
|
cd tests/sat && bash run-test.sh
|
||||||
|
|
||||||
install: $(TARGETS) $(EXTRA_TARGETS)
|
install: $(TARGETS) $(EXTRA_TARGETS)
|
||||||
$(INSTALL_SUDO) mkdir -p $(DESTDIR)/bin
|
$(INSTALL_SUDO) mkdir -p $(DESTDIR)/bin
|
||||||
|
|
1
tests/sat/.gitignore
vendored
Normal file
1
tests/sat/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.log
|
14
tests/sat/asserts.v
Normal file
14
tests/sat/asserts.v
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// http://www.reddit.com/r/yosys/comments/1vljks/new_support_for_systemveriloglike_asserts/
|
||||||
|
module test(input clk, input rst, output y);
|
||||||
|
reg [2:0] state;
|
||||||
|
always @(posedge clk) begin
|
||||||
|
if (rst || state == 3) begin
|
||||||
|
state <= 0;
|
||||||
|
end else begin
|
||||||
|
assert(state < 3);
|
||||||
|
state <= state + 1;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assign y = state[2];
|
||||||
|
assert property (y !== 1'b1);
|
||||||
|
endmodule
|
3
tests/sat/asserts.ys
Normal file
3
tests/sat/asserts.ys
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
read_verilog asserts.v
|
||||||
|
hierarchy; proc; opt
|
||||||
|
sat -verify -seq 1 -set-at 1 rst 1 -tempinduct -prove-asserts
|
87
tests/sat/asserts_seq.v
Normal file
87
tests/sat/asserts_seq.v
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
module test_001(clk, a, a_old, b);
|
||||||
|
// test case taken from:
|
||||||
|
// http://www.reddit.com/r/yosys/comments/1wvpj6/trouble_with_assertions_and_sat_solver/
|
||||||
|
|
||||||
|
input wire clk;
|
||||||
|
input wire a;
|
||||||
|
|
||||||
|
output reg a_old = 0;
|
||||||
|
output reg b = 1;
|
||||||
|
wire assertion = (a_old != b);
|
||||||
|
|
||||||
|
always @(posedge clk) begin
|
||||||
|
a_old <= a;
|
||||||
|
b <= !a;
|
||||||
|
|
||||||
|
assert(a_old != b);
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module test_002(clk, a, a_old, b);
|
||||||
|
// copy from test_001 with modifications
|
||||||
|
|
||||||
|
input wire clk;
|
||||||
|
input wire a;
|
||||||
|
|
||||||
|
output reg a_old = 0;
|
||||||
|
output reg b = 0; // <-- this will fail
|
||||||
|
wire assertion = (a_old != b);
|
||||||
|
|
||||||
|
always @(posedge clk) begin
|
||||||
|
a_old <= a;
|
||||||
|
b <= !a;
|
||||||
|
assert(a_old != b);
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module test_003(clk, a, a_old, b);
|
||||||
|
// copy from test_001 with modifications
|
||||||
|
|
||||||
|
input wire clk;
|
||||||
|
input wire a;
|
||||||
|
|
||||||
|
output reg a_old = 0;
|
||||||
|
output reg b; // <-- this will fail
|
||||||
|
wire assertion = (a_old != b);
|
||||||
|
|
||||||
|
always @(posedge clk) begin
|
||||||
|
a_old <= a;
|
||||||
|
b <= !a;
|
||||||
|
assert(a_old != b);
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module test_004(clk, a, a_old, b);
|
||||||
|
// copy from test_001 with modifications
|
||||||
|
|
||||||
|
input wire clk;
|
||||||
|
input wire a;
|
||||||
|
|
||||||
|
output reg a_old = 0;
|
||||||
|
output reg b = 1;
|
||||||
|
wire assertion = (a_old != b);
|
||||||
|
|
||||||
|
always @(posedge clk) begin
|
||||||
|
a_old <= a;
|
||||||
|
b <= !a;
|
||||||
|
assert(a_old == b); // <-- this will fail
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module test_005(clk, a, a_old, b);
|
||||||
|
// copy from test_001 with modifications
|
||||||
|
|
||||||
|
input wire clk;
|
||||||
|
input wire a;
|
||||||
|
|
||||||
|
output reg a_old = 1; // <-- inverted, no problem
|
||||||
|
output reg b = 0;
|
||||||
|
wire assertion = (a_old != b);
|
||||||
|
|
||||||
|
always @(posedge clk) begin
|
||||||
|
a_old <= a;
|
||||||
|
b <= !a;
|
||||||
|
assert(a_old != b);
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
|
|
15
tests/sat/asserts_seq.ys
Normal file
15
tests/sat/asserts_seq.ys
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
read_verilog asserts_seq.v
|
||||||
|
hierarchy; proc; opt
|
||||||
|
|
||||||
|
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_003
|
||||||
|
sat -falsify -prove-asserts -tempinduct -seq 1 test_004
|
||||||
|
sat -verify -prove-asserts -tempinduct -seq 1 test_005
|
||||||
|
|
||||||
|
sat -verify -prove-asserts -seq 2 test_001
|
||||||
|
sat -falsify -prove-asserts -seq 2 test_002
|
||||||
|
sat -falsify -prove-asserts -seq 2 test_003
|
||||||
|
sat -falsify -prove-asserts -seq 2 test_004
|
||||||
|
sat -verify -prove-asserts -seq 2 test_005
|
||||||
|
|
6
tests/sat/run-test.sh
Executable file
6
tests/sat/run-test.sh
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
for x in *.ys; do
|
||||||
|
echo "Running $x.."
|
||||||
|
../../yosys -ql ${x%.ys}.log $x
|
||||||
|
done
|
Loading…
Reference in a new issue