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.

108 lines
2.1 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. signal ch : character;
  15. function to_bit (a : in character) return std_logic is
  16. variable ret : std_logic;
  17. begin
  18. case a is
  19. when '0' | '_' => ret := '0';
  20. when '1' | '-' => ret := '1';
  21. when others => ret := 'X';
  22. end case;
  23. return ret;
  24. end function to_bit;
  25. begin
  26. process (clk) is
  27. begin
  28. if rising_edge(clk) then
  29. if (index < seq'high) then
  30. index <= index + 1;
  31. end if;
  32. end if;
  33. end process;
  34. ch <= seq(index);
  35. data <= to_bit(ch);
  36. end architecture rtl;
  37. library ieee;
  38. use ieee.std_logic_1164.all;
  39. entity issue is
  40. port (
  41. clk : in std_logic
  42. );
  43. end entity issue;
  44. architecture psl of issue is
  45. component sequencer is
  46. generic (
  47. seq : string
  48. );
  49. port (
  50. clk : in std_logic;
  51. data : out std_logic
  52. );
  53. end component sequencer;
  54. signal a, b : std_logic;
  55. signal c, d : std_logic;
  56. signal e, f : std_logic;
  57. begin
  58. -- 01234567890
  59. SEQ_A : sequencer generic map ("__-_-______") port map (clk, a);
  60. SEQ_B : sequencer generic map ("_____-_-___") port map (clk, b);
  61. -- 01234567890
  62. SEQ_C : sequencer generic map ("__-_-______") port map (clk, c);
  63. SEQ_D : sequencer generic map ("_____-_____") port map (clk, d);
  64. -- 01234567890
  65. SEQ_E : sequencer generic map ("__-_-______") port map (clk, e);
  66. SEQ_F : sequencer generic map ("_____-----_") port map (clk, f);
  67. -- All is sensitive to rising edge of clk
  68. default clock is rising_edge(clk);
  69. -- This assertion holds
  70. NEXT_0_a : assert always (a -> next_e[3 to 5] (b));
  71. -- This assertion doesn't hold at cycle 9
  72. NEXT_1_a : assert always (c -> next_e[3 to 5] (d));
  73. -- This assertion holds
  74. NEXT_2_a : assert always (e -> next_e[3 to 5] (f));
  75. end architecture psl;