1 ----------------------------------------------------------------------------------
5 -- Create Date: 10:
01:
22 10/08/2013
7 -- Module Name: FIFO72x8192 - Behavioral
16 -- Revision 0.
01 -
File Created
17 -- Additional Comments:
19 ----------------------------------------------------------------------------------
21 use IEEE.STD_LOGIC_1164.
ALL;
22 use IEEE.STD_LOGIC_ARITH.
ALL;
23 use IEEE.STD_LOGIC_UNSIGNED.
ALL;
24 use IEEE.std_logic_misc.
all;
26 -- Uncomment the following library declaration if using
27 -- arithmetic functions with or values
28 --use IEEE.NUMERIC_STD.ALL;
30 -- Uncomment the following library declaration if instantiating
31 -- any Xilinx primitives in this code.
33 use UNISIM.VComponents.
all;
35 use UNIMACRO.vcomponents.
all;
41 di : in (32 downto 0);
44 do : out (64 downto 0);
50 type array2x7 is array (0 to 1) of (6 downto 0);
51 signal fifo_re : array2X7 := (others => (others => '0'));
52 signal fifo_we : array2X7 := (others => (others => '0'));
53 type array2x65 is array (0 to 1) of (64 downto 0);
54 signal dip : array2X65 := (others => (others => '0'));
55 signal dop : array2X65 := (others => (others => '0'));
56 signal fifo_empty : (13 downto 0) := (others => '0');
57 signal fifo_full : (13 downto 0) := (others => '0');
58 signal fifo_Almostfull : (13 downto 0) := (others => '0');
59 type array14X12 is array (0 to 13) of (11 downto 0);
60 signal rdcount : array14X12 := (others => (others => '0'));
61 signal wrcount : array14X12 := (others => (others => '0'));
62 signal BRAM_re : := '0';
63 signal BRAM_vld : := '0';
64 signal wa_equal_ra_q : := '0';
65 signal do_vld : (1 downto 0) := (others => '0');
66 signal wa : (12 downto 0) := (others => '0');
67 signal ra : (12 downto 0) := (others => '0');
70 dip(0)(64 downto 32) <= di;
73 if(clk'event and clk = '1')then
75 dip(0)(31 downto 0) <= di(31 downto 0);
79 g_FIFO_j: for j in 0 to 1 generate
80 g_FIFO: for i in 0 to 6 generate
81 i_FIFO : FIFO_DUALCLOCK_MACRO
83 DEVICE =>
"7SERIES",
-- Target Device: "VIRTEX5",
"VIRTEX6",
"7SERIES"
84 DATA_WIDTH =>
9,
-- Valid values are 1-72 (37-72 only valid when FIFO_SIZE="36Kb")
85 FIFO_SIZE =>
"36Kb",
-- Target BRAM, "18Kb" or "36Kb"
86 FIRST_WORD_FALL_THROUGH => TRUE
) -- Sets the FIFO FWFT to TRUE or FALSE
88 ALMOSTEMPTY =>
open,
-- 1-bit output almost empty
89 ALMOSTFULL =>
open,
-- 1-bit output almost full
90 DO => dop
(j
)(i*9+8
downto i*9
),
-- Output data, width defined by DATA_WIDTH parameter
91 EMPTY => fifo_empty
(j*7+i
),
-- 1-bit output empty
92 FULL => FIFO_full
(j*7+i
),
-- 1-bit output full
93 RDCOUNT => rdcount
(j*7+i
),
-- Output read count, width determined by FIFO depth
94 RDERR =>
open,
-- 1-bit output read error
95 WRCOUNT => wrcount
(j*7+i
),
-- Output write count, width determined by FIFO depth
96 WRERR =>
open,
-- 1-bit output write error
97 DI => dip
(j
)(i*9+8
downto i*9
),
-- Input data, width defined by DATA_WIDTH parameter
98 RDCLK => clk,
-- 1-bit input read clock
99 RDEN => FIFO_re
(j
)(i
),
-- 1-bit input read enable
100 RST => fifo_rst,
-- 1-bit input reset
101 WRCLK => clk,
-- 1-bit input write clock
102 WREN => FIFO_we
(j
)(i
) -- 1-bit input write enable
106 dip(1)(62 downto 0) <= dop(0)(62 downto 0);
107 FIFO6463 : BRAM_SDP_MACRO
109 BRAM_SIZE =>
"18Kb",
-- Target BRAM, "18Kb" or "36Kb"
110 DEVICE =>
"7SERIES",
-- Target device: "VIRTEX5",
"VIRTEX6",
"7SERIES",
"SPARTAN6"
111 WRITE_WIDTH =>
2,
-- Valid values are 1-72 (37-72 only valid when BRAM_SIZE="36Kb")
112 READ_WIDTH =>
2) -- Valid values are 1-72 (37-72 only valid when BRAM_SIZE="36Kb")
114 DO => dop
(1)(64 downto 63),
-- Output read data port, width defined by READ_WIDTH parameter
115 DI => dip
(0)(64 downto 63),
-- Input write data port, width defined by WRITE_WIDTH parameter
116 RDADDR => ra,
-- Input read address, width defined by read port depth
117 RDCLK => clk,
-- 1-bit input read clock
118 RDEN => BRAM_re,
-- 1-bit input read port enable
119 REGCE => '0',
-- 1-bit input read output register enable
120 RST => '0',
-- 1-bit input reset
121 WE => "
1",
-- Input write enable, width defined by write port depth
122 WRADDR => wa,
-- Input write address, width defined by write port depth
123 WRCLK => clk,
-- 1-bit input write clock
124 WREN => we
(1) -- 1-bit input write port enable
126 process(clk,fifo_rst)
128 if(fifo_rst = '1')then
129 wa <= (others => '0');
130 ra <= (others => '0');
131 wa_equal_ra_q <= '0';
135 elsif(clk'event and clk = '1')then
136 if(we(1) = '1' and fifo_en = '1')then
139 if(BRAM_re = '1')then
143 wa_equal_ra_q <= '1';
145 wa_equal_ra_q <= '0';
147 if(BRAM_re = '1')then
149 elsif(do_vld(1) = '0' or re = '1')then
152 if(BRAM_vld = '1')then
157 if(fifo_empty(13) = '0')then
162 if(fifo_empty(13) = '0')then
169 BRAM_re <= '1' when fifo_en = '1' and wa /= ra and wa_equal_ra_q = '0' and (BRAM_vld = '0' or do_vld(1) = '0' or re = '1') else '0';
172 if(clk'event and clk = '1')then
173 if(do_vld(1) = '0' or re = '1')then
174 do(64 downto 63) <= dop(1)(64 downto 63);
176 if(do_vld(0) = '0' or re = '1')then
177 do(62 downto 0) <= dop(1)(62 downto 0);
181 g_we_re : for i in 0 to 6 generate
182 FIFO_we(0)(i) <= '1' when we(1) = '1' and FIFO_en = '1' else '0';
183 FIFO_we(1)(i) <= '1' when FIFO_full(7+i) = '0' and fifo_empty(i) = '0' and FIFO_en = '1' else '0';
184 FIFO_re(1)(i) <= '1' when FIFO_en = '1' and fifo_empty(13) = '0' and (do_vld(0) = '0' or re = '1') else '0';
186 FIFO_re(0) <= FIFO_we(1);