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.

70 lines
1.7 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use work.pkg.all;
  4. entity psl_fell is
  5. port (
  6. clk : in std_logic
  7. );
  8. end entity psl_fell;
  9. architecture psl of psl_fell is
  10. signal a, b, c : std_logic;
  11. begin
  12. -- 01234567890
  13. SEQ_A : sequencer generic map ("--__-_---__") port map (clk, a);
  14. SEQ_B : sequencer generic map ("_-__-_---__") port map (clk, b);
  15. SEQ_C : sequencer generic map ("__-__-___-_") port map (clk, c);
  16. -- All is sensitive to rising edge of clk
  17. default clock is rising_edge(clk);
  18. -- This assertion holds
  19. FELL_0_a : assert always (fell(a) -> c);
  20. -- This assertion holds
  21. FELL_1_a : assert always {a; not a} |-> fell(a);
  22. -- This assertion holds
  23. FELL_2_a : assert always (fell(a) -> (prev(a) and not a));
  24. -- Workaround needed before fell() is implemented
  25. -- With VHDL glue logic generating the
  26. -- previous value of a and simple comparing the two values
  27. d_reg : block is
  28. signal a_prev : std_logic := '0';
  29. begin
  30. process (clk) is
  31. begin
  32. if rising_edge(clk) then
  33. a_prev <= a;
  34. end if;
  35. end process;
  36. FELL_3_a : assert always (not a and a_prev -> c);
  37. end block d_reg;
  38. -- Another workaround by using simple SERE concatenation on LHS
  39. FELL_4_a : assert always {a; not a} |-> c;
  40. -- This assertion doesn't in formal tests
  41. -- in the 1st cycle. Problem is the value of
  42. -- a in the 0th cycle. So fell() can be safely
  43. -- used from the 2nd cycle on only
  44. FELL_5_a : assert always (fell(b) -> c);
  45. -- Stop simulation after longest running sequencer is finished
  46. -- Simulation only code by using pragmas
  47. -- synthesis translate_off
  48. stop_sim(clk, 11);
  49. -- synthesis translate_on
  50. end architecture psl;