-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrans_arb.vhd
73 lines (61 loc) · 1.54 KB
/
trans_arb.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
-- trans_arb
--
-- Arbitrates access to transactor by multiple packet buffers
--
-- Dave Newbold, February 2013
--
-- $Id$
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.ipbus_trans_decl.all;
entity trans_arb is
generic(NSRC: positive);
port(
clk: in std_logic;
rst: in std_logic;
buf_in: in ipbus_trans_in_array(NSRC-1 downto 0);
buf_out: out ipbus_trans_out_array(NSRC-1 downto 0);
trans_out: out ipbus_trans_in;
trans_in: in ipbus_trans_out
);
end trans_arb;
architecture rtl of trans_arb is
signal src: unsigned(1 downto 0); -- Up to four ports...
signal sel: integer := 0;
signal busy: std_logic;
begin
sel <= to_integer(src);
process(clk)
begin
if rising_edge(clk) then
if rst = '1' then
busy <= '0';
src <= (others => '0');
elsif busy = '0' then
if buf_in(sel).pkt_rdy /= '1' then
if src /= (NSRC - 1) then
src <= src + 1;
else
src <= (others => '0');
end if;
else
busy <= '1';
end if;
elsif trans_in.pkt_done = '1' then
busy <= '0';
end if;
end if;
end process;
trans_out.pkt_rdy <= buf_in(sel).pkt_rdy;
trans_out.rdata <= buf_in(sel).rdata;
trans_out.busy <= buf_in(sel).busy;
busgen: for i in NSRC - 1 downto 0 generate
begin
buf_out(i).pkt_done <= trans_in.pkt_done when sel = i else '0';
buf_out(i).wdata <= trans_in.wdata;
buf_out(i).waddr <= trans_in.waddr;
buf_out(i).raddr <= trans_in.raddr;
buf_out(i).we <= trans_in.we when sel = i else '0';
end generate;
end rtl;