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.

118 lines
1.9 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. signal a, b : std_logic;
  47. begin
  48. -- 012345678901
  49. SEQ_A : entity work.sequencer generic map ("__-___-_____") port map (clk, a);
  50. SEQ_B : entity work.sequencer generic map ("___-_____-__") port map (clk, b);
  51. -- All is sensitive to rising edge of clk
  52. default clock is rising_edge(clk);
  53. -- This assertion should hold
  54. INF_a : assert always {a} |=> {not b[*0 to inf]; b};
  55. end architecture psl;
  56. library ieee;
  57. use ieee.std_logic_1164.all;
  58. use std.env.all;
  59. entity test_issue is
  60. end entity test_issue;
  61. architecture sim of test_issue is
  62. signal clk : std_logic := '1';
  63. begin
  64. clk <= not clk after 500 ps;
  65. DUT : entity work.issue(psl) port map (clk);
  66. -- stop simulation after 30 cycles
  67. process
  68. variable index : natural := 29;
  69. begin
  70. loop
  71. wait until rising_edge(clk);
  72. index := index - 1;
  73. exit when index = 0;
  74. end loop;
  75. stop(0);
  76. end process;
  77. end architecture sim;