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.

90 lines
2.6 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use work.pkg.all;
  4. entity psl_before is
  5. port (
  6. clk : in std_logic
  7. );
  8. end entity psl_before;
  9. architecture psl of psl_before is
  10. signal a, b : std_logic;
  11. signal c, d : std_logic;
  12. signal e, f : std_logic;
  13. begin
  14. -- 01234567890
  15. SEQ_A : sequencer generic map ("_-____-____") port map (clk, a);
  16. SEQ_B : sequencer generic map ("___-_____-_") port map (clk, b);
  17. -- 01234567890
  18. SEQ_C : sequencer generic map ("_-___-_____") port map (clk, c);
  19. SEQ_D : sequencer generic map ("_____-___-_") port map (clk, d);
  20. -- 01234567890
  21. SEQ_E : sequencer generic map ("_-____-____") port map (clk, e);
  22. SEQ_F : sequencer generic map ("_-_______-_") port map (clk, f);
  23. -- All is sensitive to rising edge of clk
  24. default clock is rising_edge(clk);
  25. -- This assertion holds
  26. BEFORE_0_a : assert always (a -> next (b before a))
  27. report "BEFORE_0_a failed";
  28. -- This assertion doesn't hold at cycle 5
  29. BEFORE_1_a : assert always (c -> next (d before c))
  30. report "BEFORE_1_a failed";
  31. -- This assertion doesn't hold at cycle 6
  32. BEFORE_2_a : assert always (e -> next (f before e))
  33. report "BEFORE_2_a failed";
  34. -- This is flawed variant of the former assertion
  35. -- because even in cycle 1 the b before a property has
  36. -- to hold, which is clearly not what we want
  37. -- This assertion doesn't hold at cycle 1
  38. -- Furthermore this assertion leads to a GHDL crash with bug report
  39. -- BEFORE_3_a : assert always (a -> (b before a))
  40. -- report "BEFORE_3_a failed";
  41. -- This assertion holds (see ghdl/ghdl#2153)
  42. BEFORE_4_a : assert always (a -> next (b before_ a))
  43. report "BEFORE_4_a failed";
  44. -- This assertion holds (see ghdl/ghdl#2153)
  45. BEFORE_5_a : assert always (c -> next (d before_ c))
  46. report "BEFORE_5_a failed";
  47. -- This assertion doesn't at cycle 6
  48. BEFORE_6_a : assert always (e -> next (f before_ e))
  49. report "BEFORE_6_a failed";
  50. -- This assertion holds
  51. BEFORE_7_a : assert always (a -> (b or next (b before a)))
  52. report "BEFORE_7_a failed";
  53. -- This assertion doesn't hold at cycle 5
  54. BEFORE_8_a : assert always (c -> (d or next (d before c)))
  55. report "BEFORE_8_a failed";
  56. -- This assertion holds
  57. BEFORE_9_a : assert always (e -> (f or next (f before e)))
  58. report "BEFORE_9_a failed";
  59. -- Stop simulation after longest running sequencer is finished
  60. -- Simulation only code by using pragmas
  61. -- synthesis translate_off
  62. stop_sim(clk, 11);
  63. -- synthesis translate_on
  64. end architecture psl;