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.

72 lines
1.9 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use work.pkg.all;
  4. entity psl_prev is
  5. port (
  6. clk : in std_logic
  7. );
  8. end entity psl_prev;
  9. architecture psl of psl_prev is
  10. signal valid : std_logic;
  11. signal a : std_logic;
  12. signal d : std_logic_vector(3 downto 0);
  13. begin
  14. -- 01234567890123
  15. SEQ_VALID : sequencer generic map ("____-_-_-_-_-_") port map (clk, valid);
  16. SEQ_A : sequencer generic map ("-__--__--__--_") port map (clk, a);
  17. SEQ_D : hex_sequencer generic map ("00011223344556") port map (clk, d);
  18. -- All is sensitive to rising edge of clk
  19. default clock is rising_edge(clk);
  20. -- This assertion holds
  21. PREV_0_a : assert always (valid -> a = prev(a));
  22. -- This assertion should hold
  23. -- prev() with vector parameter isn't supported yet
  24. -- Workaround: VHDL glue logic and simple compare
  25. -- PREV_1_a : assert always (valid -> d = prev(d));
  26. -- Workaround with VHDL glue logic generating the
  27. -- previous value of d and simple comparing the two values
  28. d_reg : block is
  29. signal d_prev : std_logic_vector(d'range);
  30. begin
  31. process (clk) is
  32. begin
  33. if rising_edge(clk) then
  34. d_prev <= d;
  35. end if;
  36. end process;
  37. PREV_2_a : assert always (valid -> d = d_prev);
  38. end block d_reg;
  39. -- Using prev() with additional parameter i, should return
  40. -- the value of the expression in the i-th previous cycle
  41. -- prev(a) = prev(a, 1)
  42. -- This assertion holds
  43. PREV_3_a : assert always (valid -> a = prev(a, 1));
  44. -- Using prev() with additional parameter i, should return
  45. -- the value of the expression in the i-th previous cycle
  46. -- This assertion holds
  47. PREV_4_a : assert always (valid -> a = prev(a, 4));
  48. -- Stop simulation after longest running sequencer is finished
  49. -- Simulation only code by using pragmas
  50. -- synthesis translate_off
  51. stop_sim(clk, 14);
  52. -- synthesis translate_on
  53. end architecture psl;