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.

59 lines
1.7 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. use ieee.math_real.all;
  5. use work.pkg.all;
  6. entity psl_next_event_a is
  7. port (
  8. clk : in std_logic
  9. );
  10. end entity psl_next_event_a;
  11. architecture psl of psl_next_event_a is
  12. signal a, c : std_logic;
  13. signal b : std_logic_vector(3 downto 0);
  14. begin
  15. -- 012345678901234567890123
  16. SEQ_A : sequencer generic map ("_-______________-_______") port map (clk, a);
  17. SEQ_B : hex_sequencer generic map ("443334477444433355554555") port map (clk, b);
  18. SEQ_C : sequencer generic map ("_____-___---______--_--_") port map (clk, c);
  19. -- All is sensitive to rising edge of clk
  20. default clock is rising_edge(clk);
  21. -- Check for one possible value of b
  22. -- Both assertions should hold
  23. -- Assertions don't hold, assuming GHDL bug
  24. NEXT_EVENT_0_a : assert always ((a and b = x"4") -> next_event_a(c)[1 to 4](b = x"4"));
  25. NEXT_EVENT_1_a : assert always ((a and b = x"5") -> next_event_a(c)[1 to 4](b = x"5"));
  26. -- Check for all possible values of b
  27. -- Workaround for missing PSL forall in {i to j} statement
  28. -- This assertions should hold
  29. -- Assertions for i = 4 & i = 5 don't hold, assuming GHDL bug
  30. check_b : for i in 0 to 2**b'length-1 generate
  31. signal i_slv : std_logic_vector(b'range);
  32. begin
  33. i_slv <= std_logic_vector(to_unsigned(i, 4));
  34. NEXT_EVENT_a : assert always ((a and b = i_slv) -> next_event_a(c)[1 to 4](b = i_slv));
  35. end generate check_b;
  36. -- Stop simulation after longest running sequencer is finished
  37. -- Simulation only code by using pragmas
  38. -- synthesis translate_off
  39. stop_sim(clk, 24);
  40. -- synthesis translate_on
  41. end architecture psl;