Examples of using PSL for functional and formal verification of VHDL with GHDL (and SymbiYosys)
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.

115 lines
3.5 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use work.pkg.all;
  4. entity psl_sere_consecutive_repetition is
  5. port (
  6. clk : in std_logic
  7. );
  8. end entity psl_sere_consecutive_repetition;
  9. architecture psl of psl_sere_consecutive_repetition is
  10. signal a, b, c : std_logic;
  11. signal d, e, f : std_logic;
  12. signal g, h, i : std_logic;
  13. begin
  14. -- 012345678
  15. SEQ_A : sequencer generic map ("_-_______") port map (clk, a);
  16. SEQ_B : sequencer generic map ("__----___") port map (clk, b);
  17. SEQ_C : sequencer generic map ("______-__") port map (clk, c);
  18. -- 012345
  19. SEQ_D : sequencer generic map ("_-____") port map (clk, d);
  20. SEQ_E : sequencer generic map ("______") port map (clk, e);
  21. SEQ_F : sequencer generic map ("__-___") port map (clk, f);
  22. -- 0123456789
  23. SEQ_G : sequencer generic map ("_-________") port map (clk, g);
  24. SEQ_H : sequencer generic map ("__-_-_-___") port map (clk, h);
  25. SEQ_I : sequencer generic map ("________-_") port map (clk, i);
  26. -- All is sensitive to rising edge of clk
  27. default clock is rising_edge(clk);
  28. -- Simple SERE with repetitions done manual without operators
  29. -- This assertion holds
  30. SERE_0_a : assert always {a} |=> {b; b; b; b; c};
  31. -- Repetition of 4 cycles
  32. -- In all these cycles b has to be active
  33. -- This assertion holds
  34. SERE_1_a : assert always {a} |=> {b[*4]; c};
  35. -- Repetition in range of 3 to 5 cycles
  36. -- In all these cycles b has to be active
  37. -- This assertion holds
  38. SERE_2_a : assert always {a} |=> {b[*3 to 5]; c};
  39. -- Repetition of any number of cycles, including none
  40. -- In all these cycles b has to be active
  41. -- This assertion holds
  42. SERE_3_a : assert always {a} |=> {b[*]; c};
  43. -- Repetition of any number of cycles, excluding none
  44. -- In all these cycles b has to be active
  45. -- This assertion holds
  46. SERE_4_a : assert always {a} |=> {b[+]; c};
  47. -- Repetition of any number of cycles, including none
  48. -- In all these cycles e has to be active
  49. -- This assertion holds
  50. SERE_5_a : assert always {d} |=> {e[*]; f};
  51. -- Repetition of any number of cycles, excluding none
  52. -- In all these cycles e has to be active
  53. -- This assertion doesn't hold at cycle 2
  54. SERE_6_a : assert always {d} |=> {e[+]; f};
  55. -- Repetition of 3 cycles
  56. -- In all these cycles h has to be active
  57. -- This assertion doesn't hold at cycle 3
  58. SERE_7_a : assert always {g} |=> {h[*3]; i};
  59. -- Repetition in range of 2 to 4 cycles
  60. -- In all these cycles h has to be active
  61. -- This assertion doesn't hold at cycle 3
  62. SERE_8_a : assert always {g} |=> {h[*2 to 4]; i};
  63. -- Repetition of any number of cycles, including none
  64. -- In all these cycles h has to be active
  65. -- This assertion doesn't hold at cycle 3
  66. SERE_9_a : assert always {g} |=> {h[*]; i};
  67. -- Repetition of any number of cycles, exluding none
  68. -- In all these cycles h has to be active
  69. -- This assertion doesn't hold at cycle 3
  70. SERE_10_a : assert always {g} |=> {h[+]; i};
  71. -- Repetition of any 6 cycles
  72. -- This assertion holds
  73. SERE_11_a : assert always {g} |=> {[*6]; i};
  74. -- Upper bound can also be infinity
  75. -- This assertion holds
  76. SERE_12_a : assert always {g} |=> {[*6]; i; not i[*1 to inf]};
  77. -- All repetition operators can also be used with SERE
  78. -- This assertion holds
  79. SERE_13_a : assert always {g} |=> {{h; not h}[*3]; i};
  80. -- Stop simulation after longest running sequencer is finished
  81. -- Simulation only code by using pragmas
  82. -- synthesis translate_off
  83. stop_sim(clk, 10);
  84. -- synthesis translate_on
  85. end architecture psl;