SURF  1.0
AxiLiteMaster.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : AxiLiteMaster.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2014-04-09
5 -- Last update: 2016-03-09
6 -------------------------------------------------------------------------------
7 -- Description: AXI-Lite Master module controlled via REQ/ACK interface
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
29 entity AxiLiteMaster is
30  generic (
31  -- General Config
32  TPD_G : time := 1 ns);
33  port (
34  axilClk : in sl;
35  axilRst : in sl;
42  );
43 
44 end AxiLiteMaster;
45 
46 architecture rtl of AxiLiteMaster is
47 
48  type StateType is (S_IDLE_C, S_WRITE_C, S_WRITE_AXI_C, S_READ_C, S_READ_AXI_C);
49 
50  type RegType is record
52  state : StateType;
55  end record RegType;
56 
57  constant REG_INIT_C : RegType := (
59  state => S_IDLE_C,
62 
63  signal r : RegType := REG_INIT_C;
64  signal rin : RegType;
65 
66 
67 begin
68 
69  -------------------------------------
70  -- Master State Machine
71  -------------------------------------
72 
73  comb : process (axilRst, axilReadSlave, axilWriteSlave, r, req) is
74  variable v : RegType;
75  begin
76  v := r;
77 
78  -- State machine
79  case r.state is
80 
81  -- Idle
82  when S_IDLE_C =>
85 
86  if (req.request = '0') then
88  end if;
89 
90  -- Frame is starting
91  if (req.request = '1' and r.ack.done = '0') then
92  if (req.rnw = '1') then
93  v.state := S_READ_C;
94  else
95  v.state := S_WRITE_C;
96  end if;
97  end if;
98 
99  -- Prepare Write Transaction
100  when S_WRITE_C =>
102  v.axilWriteMaster.awprot := (others => '0');
103  v.axilWriteMaster.wstrb := (others => '1');
105  v.axilWriteMaster.awvalid := '1';
106  v.axilWriteMaster.wvalid := '1';
107  v.axilWriteMaster.bready := '1';
108 
109  v.state := S_WRITE_AXI_C;
110 
111  -- Write Transaction, AXI
112  when S_WRITE_AXI_C =>
113  -- Clear control signals on ack
114  if axilWriteSlave.awready = '1' then
115  v.axilWriteMaster.awvalid := '0';
116  end if;
117  if axilWriteSlave.wready = '1' then
118  v.axilWriteMaster.wvalid := '0';
119  end if;
120  if axilWriteSlave.bvalid = '1' then
121  v.axilWriteMaster.bready := '0';
122  v.ack.done := '1';
124  v.state := S_IDLE_C;
125  end if;
126 
127  -- Read transaction
128  when S_READ_C =>
130  v.axilReadMaster.arprot := (others => '0');
131 
132  -- Start AXI transaction
133  v.axilReadMaster.arvalid := '1';
134  v.axilReadMaster.rready := '1';
135  v.state := S_READ_AXI_C;
136 
137  -- Read AXI
138  when S_READ_AXI_C =>
139  -- Clear control signals on ack
140  if axilReadSlave.arready = '1' then
141  v.axilReadMaster.arvalid := '0';
142  end if;
143  if axilReadSlave.rvalid = '1' then
144  v.axilReadMaster.rready := '0';
147  end if;
148 
149  -- Transaction is done
150  if v.axilReadMaster.arvalid = '0' and v.axilReadMaster.rready = '0' then
151  v.ack.done := '1';
152  v.state := S_IDLE_C;
153  end if;
154 
155  end case;
156 
157  if (axilRst = '1') then
158  v := REG_INIT_C;
159  end if;
160 
161  rin <= v;
162 
163  ack <= r.ack;
166 
167 
168  end process comb;
169 
170  seq : process (axilClk) is
171  begin
172  if (rising_edge(axilClk)) then
173  r <= rin after TPD_G;
174  end if;
175  end process seq;
176 
177 
178 end rtl;
179 
slv( 2 downto 0) arprot
Definition: AxiLitePkg.vhd:62
slv( 1 downto 0) rresp
Definition: AxiLitePkg.vhd:90
out axilWriteMasterAxiLiteWriteMasterType
out axilReadMasterAxiLiteReadMasterType
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
in axilWriteSlaveAxiLiteWriteSlaveType
in reqAxiLiteMasterReqType
out ackAxiLiteMasterAckType
slv( 1 downto 0) resp
slv( 31 downto 0) rdata
Definition: AxiLitePkg.vhd:89
slv( 31 downto 0) rdData
slv( 31 downto 0) wdata
Definition: AxiLitePkg.vhd:117
slv( 2 downto 0) awprot
Definition: AxiLitePkg.vhd:114
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
slv( 31 downto 0) awaddr
Definition: AxiLitePkg.vhd:113
AxiLiteMasterAckType :=(done => '0',resp =>( others => '0'),rdData =>( others => '0')) AXI_LITE_MASTER_ACK_INIT_C
slv( 1 downto 0) bresp
Definition: AxiLitePkg.vhd:150
AxiLiteReadMasterType :=(araddr =>( others => '0'),arprot =>( others => '0'),arvalid => '0',rready => '1') AXI_LITE_READ_MASTER_INIT_C
Definition: AxiLitePkg.vhd:69
in axilReadSlaveAxiLiteReadSlaveType
slv( 31 downto 0) wrData
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
slv( 31 downto 0) address
AxiLiteWriteMasterType :=(awaddr =>( others => '0'),awprot =>( others => '0'),awvalid => '0',wdata =>( others => '0'),wstrb =>( others => '1'),wvalid => '0',bready => '1') AXI_LITE_WRITE_MASTER_INIT_C
Definition: AxiLitePkg.vhd:125
slv( 31 downto 0) araddr
Definition: AxiLitePkg.vhd:61
slv( 3 downto 0) wstrb
Definition: AxiLitePkg.vhd:118
TPD_Gtime := 1 ns