SURF  1.0
AxiReadPathMux.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : AxiReadPathMux.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2014-04-25
5 -- Last update: 2014-04-29
6 -------------------------------------------------------------------------------
7 -- Description: Block to connect multiple incoming AXI write path interfaces.
8 -------------------------------------------------------------------------------
9 -- This file is part of 'SLAC Firmware Standard Library'.
10 -- It is subject to the license terms in the LICENSE.txt file found in the
11 -- top-level directory of this distribution and at:
12 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
13 -- No part of 'SLAC Firmware Standard Library', including this file,
14 -- may be copied, modified, propagated, or distributed except according to
15 -- the terms contained in the LICENSE.txt file.
16 -------------------------------------------------------------------------------
17 
18 library ieee;
19 use ieee.std_logic_1164.all;
20 use ieee.std_logic_arith.all;
21 use ieee.std_logic_unsigned.all;
22 
23 use work.StdRtlPkg.all;
24 use work.ArbiterPkg.all;
25 use work.AxiPkg.all;
26 
27 --! @see entity
28  --! @ingroup axi
29 entity AxiReadPathMux is
30  generic (
31  TPD_G : time := 1 ns;
32  NUM_SLAVES_G : integer range 1 to 32 := 4
33  );
34  port (
35 
36  -- Clock and reset
37  axiClk : in sl;
38  axiRst : in sl;
39 
40  -- Slaves
43 
44  -- Master
47  );
48 end AxiReadPathMux;
49 
50 architecture structure of AxiReadPathMux is
51 
52  constant DEST_SIZE_C : integer := bitSize(NUM_SLAVES_G-1);
53  constant ARB_BITS_C : integer := 2**DEST_SIZE_C;
54 
55  --------------------------
56  -- Address Path
57  --------------------------
58 
59  type StateType is (S_IDLE_C, S_MOVE_C, S_LAST_C);
60 
61  type RegType is record
63  addrAcks : slv(ARB_BITS_C-1 downto 0);
64  addrAckNum : slv(DEST_SIZE_C-1 downto 0);
68  end record RegType;
69 
70  constant REG_INIT_C : RegType := (
71  addrState => S_IDLE_C,
72  addrAcks => (others => '0'),
73  addrAckNum => (others => '0'),
74  addrValid => '0',
75  slaves => (others => AXI_READ_SLAVE_INIT_C),
77  );
78 
79  signal r : RegType := REG_INIT_C;
80  signal rin : RegType;
81 
82 begin
83 
84  comb : process (axiRst, r, sAxiReadMasters, mAxiReadSlave) is
85  variable v : RegType;
86  variable addrRequests : slv(ARB_BITS_C-1 downto 0);
87  variable selAddr : AxiReadMasterType;
88  begin
89  v := r;
90 
91  ----------------------------
92  -- Address Path
93  ----------------------------
94 
95  -- Init Slave Ready
96  for i in 0 to (NUM_SLAVES_G-1) loop
97  v.slaves(i).arready := '0';
98  end loop;
99 
100  -- Select address source
101  selAddr := sAxiReadMasters(conv_integer(r.addrAckNum));
102  selAddr.arid := (others => '0');
103 
104  selAddr.arid(DEST_SIZE_C-1 downto 0) := r.addrAckNum;
105 
106  -- Format requests
107  addrRequests := (others=>'0');
108  for i in 0 to (NUM_SLAVES_G-1) loop
109  addrRequests(i) := sAxiReadMasters(i).arvalid;
110  end loop;
111 
112  -- Addr State machine
113  case r.addrState is
114 
115  -- IDLE
116  when S_IDLE_C =>
117  v.master.arvalid := '0';
118 
119  -- Aribrate between requesters
120  if r.addrValid = '0' then
121  arbitrate(addrRequests, r.addrAckNum, v.addrAckNum, v.addrValid, v.addrAcks);
122  end if;
123 
124  -- Valid request
125  if r.addrValid = '1' then
126  v.addrState := S_MOVE_C;
127  end if;
128 
129  -- Move one entry
130  when S_MOVE_C =>
131  v.addrValid := '0';
132 
133  -- Assert ready
134  v.slaves(conv_integer(r.addrAckNum)).arready := '1';
135 
136  -- Advance pipeline
137  v.master.arvalid := '1';
138  v.master.araddr := selAddr.araddr;
139  v.master.arid := selAddr.arid;
140  v.master.arlen := selAddr.arlen;
141  v.master.arsize := selAddr.arsize;
142  v.master.arburst := selAddr.arburst;
143  v.master.arlock := selAddr.arlock;
144  v.master.arprot := selAddr.arprot;
145  v.master.arcache := selAddr.arcache;
146  v.addrState := S_LAST_C;
147 
148  -- Laster transfer
149  when S_LAST_C =>
150  if mAxiReadSlave.arready = '1' then
151  v.master.arvalid := '0';
152  v.addrState := S_IDLE_C;
153  end if;
154  end case;
155 
156  ----------------------------
157  -- Data Path
158  ----------------------------
159 
160  -- Clear existing valids
161  for i in 0 to (NUM_SLAVES_G-1) loop
162  if sAxiReadMasters(i).rready = '1' then
163  v.slaves(i).rvalid := '0';
164  end if;
165  end loop;
166 
167  -- Pass response to destination
168  if r.slaves(conv_integer(mAxiReadSlave.rid(DEST_SIZE_C-1 downto 0))).rvalid = '0' or
169  sAxiReadMasters(conv_integer(mAxiReadSlave.rid(DEST_SIZE_C-1 downto 0))).rready = '1' then
170 
171  v.slaves(conv_integer(mAxiReadSlave.rid(DEST_SIZE_C-1 downto 0))).rvalid := mAxiReadSlave.rvalid;
172  v.slaves(conv_integer(mAxiReadSlave.rid(DEST_SIZE_C-1 downto 0))).rdata := mAxiReadSlave.rdata;
173  v.slaves(conv_integer(mAxiReadSlave.rid(DEST_SIZE_C-1 downto 0))).rlast := mAxiReadSlave.rlast;
174  v.slaves(conv_integer(mAxiReadSlave.rid(DEST_SIZE_C-1 downto 0))).rresp := mAxiReadSlave.rresp;
175  v.slaves(conv_integer(mAxiReadSlave.rid(DEST_SIZE_C-1 downto 0))).rid := mAxiReadSlave.rid;
176  v.master.rready := '1';
177  else
178  v.master.rready := '0';
179  end if;
180 
181  if (axiRst = '1' ) or (NUM_SLAVES_G = 1) then
182  v := REG_INIT_C;
183  end if;
184 
185  rin <= v;
186 
187  -- Bypass if single slave
188  if NUM_SLAVES_G = 1 then
190  mAxiReadMaster <= sAxiReadmasters(0);
191  else
192 
193  -- Output data
196 
197  -- Readies are direct
198  for i in 0 to (NUM_SLAVES_G-1) loop
200  end loop;
202  end if;
203  end process comb;
204 
205  seq : process (axiClk) is
206  begin
207  if (rising_edge(axiClk)) then
208  r <= rin after TPD_G;
209  end if;
210  end process seq;
211 
212 end structure;
(S_IDLE_C,S_MOVE_C,S_LAST_C) StateType
slv( 7 downto 0) arlen
Definition: AxiPkg.vhd:37
AxiReadMasterType :=(arvalid => '0',araddr =>( others => '0'),arid =>( others => '0'),arlen =>( others => '0'),arsize =>( others => '0'),arburst =>( others => '0'),arlock =>( others => '0'),arprot =>( others => '0'),arcache =>( others => '0'),arqos =>( others => '0'),arregion =>( others => '0'),rready => '0') AXI_READ_MASTER_INIT_C
Definition: AxiPkg.vhd:49
slv( 1023 downto 0) rdata
Definition: AxiPkg.vhd:83
sl rready
Definition: AxiPkg.vhd:46
RegType := REG_INIT_C r
slv( 31 downto 0) rid
Definition: AxiPkg.vhd:86
array(natural range <> ) of AxiReadSlaveType AxiReadSlaveArray
Definition: AxiPkg.vhd:89
slv( 1 downto 0) rresp
Definition: AxiPkg.vhd:87
sl rvalid
Definition: AxiPkg.vhd:85
std_logic sl
Definition: StdRtlPkg.vhd:28
AxiReadSlaveArray( NUM_SLAVES_G- 1 downto 0) slaves
slv( 3 downto 0) arcache
Definition: AxiPkg.vhd:42
sl arready
Definition: AxiPkg.vhd:81
in mAxiReadSlaveAxiReadSlaveType
AxiReadSlaveType
Definition: AxiPkg.vhd:79
AxiReadMasterType master
NUM_SLAVES_Ginteger range 1 to 32:= 4
slv( ARB_BITS_C- 1 downto 0) addrAcks
slv( DEST_SIZE_C- 1 downto 0) addrAckNum
slv( 31 downto 0) arid
Definition: AxiPkg.vhd:36
slv( 63 downto 0) araddr
Definition: AxiPkg.vhd:35
out mAxiReadMasterAxiReadMasterType
slv( 2 downto 0) arsize
Definition: AxiPkg.vhd:38
slv( 1 downto 0) arburst
Definition: AxiPkg.vhd:39
array(natural range <> ) of AxiReadMasterType AxiReadMasterArray
Definition: AxiPkg.vhd:48
_library_ ieeeieee
RegType :=(addrState => S_IDLE_C,addrAcks =>( others => '0'),addrAckNum =>( others => '0'),addrValid => '0',slaves =>( others => AXI_READ_SLAVE_INIT_C),master => AXI_READ_MASTER_INIT_C) REG_INIT_C
integer := bitSize( NUM_SLAVES_G- 1) DEST_SIZE_C
sl rlast
Definition: AxiPkg.vhd:84
slv( 1 downto 0) arlock
Definition: AxiPkg.vhd:40
out sAxiReadSlavesAxiReadSlaveArray( NUM_SLAVES_G- 1 downto 0)
in sAxiReadMastersAxiReadMasterArray( NUM_SLAVES_G- 1 downto 0)
TPD_Gtime := 1 ns
AxiReadMasterType
Definition: AxiPkg.vhd:32
slv( 2 downto 0) arprot
Definition: AxiPkg.vhd:41
integer := 2** DEST_SIZE_C ARB_BITS_C
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
sl arvalid
Definition: AxiPkg.vhd:34
AxiReadSlaveType :=(arready => '0',rdata =>( others => '0'),rlast => '0',rvalid => '0',rid =>( others => '0'),rresp =>( others => '0')) AXI_READ_SLAVE_INIT_C
Definition: AxiPkg.vhd:90