-
Notifications
You must be signed in to change notification settings - Fork 0
/
ack_issuer.vhd
104 lines (88 loc) · 2.22 KB
/
ack_issuer.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
-----------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 2015/10/22 17:28:08
-- Design Name:
-- Module Name: ack_issuer - 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;
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_SIGNED.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 leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
library work;
use work.rhea_pkg.all;
entity ack_issuer is
generic (
delay : integer := 0);
port (
clk : in std_logic;
rst : in std_logic;
req : in std_logic;
busy : out std_logic;
ack : buffer std_logic;
ack_cnt : buffer std_logic_vector(7 downto 0));
end ack_issuer;
architecture Behavioral of ack_issuer is
type state_type is (s0, s1, s2);
signal state : state_type;
begin -- architecture Behavioral
busy <= '1' when state /= s0 else '0';
ack <= '1' when state = s2 else '0';
process(clk)
variable cnt : integer := 0;
begin
if rising_edge(clk) then
if rst = '1' then
cnt := 0;
state <= s0;
else
case state is
when s0 =>
if req = '1' then
state <= s1;
else
state <= s0;
end if;
when s1 =>
if cnt = delay then
state <= s2;
else
cnt := cnt + 1;
state <= s1;
end if;
when s2 => state <= s0;
when others => null;
end case;
end if;
end if;
end process;
process(clk)
begin
if rising_edge(clk) then
if rst = '1' then
ack_cnt <= (others => '0');
else
ack_cnt <= ack_cnt + ack;
end if;
end if;
end process;
end architecture Behavioral;