SURF  1.0
SlvArraytoAxiLite.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : SlvArraytoAxiLite.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2016-07-21
5 -- Last update: 2016-07-21
6 -------------------------------------------------------------------------------
7 -- Description: SLV array to AXI-Lite Master Bridge
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.AxiLitePkg.all;
25 use work.AxiLiteMasterPkg.all;
26 
27 --! @see entity
28  --! @ingroup axi
30  generic (
31  TPD_G : time := 1 ns;
32  COMMON_CLK_G : boolean := false; -- Set true if axilClk = clk
33  SIZE_G : positive := 1;
34  ADDR_G : Slv32Array := (0 => x"00000000"));
35  port (
36  -- SLV Array Interface
37  clk : in sl;
38  rst : in sl;
39  input : in Slv32Array(SIZE_G-1 downto 0);
40  -- AXI-Lite Master Interface
41  axilClk : in sl;
42  axilRst : in sl;
47 end entity SlvArraytoAxiLite;
48 
49 architecture rtl of SlvArraytoAxiLite is
50 
51  type StateType is (
52  IDLE_S,
53  WAIT_S);
54 
55  type RegType is record
56  cnt : natural range 0 to SIZE_G-1;
57  valid : slv(SIZE_G-1 downto 0);
58  inSlv : Slv32Array(SIZE_G-1 downto 0);
60  state : StateType;
61  end record;
62 
63  constant REG_INIT_C : RegType := (
64  cnt => 0,
65  valid => (others => '0'),
66  inSlv => (others => (others => '0')),
68  state => IDLE_S);
69 
70  signal r : RegType := REG_INIT_C;
71  signal rin : RegType;
72 
73  signal inSlv : Slv32Array(SIZE_G-1 downto 0);
74  signal ack : AxiLiteMasterAckType;
75 
76  -- attribute dont_touch : string;
77  -- attribute dont_touch of r : signal is "true";
78 
79 begin
80 
81  GEN_VEC :
82  for i in (SIZE_G-1) downto 0 generate
83  SyncFifo : entity work.SynchronizerFifo
84  generic map (
85  TPD_G => TPD_G,
87  DATA_WIDTH_G => 32)
88  port map (
89  -- Write Ports (wr_clk domain)
90  wr_clk => clk,
91  din => input(i),
92  -- Read Ports (rd_clk domain)
93  rd_clk => axilClk,
94  dout => inSlv(i));
95  end generate GEN_VEC;
96 
97  AxiLiteMaster : entity work.AxiLiteMaster
98  generic map (
99  TPD_G => TPD_G)
100  port map (
101  req => r.req,
102  ack => ack,
103  axilClk => axilClk,
104  axilRst => axilRst,
109 
110  comb : process (ack, axilRst, inSlv, r) is
111  variable v : RegType;
112  variable i : natural;
113  begin
114  -- Latch the current value
115  v := r;
116 
117  -- Loop through the SLV array
118  for i in (SIZE_G-1) downto 0 loop
119  -- Check for changes in the bus
120  if inSlv(i) /= r.inSlv(i) then
121  -- Set the flag
122  v.valid(i) := '1';
123  end if;
124  end loop;
125 
126  -- Update the registered value
127  v.inSlv := inSlv;
128 
129  -- State Machine
130  case (r.state) is
131  ----------------------------------------------------------------------
132  when IDLE_S =>
133  -- Increment the counter
134  if r.cnt = (SIZE_G-1) then
135  v.cnt := 0;
136  else
137  v.cnt := r.cnt + 1;
138  end if;
139  -- Check the valid flag and transaction completed
140  if (r.valid(r.cnt) = '1') and (ack.done = '0') then
141  -- Reset the flag
142  v.valid(r.cnt) := '0';
143  -- Setup the AXI-Lite Master request
144  v.req.request := '1';
145  v.req.rnw := '0'; -- Write operation
146  v.req.address := ADDR_G(r.cnt);
147  v.req.wrData := r.inSlv(r.cnt);
148  -- Next state
149  v.state := WAIT_S;
150  end if;
151  ----------------------------------------------------------------------
152  when WAIT_S =>
153  -- Wait for DONE to set
154  if ack.done = '1' then
155  -- Reset the flag
156  v.req.request := '0';
157  -- Next state
158  v.state := IDLE_S;
159  end if;
160  ----------------------------------------------------------------------
161  end case;
162 
163  -- Synchronous Reset
164  if (axilRst = '1') then
165  v := REG_INIT_C;
166  end if;
167 
168  -- Register the variable for next clock cycle
169  rin <= v;
170 
171  end process comb;
172 
173  seq : process (axilClk) is
174  begin
175  if (rising_edge(axilClk)) then
176  r <= rin after TPD_G;
177  end if;
178  end process seq;
179 
180 end architecture rtl;
out axilReadMasterAxiLiteReadMasterType
in axilReadSlaveAxiLiteReadSlaveType
AxiLiteMasterReqType :=(request => '0',rnw => '1',address =>( others => '0'),wrData =>( others => '0')) AXI_LITE_MASTER_REQ_INIT_C
array(natural range <> ) of slv( 31 downto 0) Slv32Array
Definition: StdRtlPkg.vhd:379
out axilWriteMasterAxiLiteWriteMasterType
out axilReadMasterAxiLiteReadMasterType
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
in dinslv( DATA_WIDTH_G- 1 downto 0)
in axilWriteSlaveAxiLiteWriteSlaveType
in reqAxiLiteMasterReqType
out ackAxiLiteMasterAckType
COMMON_CLK_Gboolean := false
out doutslv( DATA_WIDTH_G- 1 downto 0)
COMMON_CLK_Gboolean := false
_library_ ieeeieee
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
in inputSlv32Array( SIZE_G- 1 downto 0)
out axilWriteMasterAxiLiteWriteMasterType
in axilReadSlaveAxiLiteReadSlaveType
in axilWriteSlaveAxiLiteWriteSlaveType
slv( 31 downto 0) wrData
ADDR_GSlv32Array :=( 0=> x"00000000")
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
slv( 31 downto 0) address
TPD_Gtime := 1 ns
DATA_WIDTH_Ginteger range 1 to ( 2** 24):= 16
std_logic_vector slv
Definition: StdRtlPkg.vhd:29