AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
FIFO_sync.vhd
1 ------------------------------------------------------
2 -- Component FIFO
3 --
4 -- Ver 1.00
5 --
6 -- Dominique Gigi May 2015
7 ------------------------------------------------------
8 -- This file contain un instatiation of a FIFO (ALTERA or XILINX)
9 -- with he almost FUll signal
10 --
11 --
12 ------------------------------------------------------
13 LIBRARY ieee;
14 USE ieee.std_logic_1164.all;
15 use ieee.numeric_std.all;
16 
17 
18 entity FIFO_sync is
19 generic ( fifo_deep : integer := 6
20  );
21 port
22  (
23  aclr : in std_logic; -- active low
24  clk_w : in std_logic;
25  wen : in std_logic;
26  dataw : in std_logic_vector(65 downto 0);
27  almost_f : out std_logic; -- active low
28  clk_r : in std_logic;
29  datar : out std_logic_vector(65 downto 0);
30  ren : in std_logic;
31  empty : out std_logic -- active low
32  );
33 end FIFO_sync;
34 
35 architecture behavioral of FIFO_sync is
36 
37 
38 
39 --***********************************************************
40 --********************** ALTERA DC FIFO *******************
41 --***********************************************************
42 
43 -- component LPM_FIFO_v14
44  -- PORT
45  -- (
46  -- aclr : IN STD_LOGIC := '0';
47  -- data : IN STD_LOGIC_VECTOR (65 DOWNTO 0);
48  -- rdclk : IN STD_LOGIC ;
49  -- rdreq : IN STD_LOGIC ;
50  -- wrclk : IN STD_LOGIC ;
51  -- wrreq : IN STD_LOGIC ;
52  -- q : OUT STD_LOGIC_VECTOR (65 DOWNTO 0);
53  -- rdempty : OUT STD_LOGIC ;
54  -- wrusedw : OUT STD_LOGIC_VECTOR (5 DOWNTO 0)
55  -- );
56 -- end component;
57 
58 
59 COMPONENT lpm_fifo_dc -- !!!!!!!!!!!!!!! XILINX ISE and VIVADO VERSION !!!!!!!!!!!!!
60  PORT (
61  rst : IN STD_LOGIC;
62  wr_clk : IN STD_LOGIC;
63  rd_clk : IN STD_LOGIC;
64  din : IN STD_LOGIC_VECTOR(65 DOWNTO 0);
65  wr_en : IN STD_LOGIC;
66  rd_en : IN STD_LOGIC;
67  dout : OUT STD_LOGIC_VECTOR(65 DOWNTO 0);
68  full : OUT STD_LOGIC;
69  empty : OUT STD_LOGIC;
70  wr_data_count : OUT STD_LOGIC_VECTOR(5 DOWNTO 0)
71  );
72 END COMPONENT;
73 
74 
75 
76 signal almost_full_reg : std_logic;
77 signal resetp : std_logic;
78 signal word_used : std_logic_vector(fifo_deep-1 downto 0);
79 
80 
81 --***********************************************************
82 --********************** BEGIN ****************************
83 --***********************************************************
84 begin
85 
86 resetp <= '1' when aclr = '0' else '0';
87 
88 
89 -- fifo_dc:LPM_FIFO_v14 -- !!!!!!!!!!!!! ALTERA VERSION
90 -- port MAP(
91  -- DATA => dataw,
92  -- wrclk => clk_w,
93  -- rdclk => clk_r,
94  -- WRREQ => wen,
95  -- RDREQ => ren,
96  -- ACLR => resetp,
97  -- Q => datar,
98  -- WRUSEDW => word_used,
99  -- RDEMPTY => empty
100  -- );
101 
102 fifo_dc : lpm_fifo_dc -- !!!!!!!!!!!!!!! XILINX ISE and Vivado VERSION !!!!!!!!!!!!!
103  PORT MAP (
104  rst => resetp,
105  wr_clk => clk_w,
106  din => dataw,
107  wr_en => wen,
108  wr_data_count => word_used,
109  rd_clk => clk_r,
110  rd_en => ren,
111  dout => datar,
112  -- full => full,
113  empty => empty
114 
115  );
116 
117 
118 
119 
120 process(aclr,clk_w)
121 begin
122 if aclr = '0' then
123  almost_full_reg <= '1';
124 elsif rising_edge(clk_w) then
125  if word_used >= "110000" then --enable almostFull when reaches 48 data in FIFO of 64
126  almost_full_reg <= '0';
127  elsif word_used < "100101" then -- realize almostFull below 37 data in FIFO of 64
128  almost_full_reg <= '1';
129  end if;
130 end if;
131 end process;
132 
133 almost_f <= almost_full_reg;
134 
135 end behavioral;