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.

61 lines
1.1 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. (* gclk *) wire gbl_clk;
  18. // Initial reset
  19. always @(*) begin
  20. if (init_state) assume (!Reset_n_i);
  21. if (!init_state) assume (Reset_n_i);
  22. end
  23. always @(posedge Clk_i)
  24. init_state = 0;
  25. // Generate global clock
  26. global clocking
  27. @(posedge gbl_clk);
  28. endclocking
  29. // Use global clock to constrain the DUT clock
  30. always @($global_clock) begin
  31. assume (Clk_i != $past(Clk_i));
  32. end
  33. default clocking
  34. @(posedge Clk_i);
  35. endclocking
  36. default disable iff (!Reset_n_i);
  37. // Immediate assertions
  38. always @(*)
  39. if (!Reset_n_i) assert (Data_o == `INITVAL);
  40. // Concurrent assertions
  41. assert property (Data_o < `ENDVAL |=> Data_o == $past(Data_o) + 1);
  42. assert property (Data_o == `ENDVAL |=> $stable(Data_o));
  43. assert property (Data_o >= `INITVAL && Data_o <= `ENDVAL);
  44. endmodule