fifo_w32_d3_A.vhd 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. -- ==============================================================
  2. -- File generated on Wed Jun 26 16:53:30 CEST 2019
  3. -- Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC v2018.3 (64-bit)
  4. -- SW Build 2405991 on Thu Dec 6 23:36:41 MST 2018
  5. -- IP Build 2404404 on Fri Dec 7 01:43:56 MST 2018
  6. -- Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.
  7. -- ==============================================================
  8. library IEEE;
  9. use IEEE.std_logic_1164.all;
  10. use IEEE.std_logic_unsigned.all;
  11. entity fifo_w32_d3_A_shiftReg is
  12. generic (
  13. DATA_WIDTH : integer := 32;
  14. ADDR_WIDTH : integer := 2;
  15. DEPTH : integer := 3);
  16. port (
  17. clk : in std_logic;
  18. data : in std_logic_vector(DATA_WIDTH-1 downto 0);
  19. ce : in std_logic;
  20. a : in std_logic_vector(ADDR_WIDTH-1 downto 0);
  21. q : out std_logic_vector(DATA_WIDTH-1 downto 0));
  22. end fifo_w32_d3_A_shiftReg;
  23. architecture rtl of fifo_w32_d3_A_shiftReg is
  24. --constant DEPTH_WIDTH: integer := 16;
  25. type SRL_ARRAY is array (0 to DEPTH-1) of std_logic_vector(DATA_WIDTH-1 downto 0);
  26. signal SRL_SIG : SRL_ARRAY;
  27. begin
  28. p_shift: process (clk)
  29. begin
  30. if (clk'event and clk = '1') then
  31. if (ce = '1') then
  32. SRL_SIG <= data & SRL_SIG(0 to DEPTH-2);
  33. end if;
  34. end if;
  35. end process;
  36. q <= SRL_SIG(conv_integer(a));
  37. end rtl;
  38. library ieee;
  39. use ieee.std_logic_1164.all;
  40. use ieee.std_logic_unsigned.all;
  41. use ieee.std_logic_arith.all;
  42. entity fifo_w32_d3_A is
  43. generic (
  44. MEM_STYLE : string := "shiftreg";
  45. DATA_WIDTH : integer := 32;
  46. ADDR_WIDTH : integer := 2;
  47. DEPTH : integer := 3);
  48. port (
  49. clk : IN STD_LOGIC;
  50. reset : IN STD_LOGIC;
  51. if_empty_n : OUT STD_LOGIC;
  52. if_read_ce : IN STD_LOGIC;
  53. if_read : IN STD_LOGIC;
  54. if_dout : OUT STD_LOGIC_VECTOR(DATA_WIDTH - 1 downto 0);
  55. if_full_n : OUT STD_LOGIC;
  56. if_write_ce : IN STD_LOGIC;
  57. if_write : IN STD_LOGIC;
  58. if_din : IN STD_LOGIC_VECTOR(DATA_WIDTH - 1 downto 0));
  59. end entity;
  60. architecture rtl of fifo_w32_d3_A is
  61. component fifo_w32_d3_A_shiftReg is
  62. generic (
  63. DATA_WIDTH : integer := 32;
  64. ADDR_WIDTH : integer := 2;
  65. DEPTH : integer := 3);
  66. port (
  67. clk : in std_logic;
  68. data : in std_logic_vector(DATA_WIDTH-1 downto 0);
  69. ce : in std_logic;
  70. a : in std_logic_vector(ADDR_WIDTH-1 downto 0);
  71. q : out std_logic_vector(DATA_WIDTH-1 downto 0));
  72. end component;
  73. signal shiftReg_addr : STD_LOGIC_VECTOR(ADDR_WIDTH - 1 downto 0);
  74. signal shiftReg_data, shiftReg_q : STD_LOGIC_VECTOR(DATA_WIDTH - 1 downto 0);
  75. signal shiftReg_ce : STD_LOGIC;
  76. signal mOutPtr : STD_LOGIC_VECTOR(ADDR_WIDTH downto 0) := (others => '1');
  77. signal internal_empty_n : STD_LOGIC := '0';
  78. signal internal_full_n : STD_LOGIC := '1';
  79. begin
  80. if_empty_n <= internal_empty_n;
  81. if_full_n <= internal_full_n;
  82. shiftReg_data <= if_din;
  83. if_dout <= shiftReg_q;
  84. process (clk)
  85. begin
  86. if clk'event and clk = '1' then
  87. if reset = '1' then
  88. mOutPtr <= (others => '1');
  89. internal_empty_n <= '0';
  90. internal_full_n <= '1';
  91. else
  92. if ((if_read and if_read_ce) = '1' and internal_empty_n = '1') and
  93. ((if_write and if_write_ce) = '0' or internal_full_n = '0') then
  94. mOutPtr <= mOutPtr - conv_std_logic_vector(1, 3);
  95. if (mOutPtr = conv_std_logic_vector(0, 3)) then
  96. internal_empty_n <= '0';
  97. end if;
  98. internal_full_n <= '1';
  99. elsif ((if_read and if_read_ce) = '0' or internal_empty_n = '0') and
  100. ((if_write and if_write_ce) = '1' and internal_full_n = '1') then
  101. mOutPtr <= mOutPtr + conv_std_logic_vector(1, 3);
  102. internal_empty_n <= '1';
  103. if (mOutPtr = conv_std_logic_vector(DEPTH, 3) - conv_std_logic_vector(2, 3)) then
  104. internal_full_n <= '0';
  105. end if;
  106. end if;
  107. end if;
  108. end if;
  109. end process;
  110. shiftReg_addr <= (others => '0') when mOutPtr(ADDR_WIDTH) = '1' else mOutPtr(ADDR_WIDTH-1 downto 0);
  111. shiftReg_ce <= (if_write and if_write_ce) and internal_full_n;
  112. U_fifo_w32_d3_A_shiftReg : fifo_w32_d3_A_shiftReg
  113. generic map (
  114. DATA_WIDTH => DATA_WIDTH,
  115. ADDR_WIDTH => ADDR_WIDTH,
  116. DEPTH => DEPTH)
  117. port map (
  118. clk => clk,
  119. data => shiftReg_data,
  120. ce => shiftReg_ce,
  121. a => shiftReg_addr,
  122. q => shiftReg_q);
  123. end rtl;