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.

98 lines
1.7 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. entity sequencer is
  4. generic (
  5. seq : string
  6. );
  7. port (
  8. clk : in std_logic;
  9. data : out std_logic
  10. );
  11. end entity sequencer;
  12. architecture rtl of sequencer is
  13. signal index : natural := seq'low;
  14. function to_bit (a : in character) return std_logic is
  15. variable ret : std_logic;
  16. begin
  17. case a is
  18. when '0' | '_' => ret := '0';
  19. when '1' | '-' => ret := '1';
  20. when others => ret := 'X';
  21. end case;
  22. return ret;
  23. end function to_bit;
  24. begin
  25. process (clk) is
  26. begin
  27. if rising_edge(clk) then
  28. if (index < seq'high) then
  29. index <= index + 1;
  30. end if;
  31. end if;
  32. end process;
  33. data <= to_bit(seq(index));
  34. end architecture rtl;
  35. library ieee;
  36. use ieee.std_logic_1164.all;
  37. library ieee;
  38. use ieee.std_logic_1164.all;
  39. use ieee.numeric_std.all;
  40. entity issue is
  41. port (
  42. clk : in std_logic
  43. );
  44. end entity issue;
  45. architecture psl of issue is
  46. component sequencer is
  47. generic (
  48. seq : string
  49. );
  50. port (
  51. clk : in std_logic;
  52. data : out std_logic
  53. );
  54. end component sequencer;
  55. signal a, b, c : std_logic;
  56. begin
  57. -- 01234567890123
  58. SEQ_A : sequencer generic map ("_-_____-______") port map (clk, a);
  59. SEQ_B : sequencer generic map ("__--____---___") port map (clk, b);
  60. SEQ_C : sequencer generic map ("____-______-__") port map (clk, c);
  61. -- All is sensitive to rising edge of clk
  62. default clock is rising_edge(clk);
  63. -- Doesn't work with inline PSL
  64. -- endpoint ENDPOINT_0_e is {a; b[*2]; c};
  65. -- endpoint in psl comment works
  66. -- psl endpoint ENDPOINT_1_e is {a; b[*3]; c};
  67. assert not ENDPOINT_1_e
  68. report "Endpoint hit"
  69. severity note;
  70. end architecture psl;