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.

167 lines
3.5 KiB

  1. module properties (
  2. input Reset_n_i,
  3. input Clk_i,
  4. input [7:0] Din_i,
  5. input DinValid_i,
  6. input DinStart_i,
  7. input DinStop_i,
  8. input DinAccept_o,
  9. input [7:0] Dout_o,
  10. input DoutValid_o,
  11. input DoutStart_o,
  12. input DoutStop_o,
  13. input DoutAccept_i,
  14. // Internals
  15. input [2:0] s_fsm_state,
  16. input [7:0] s_header
  17. );
  18. `define READ 0
  19. `define WRITE 1
  20. reg init_state = 1;
  21. // Initial reset
  22. always @(*) begin
  23. if (init_state) assume (!Reset_n_i);
  24. if (!init_state) assume (Reset_n_i);
  25. end
  26. always @(posedge Clk_i)
  27. init_state = 0;
  28. // Constraints
  29. assume property (@(posedge Clk_i)
  30. DinValid_i && !DinAccept_o |=>
  31. $stable(Din_i)
  32. );
  33. assume property (@(posedge Clk_i)
  34. DinValid_i && !DinAccept_o |=>
  35. $stable(DinStart_i)
  36. );
  37. assume property (@(posedge Clk_i)
  38. DinValid_i && !DinAccept_o |=>
  39. $stable(DinStop_i)
  40. );
  41. // Asserts
  42. assert property (@(posedge Clk_i)
  43. s_fsm_state >= 0 && s_fsm_state <= 6
  44. );
  45. assert property (@(posedge Clk_i)
  46. DoutStart_o |->
  47. DoutValid_o
  48. );
  49. assert property (@(posedge Clk_i)
  50. DoutStart_o && DoutAccept_i |=>
  51. !DoutStart_o
  52. );
  53. assert property (@(posedge Clk_i)
  54. DoutStop_o |->
  55. DoutValid_o
  56. );
  57. assert property (@(posedge Clk_i)
  58. DoutStop_o && DoutAccept_i |=>
  59. !DoutStop_o
  60. );
  61. assert property (@(posedge Clk_i)
  62. s_fsm_state == 1 && DinValid_i && DinStart_i && DinAccept_o |=>
  63. s_header == $past(Din_i)
  64. );
  65. // State changes
  66. assert property (@(posedge Clk_i) disable iff (!Reset_n_i)
  67. s_fsm_state == 0 |=> s_fsm_state == 1
  68. );
  69. assert property (@(posedge Clk_i) disable iff (!Reset_n_i)
  70. s_fsm_state == 1 && DinValid_i && DinStart_i && DinStop_i && Din_i[3:0] == `READ |=>
  71. s_fsm_state == 2
  72. );
  73. assert property (@(posedge Clk_i) disable iff (!Reset_n_i)
  74. s_fsm_state == 1 && DinValid_i && DinStart_i && !DinStop_i && Din_i[3:0] == `WRITE |=>
  75. s_fsm_state == 3
  76. );
  77. assert property (@(posedge Clk_i) disable iff (!Reset_n_i)
  78. s_fsm_state == 2 |=> s_fsm_state == 4
  79. );
  80. assert property (@(posedge Clk_i) disable iff (!Reset_n_i)
  81. s_fsm_state == 4 && DoutValid_o && DoutAccept_i && s_header[3:0] == `READ |=> s_fsm_state == 5
  82. );
  83. assert property (@(posedge Clk_i) disable iff (!Reset_n_i)
  84. s_fsm_state == 4 && DoutValid_o && DoutAccept_i && s_header[3:0] != `READ |=> s_fsm_state == 6
  85. );
  86. assert property (@(posedge Clk_i) disable iff (!Reset_n_i)
  87. s_fsm_state == 6 && DoutValid_o && DoutAccept_i |=> s_fsm_state == 0
  88. );
  89. // Protocol checks
  90. assert property (@(posedge Clk_i)
  91. s_fsm_state > 1 |->
  92. s_header[3:0] == `READ || s_header[3:0] == `WRITE
  93. );
  94. assert property (@(posedge Clk_i)
  95. DoutStart_o && DoutValid_o |->
  96. Dout_o[3:0] == s_header[3:0]
  97. );
  98. assert property (@(posedge Clk_i)
  99. DoutValid_o && !DoutAccept_i |=>
  100. $stable(Dout_o)
  101. );
  102. assert property (@(posedge Clk_i)
  103. DoutValid_o && !DoutAccept_i |=>
  104. $stable(DoutStart_o)
  105. );
  106. assert property (@(posedge Clk_i)
  107. DoutValid_o && !DoutAccept_i |=>
  108. $stable(DoutStop_o)
  109. );
  110. assert property (@(posedge Clk_i)
  111. DoutValid_o |-> !(DoutStart_o && DoutStop_o)
  112. );
  113. assert property (@(posedge Clk_i)
  114. DoutStart_o |-> s_fsm_state == 4
  115. );
  116. assert property (@(posedge Clk_i)
  117. DoutStop_o |-> s_fsm_state == 6
  118. );
  119. assert property (@(posedge Clk_i)
  120. DoutValid_o |-> s_fsm_state >= 4 && s_fsm_state <= 6
  121. );
  122. endmodule
  123. bind vai_reg properties properties (.*);