-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgc_rr_arbiter.vhd
112 lines (91 loc) · 3 KB
/
gc_rr_arbiter.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
105
106
107
108
109
110
111
112
-------------------------------------------------------------------------------
-- Title : Round-robin arbiter
-- Project : General Cores
-------------------------------------------------------------------------------
-- File : gc_rr_arbiter.vhd
-- Author : Tomasz Wlostowski
-- Company : CERN
-- Platform : FPGA-generics
-- Standard : VHDL '93
-------------------------------------------------------------------------------
-- Copyright (c) 2012 CERN
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the GNU Lesser General
-- Public License as published by the Free Software Foundation;
-- either version 2.1 of the License, or (at your option) any
-- later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the GNU Lesser General Public License for more
-- details.
--
-- You should have received a copy of the GNU Lesser General
-- Public License along with this source; if not, download it
-- from http://www.gnu.org/licenses/lgpl-2.1.html
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity gc_rr_arbiter is
generic (
g_size : integer := 19);
port (
clk_i : in std_logic;
rst_n_i : in std_logic;
req_i : in std_logic_vector(g_size-1 downto 0);
grant_o : out std_logic_vector(g_size-1 downto 0);
grant_comb_o: out std_logic_vector(g_size-1 downto 0)
);
attribute opt_mode: string;
attribute opt_mode of gc_rr_arbiter: entity is "speed";
attribute resource_sharing: string;
attribute resource_sharing of gc_rr_arbiter: entity is "no";
end gc_rr_arbiter;
architecture rtl of gc_rr_arbiter is
component gc_prio_encoder
generic (
g_width : integer);
port (
d_i : in std_logic_vector(g_width-1 downto 0);
therm_o : out std_logic_vector(g_width-1 downto 0));
end component;
signal req_m, th_m, th_u, mux_out, mask : std_logic_vector(g_size-1 downto 0);
begin -- rtl
req_m<=req_i and mask;
U_PE1 : gc_prio_encoder
generic map (
g_width => g_size)
port map (
d_i => req_m,
therm_o => th_m);
U_PE2 : gc_prio_encoder
generic map (
g_width => g_size)
port map (
d_i => req_i,
therm_o => th_u);
process(th_u, th_m)
begin
if(th_m(th_m'length - 1) = '0') then
mux_out <= th_u;
else
mux_out <= th_m;
end if;
end process;
process(clk_i)
begin
if rising_edge(clk_i) then
if rst_n_i = '0' then
mask <= (others => '0');
grant_o <= (others => '0');
else
mask <= mux_out(g_size-2 downto 0) & '0';
grant_o <= not (mux_out(g_size-2 downto 0) & '0') and mux_out;
end if;
end if;
end process;
grant_comb_o <= not (mux_out(g_size-2 downto 0) & '0') and mux_out;
end rtl;