-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathic_fifo.vhd
86 lines (71 loc) · 2.01 KB
/
ic_fifo.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 13:39:22 04/29/2013
-- Design Name:
-- Module Name: ic_fifo - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
use work.octagon_types.all;
use work.octagon_funcs.all;
entity ic_fifo is
Port (
clk : in std_logic;
rd : in std_logic;
wr : in std_logic;
tidi : in std_logic_vector(2 downto 0);
din : in std_logic_vector(IM_BITS-1 downto 6);
dout : out std_logic_vector(IM_BITS-1 downto 6);
tido : out std_logic_vector(2 downto 0);
empty : out std_logic
);
end ic_fifo;
architecture Behavioral of ic_fifo is
type fd_type is array(0 to 7) of std_logic_vector(IM_BITS-1 downto 6);
type tid_type is array(0 to 7) of std_logic_vector(2 downto 0);
signal fifo_data : fd_type := (others => (others => '0'));
signal fifo_tiddata : tid_type := (others => (others => '0'));
signal rdptr : unsigned(3 downto 0) := "0000";
signal wrptr : unsigned(3 downto 0) := "0000";
begin
process(clk)
variable rdI : Integer;
variable wrI : Integer;
begin
if clk='1' and clk'Event then
empty <= to_std_logic(rdptr = wrptr);
rdI := to_integer(rdptr(2 downto 0));
dout <= fifo_data(rdI);
tido <= fifo_tiddata(rdI);
if rd='1' then
rdptr <= rdptr + 1;
end if;
if wr='1' then
wrI := to_integer(wrptr(2 downto 0));
fifo_data(wrI) <= din;
fifo_tiddata(wrI) <= tidi;
wrptr <= wrptr + 1;
end if;
end if;
end process;
end Behavioral;