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.

63 lines
1.4 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use work.pkg.all;
  4. entity psl_rose is
  5. port (
  6. clk : in std_logic
  7. );
  8. end entity psl_rose;
  9. architecture psl of psl_rose is
  10. signal a, b : 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. -- All is sensitive to rising edge of clk
  16. default clock is rising_edge(clk);
  17. -- This assertion holds
  18. ROSE_0_a : assert always (rose(a) -> b);
  19. -- This assertion holds
  20. ROSE_1_a : assert always {not a; a} |-> rose(a);
  21. -- This assertion holds
  22. ROSE_2_a : assert always (rose(a) -> (not prev(a) and a));
  23. -- Workaround needed before rose() is implemented
  24. -- With VHDL glue logic generating the
  25. -- previous value of a and simple comparing the two values
  26. d_reg : block is
  27. signal a_prev : std_logic := '0';
  28. begin
  29. process (clk) is
  30. begin
  31. if rising_edge(clk) then
  32. a_prev <= a;
  33. end if;
  34. end process;
  35. ROSE_3_a : assert always (a and not a_prev -> b);
  36. end block d_reg;
  37. -- Another workaround by using simple SERE concatenation on LHS
  38. ROSE_4_a : assert always {not a; a} |-> b;
  39. -- Stop simulation after longest running sequencer is finished
  40. -- Simulation only code by using pragmas
  41. -- synthesis translate_off
  42. stop_sim(clk, 11);
  43. -- synthesis translate_on
  44. end architecture psl;