--- /dev/null
+/*_pass.sby
+/*_fail.sby
+/*_pass
+/*_fail
+/*.ok
--- /dev/null
+
+TESTS = $(basename $(wildcard *.sv))
+
+all: $(addsuffix .ok,$(TESTS))
+
+%.ok: %.sv
+ bash runtest.sh $<
+
+clean:
+ rm -rf $(addsuffix .ok,$(TESTS))
+ rm -rf $(addsuffix _pass.sby,$(TESTS)) $(addsuffix _pass,$(TESTS))
+ rm -rf $(addsuffix _fail.sby,$(TESTS)) $(addsuffix _fail,$(TESTS))
+
always @(posedge clk)
consequent <= reset ? 0 : antecedent;
+`ifdef FAIL
test_assert: assert property ( @(posedge clk) disable iff (reset) antecedent |-> consequent )
else $error("Failed with consequent = ", $sampled(consequent));
+`else
+ test_assert: assert property ( @(posedge clk) disable iff (reset) antecedent |=> consequent )
+ else $error("Failed with consequent = ", $sampled(consequent));
+`endif
endmodule
end
a_rw: assert property ( @(posedge clock) !(read && write) );
+`ifdef FAIL
a_wr: assert property ( @(posedge clock) write |-> ready );
+`else
+ a_wr: assert property ( @(posedge clock) write |=> ready );
+`endif
endmodule
module top_properties (input logic clock, read, write, ready);
a_rw: assert property ( @(posedge clock) !(read && write) );
+`ifdef FAIL
a_wr: assert property ( @(posedge clock) write |-> ready );
+`else
+ a_wr: assert property ( @(posedge clock) write |=> ready );
+`endif
endmodule
bind top top_properties properties_inst (.*);
if (selB) Q <= QB;
end
- check_selA: assert property ( @(posedge clk) selA|=> Q == $past(QA) );
- check_selB: assert property ( @(posedge clk) selB|=> Q == $past(QB) );
- assume_not_11: assume property ( @(posedge clk) !(selA& selB) );
+ check_selA: assert property ( @(posedge clk) selA |=> Q == $past(QA) );
+ check_selB: assert property ( @(posedge clk) selB |=> Q == $past(QB) );
+`ifndef FAIL
+ assume_not_11: assume property ( @(posedge clk) !(selA & selB) );
+`endif
endmodule
module top_properties (input logic clock, read, write, ready);
a_rw: assert property ( @(posedge clock) !(read && write) );
+`ifdef FAIL
a_wr: assert property ( @(posedge clock) write |-> ready );
+`else
+ a_wr: assert property ( @(posedge clock) write |=> ready );
+`endif
endmodule
bind top top_properties properties_inst (.*);
end entity;
architecture rtl of top is
- signal read : std_logic;
- signal write : std_logic;
- signal ready : std_logic;
+ signal read : std_logic := '0';
+ signal write : std_logic := '0';
+ signal ready : std_logic := '0';
begin
process (clock) begin
if (rising_edge(clock)) then
assign ready = uut.ready;
a_rw: assert property ( @(posedge clock) !(read && write) );
+`ifdef FAIL
a_wr: assert property ( @(posedge clock) write |-> ready );
+`else
+ a_wr: assert property ( @(posedge clock) write |=> ready );
+`endif
endmodule
end entity;
architecture rtl of demo is
- signal read : std_logic;
- signal write : std_logic;
- signal ready : std_logic;
+ signal read : std_logic := '0';
+ signal write : std_logic := '0';
+ signal ready : std_logic := '0';
begin
process (clock) begin
if (rising_edge(clock)) then
--- /dev/null
+#!/bin/bash
+
+set -ex
+
+prefix=${1%.sv}
+test -f $prefix.sv
+
+generate_sby() {
+ cat <<- EOT
+ [options]
+ mode bmc
+ depth 10
+ expect $1
+
+ [engines]
+ smtbmc yices
+
+ [script]
+ EOT
+
+ if [ "$1" = "fail" ]; then
+ echo "verific -sv ${prefix}_fail.sv"
+ else
+ echo "verific -sv $prefix.sv"
+ fi
+
+ if [ -f $prefix.vhd ]; then
+ echo "verific -vhdl2008 $prefix.vhd"
+ fi
+
+ cat <<- EOT
+ verific -import -extnets -all top
+ prep -top top
+
+ [files]
+ $prefix.sv
+ EOT
+
+ if [ -f $prefix.vhd ]; then
+ echo "$prefix.vhd"
+ fi
+
+ if [ "$1" = "fail" ]; then
+ cat <<- EOT
+
+ [file ${prefix}_fail.sv]
+ \`define FAIL
+ \`include "$prefix.sv"
+ EOT
+ fi
+}
+
+generate_sby pass > ${prefix}_pass.sby
+generate_sby fail > ${prefix}_fail.sby
+
+sby --yosys $PWD/../../yosys -f ${prefix}_pass.sby
+sby --yosys $PWD/../../yosys -f ${prefix}_fail.sby
+
+touch $prefix.ok
+