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.

60 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 hold (see ghdl/ghdl#2157)
  23. NEXT_EVENT_0_a : assert always ((a and b = x"4") -> next_event_a(c)[1 to 4](b = x"4"))
  24. report "NEXT_EVENT_0_a failed";
  25. NEXT_EVENT_1_a : assert always ((a and b = x"5") -> next_event_a(c)[1 to 4](b = x"5"))
  26. report "NEXT_EVENT_1_a failed";
  27. -- Check for all possible values of b
  28. -- Workaround for missing PSL forall in {i to j} statement
  29. -- This assertions should hold
  30. -- Assertions for i = 4 & i = 5 don't hold, assuming GHDL bug
  31. check_b : for i in 0 to 2**b'length-1 generate
  32. signal i_slv : std_logic_vector(b'range);
  33. begin
  34. i_slv <= std_logic_vector(to_unsigned(i, 4));
  35. NEXT_EVENT_a : assert always ((a and b = i_slv) -> next_event_a(c)[1 to 4](b = i_slv));
  36. end generate check_b;
  37. -- Stop simulation after longest running sequencer is finished
  38. -- Simulation only code by using pragmas
  39. -- synthesis translate_off
  40. stop_sim(clk, 24);
  41. -- synthesis translate_on
  42. end architecture psl;