Trying to verify Verilog/VHDL designs with formal methods and tools
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.0 KiB

  1. module counter_t (
  2. input Reset_n_i,
  3. input Clk_i,
  4. output [31:0] Data_o
  5. );
  6. `define INITVAL 8
  7. `define ENDVAL 64
  8. counter #(
  9. .InitVal(`INITVAL),
  10. .EndVal(`ENDVAL)
  11. ) counter_i (
  12. .Reset_n_i(Reset_n_i),
  13. .Clk_i(Clk_i),
  14. .Data_o(Data_o)
  15. );
  16. reg init_state = 1;
  17. // Initial reset
  18. always @(*) begin
  19. if (init_state) assume (!Reset_n_i);
  20. if (!init_state) assume (Reset_n_i);
  21. end
  22. always @(posedge Clk_i)
  23. init_state = 0;
  24. /*
  25. // Don't works with Verific at the moment
  26. initial begin
  27. assume (!Reset_n_i);
  28. end
  29. */
  30. // Intermediate assertions
  31. always @(*)
  32. if (!Reset_n_i) assert (Data_o == `INITVAL);
  33. // Fails with unbounded prove using SMTBMC, maybe
  34. // the assumptions/assertions have to be more strict.
  35. // With abc pdr this can be successfully proved.
  36. assert property (@(posedge Clk_i) disable iff (!Reset_n_i) Data_o < `ENDVAL |=> Data_o == $past(Data_o) + 1);
  37. assert property (@(posedge Clk_i) disable iff (!Reset_n_i) Data_o == `ENDVAL |=> $stable(Data_o));
  38. endmodule