Advertisement
Guest User

Untitled

a guest
May 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.47 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer: Nabil Sayegh
  4. --
  5. -- Create Date:    12:11:03 08/07/2009
  6. -- Design Name:
  7. -- Module Name:    fifo_fwft - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library ieee;
  21.   use ieee.std_logic_1164.all;
  22.   use ieee.numeric_std.all;
  23.  
  24. entity fifo_fwft is
  25.     generic
  26.     (
  27.     addr_width : Integer;
  28.     data_width : Integer
  29.     );
  30.     port
  31.     (
  32.         clock              : IN  std_logic;
  33.         reset              : IN  std_logic;
  34.  
  35.         wren               : IN  std_logic;
  36.         rdack              : IN  std_logic;
  37.         din                : IN  std_logic_vector(data_width-1 downto 0);
  38.         dout               : OUT std_logic_vector(data_width-1 downto 0);
  39.         valid              : OUT std_logic;
  40.         almost_full        : OUT std_logic
  41.     );
  42. end entity fifo_fwft;
  43.  
  44. architecture Behavioral of fifo_fwft is
  45.     signal rden : std_logic;
  46.     signal valid_reg : std_logic;
  47.    
  48.     signal empty : std_logic;
  49. begin
  50.  
  51.     Inst_fifo: entity work.fifo_simple
  52.     generic MAP
  53.     (
  54.         addr_width => addr_width,
  55.         data_width => data_width
  56.     )
  57.     port map
  58.     (
  59.         clock => clock,
  60.         reset => reset,
  61.         wren => wren,
  62.         rden => rden,
  63.         din => din,
  64.         dout => dout,
  65.         empty => empty,
  66.         almost_full => almost_full
  67.     );
  68.  
  69.     -- fwft fifo replaces empty by a valid signal
  70.     -- if we ack a read, then the next data will be at the output in the next cycle and valid still high
  71.     -- otherwise, if there is no data anymore, valid will be 0 at the next cycle
  72.  
  73.    
  74.     -- if current data isn't valid anymore and there is more data -> prefetch
  75.     rden <= (not valid_reg and not empty) or (rdack and not empty);
  76.     valid <= valid_reg;
  77. --  assert not (valid_reg='0' and rdack='1') report "Usage error! valid='0' and rdack='1' is forbidden: " & integer'image(to_integer(unsigned'(0=>valid_reg))) & "/" & integer'image(to_integer(unsigned'(0=>rdack)));
  78.     process (clock, reset)
  79.     begin
  80.         if rising_edge(clock) then
  81.             -- look ahead
  82.             -- if previously the data was valid and it wasn't read or there is even more data
  83.             -- the second part can be seen as a delayed empty
  84.  
  85.             valid_reg <= (valid_reg and not rdack) or (not empty);
  86.  
  87.         end if;
  88.        
  89.         if reset = '1' then
  90.             valid_reg <= '0';
  91.         end if;
  92.     end process;
  93.  
  94. end architecture Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement