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.

68 lines
1.8 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use work.pkg.all;
  4. entity psl_stable is
  5. port (
  6. clk : in std_logic
  7. );
  8. end entity psl_stable;
  9. architecture psl of psl_stable is
  10. signal valid, ack, a : std_logic;
  11. signal b : std_logic_vector(3 downto 0);
  12. begin
  13. -- 0123456789
  14. SEQ_VALID : sequencer generic map ("_--__---__") port map (clk, valid);
  15. SEQ_ACK : sequencer generic map ("__-____-__") port map (clk, ack);
  16. SEQ_A : sequencer generic map ("_--_______") port map (clk, a);
  17. SEQ_B : hex_sequencer generic map ("0110066600") port map (clk, b);
  18. -- All is sensitive to rising edge of clk
  19. default clock is rising_edge(clk);
  20. -- This assertion holds
  21. STABLE_0_a : assert always {not valid; valid} |=> (stable(a) until_ ack);
  22. -- This assertion holds
  23. STABLE_1_a : assert always rose(valid) -> next (stable(b) until_ ack);
  24. -- Workaround needed before stable() was implemented
  25. -- With VHDL glue logic generating the
  26. -- previous value of a and simple comparing the two values
  27. a_reg : block is
  28. signal a_prev : std_logic;
  29. signal b_prev : std_logic_vector(b'range);
  30. begin
  31. process (clk) is
  32. begin
  33. if rising_edge(clk) then
  34. a_prev <= a;
  35. b_prev <= b;
  36. end if;
  37. end process;
  38. STABLE_2_a : assert always {not valid; valid} |=> (a = a_prev until_ ack);
  39. STABLE_3_a : assert always {not valid; valid} |=> (b = b_prev until_ ack);
  40. end block a_reg;
  41. -- Check parts of a vector
  42. -- This assertion holds
  43. STABLE_4_a : assert always rose(valid) -> next (stable(b(1 downto 0)) until_ ack);
  44. -- Stop simulation after longest running sequencer is finished
  45. -- Simulation only code by using pragmas
  46. -- synthesis translate_off
  47. stop_sim(clk, 10);
  48. -- synthesis translate_on
  49. end architecture psl;