1 | ---------------------------------------------------------------------------------- |
---|
2 | -- Company: |
---|
3 | -- Engineer: |
---|
4 | -- |
---|
5 | -- Create Date: 04:35:05 10/15/2012 |
---|
6 | -- Design Name: |
---|
7 | -- Module Name: FIfo_mem - 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 | |
---|
21 | |
---|
22 | library IEEE; |
---|
23 | use IEEE.std_logic_1164.all; |
---|
24 | use IEEE.std_logic_unsigned.all; |
---|
25 | entity FIFO is |
---|
26 | generic (N: integer := 6; -- number of address bits for 2**N address locations |
---|
27 | M: integer := 8); -- number of data bits to/from FIFO |
---|
28 | port (CLK, PUSH, POP, INIT: in std_logic; |
---|
29 | DIN: in std_logic_vector(N-1 downto 0); |
---|
30 | DOUT: out std_logic_vector(N-1 downto 0); |
---|
31 | FULL, EMPTY, NOPUSH, NOPOP: out std_logic; |
---|
32 | clk: IN std_logic; |
---|
33 | |
---|
34 | rd_en: IN std_logic; |
---|
35 | srst: IN std_logic; |
---|
36 | wr_en: IN std_logic; |
---|
37 | |
---|
38 | empty: OUT std_logic; |
---|
39 | full: OUT std_logic); |
---|
40 | end entity FIFO; |
---|
41 | architecture TOP_HIER of FIFO is |
---|
42 | signal WE: std_logic; |
---|
43 | signal A: std_logic_vector(N-1 downto 0); |
---|
44 | signal PUSH, POP, INIT: std_logic; |
---|
45 | |
---|
46 | signal NOPUSH, NOPOP: std_logic; |
---|
47 | |
---|
48 | component FIFO_LOGIC is |
---|
49 | generic (N: integer); -- number of address bits |
---|
50 | port (CLK, PUSH, POP, INIT: in std_logic; |
---|
51 | ADD: out std_logic_vector(N-1 downto 0); |
---|
52 | FULL, EMPTY, WE, NOPUSH, NOPOP: buffer std_logic); |
---|
53 | end component FIFO_LOGIC; |
---|
54 | |
---|
55 | COMPONENT RAM_256 |
---|
56 | PORT( |
---|
57 | clka : IN std_logic; |
---|
58 | clkb : IN std_logic; |
---|
59 | wea : IN std_logic; |
---|
60 | ena : IN std_logic; |
---|
61 | enb : IN std_logic; |
---|
62 | addra : IN std_logic_vector(Word-1 downto 0); |
---|
63 | addrb : IN std_logic_vector(Word-1 downto 0); |
---|
64 | dia : IN std_logic_vector(Word-1 downto 0); |
---|
65 | dob : OUT std_logic_vector(Word-1 downto 0) |
---|
66 | ); |
---|
67 | END COMPONENT; |
---|
68 | begin |
---|
69 | -- example of component instantiation using positional notation |
---|
70 | FL: FIFO_LOGIC generic map (N) |
---|
71 | port map (CLK, PUSH, POP, INIT, A, FULL, EMPTY, WE, NOPUSH, NOPOP); |
---|
72 | Push<=wr_en; |
---|
73 | pop<=rd_en; |
---|
74 | nopush<=nopush; |
---|
75 | nopop<=nopop; |
---|
76 | init<=srst; |
---|
77 | -- example of component instantiation using keyword notation |
---|
78 | --R: RAM generic map (W => N, K => M) |
---|
79 | -- port map (DIN => DIN, ADDR => A, WR => WE, DOUT => DOUT); |
---|
80 | R: RAM_256 PORT MAP( |
---|
81 | clka => clk, |
---|
82 | clkb => clk, |
---|
83 | wea => we, |
---|
84 | ena => '1', |
---|
85 | enb => '1', |
---|
86 | addra => A, |
---|
87 | addrb => A, |
---|
88 | dia => din, |
---|
89 | dob => dout |
---|
90 | ); |
---|
91 | end architecture TOP_HIER; |
---|