Trying to verify Verilog/VHDL designs with formal methods and tools
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.9 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. entity fwft_fifo is
  5. generic (
  6. Formal : boolean := true;
  7. Depth : positive := 16;
  8. Width : positive := 16
  9. );
  10. port (
  11. Reset_n_i : in std_logic;
  12. Clk_i : in std_logic;
  13. -- write
  14. Wen_i : in std_logic;
  15. Din_i : in std_logic_vector(Width-1 downto 0);
  16. Full_o : out std_logic;
  17. Werror_o : out std_logic;
  18. -- read
  19. Ren_i : in std_logic;
  20. Dout_o : out std_logic_vector(Width-1 downto 0);
  21. Empty_o : out std_logic;
  22. Rerror_o : out std_logic
  23. );
  24. end entity fwft_fifo;
  25. architecture rtl of fwft_fifo is
  26. signal s_empty : std_logic;
  27. signal s_ren : std_logic;
  28. begin
  29. i_fifo : entity work.fifo
  30. generic map (
  31. Formal => Formal,
  32. Depth => Depth,
  33. Width => Width
  34. )
  35. port map (
  36. Reset_n_i => Reset_n_i,
  37. Clk_i => Clk_i,
  38. -- write
  39. Wen_i => Wen_i,
  40. Din_i => Din_i,
  41. Full_o => Full_o,
  42. Werror_o => Werror_o,
  43. -- read
  44. Ren_i => s_ren,
  45. Dout_o => Dout_o,
  46. Empty_o => s_empty,
  47. Rerror_o => open
  48. );
  49. s_ren <= not s_empty and (Empty_o or Ren_i);
  50. ReadFlagsP : process (Reset_n_i, Clk_i) is
  51. begin
  52. if (Reset_n_i = '0') then
  53. Empty_o <= '1';
  54. Rerror_o <= '0';
  55. elsif (rising_edge(Clk_i)) then
  56. Rerror_o <= Ren_i and Empty_o;
  57. if (s_ren = '1') then
  58. Empty_o <= '0';
  59. elsif (Ren_i = '1') then
  60. Empty_o <= '1';
  61. end if;
  62. end if;
  63. end process ReadFlagsP;
  64. FormalG : if Formal generate
  65. default clock is rising_edge(Clk_i);
  66. -- Initial reset
  67. RESTRICT_RESET : restrict
  68. {not Reset_n_i[*3]; Reset_n_i[+]}[*1];
  69. -- Inputs are low during reset for simplicity
  70. ASSUME_INPUTS_DURING_RESET : assume always
  71. not Reset_n_i ->
  72. not Wen_i and not Ren_i;
  73. end generate FormalG;
  74. end architecture rtl;