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.

171 lines
3.1 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. default clocking
  29. @(posedge Clk_i);
  30. endclocking
  31. // Constraints
  32. assume property (
  33. DinValid_i && !DinAccept_o |=>
  34. $stable(Din_i)
  35. );
  36. assume property (
  37. DinValid_i && !DinAccept_o |=>
  38. $stable(DinStart_i)
  39. );
  40. assume property (
  41. DinValid_i && !DinAccept_o |=>
  42. $stable(DinStop_i)
  43. );
  44. // Asserts
  45. assert property (
  46. s_fsm_state >= 0 && s_fsm_state <= 6
  47. );
  48. assert property (
  49. DoutStart_o |->
  50. DoutValid_o
  51. );
  52. assert property (
  53. DoutStart_o && DoutAccept_i |=>
  54. !DoutStart_o
  55. );
  56. assert property (
  57. DoutStop_o |->
  58. DoutValid_o
  59. );
  60. assert property (
  61. DoutStop_o && DoutAccept_i |=>
  62. !DoutStop_o
  63. );
  64. assert property (
  65. s_fsm_state == 1 && DinValid_i && DinStart_i && DinAccept_o |=>
  66. s_header == $past(Din_i)
  67. );
  68. // State changes
  69. assert property (disable iff (!Reset_n_i)
  70. s_fsm_state == 0 |=> s_fsm_state == 1
  71. );
  72. assert property (disable iff (!Reset_n_i)
  73. s_fsm_state == 1 && DinValid_i && DinStart_i && DinStop_i && Din_i[3:0] == `READ |=>
  74. s_fsm_state == 2
  75. );
  76. assert property (disable iff (!Reset_n_i)
  77. s_fsm_state == 1 && DinValid_i && DinStart_i && !DinStop_i && Din_i[3:0] == `WRITE |=>
  78. s_fsm_state == 3
  79. );
  80. assert property (disable iff (!Reset_n_i)
  81. s_fsm_state == 2 |=> s_fsm_state == 4
  82. );
  83. assert property (disable iff (!Reset_n_i)
  84. s_fsm_state == 4 && DoutValid_o && DoutAccept_i && s_header[3:0] == `READ |=> s_fsm_state == 5
  85. );
  86. assert property (disable iff (!Reset_n_i)
  87. s_fsm_state == 4 && DoutValid_o && DoutAccept_i && s_header[3:0] != `READ |=> s_fsm_state == 6
  88. );
  89. assert property (disable iff (!Reset_n_i)
  90. s_fsm_state == 6 && DoutValid_o && DoutAccept_i |=> s_fsm_state == 0
  91. );
  92. // Protocol checks
  93. assert property (
  94. s_fsm_state > 1 |->
  95. s_header[3:0] inside {`READ, `WRITE}
  96. );
  97. assert property (
  98. DoutStart_o && DoutValid_o |->
  99. Dout_o[3:0] == s_header[3:0]
  100. );
  101. assert property (
  102. DoutValid_o && !DoutAccept_i |=>
  103. $stable(Dout_o)
  104. );
  105. assert property (
  106. DoutValid_o && !DoutAccept_i |=>
  107. $stable(DoutStart_o)
  108. );
  109. assert property (
  110. DoutValid_o && !DoutAccept_i |=>
  111. $stable(DoutStop_o)
  112. );
  113. assert property (
  114. DoutValid_o |-> !(DoutStart_o && DoutStop_o)
  115. );
  116. assert property (
  117. DoutStart_o |-> s_fsm_state == 4
  118. );
  119. assert property (
  120. DoutStop_o |-> s_fsm_state == 6
  121. );
  122. assert property (
  123. DoutValid_o |-> s_fsm_state >= 4 && s_fsm_state <= 6
  124. );
  125. endmodule
  126. bind vai_reg properties properties (.*);