SURF  1.0
SrpV3Axi.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : SrpV3Axi.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2016-04-14
5 -- Last update: 2016-05-04
6 -------------------------------------------------------------------------------
7 -- Description: SLAC Register Protocol Version 3, AXI Interface
8 --
9 -- Documentation: https://confluence.slac.stanford.edu/x/cRmVD
10 --
11 -------------------------------------------------------------------------------
12 -- This file is part of 'SLAC Firmware Standard Library'.
13 -- It is subject to the license terms in the LICENSE.txt file found in the
14 -- top-level directory of this distribution and at:
15 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
16 -- No part of 'SLAC Firmware Standard Library', including this file,
17 -- may be copied, modified, propagated, or distributed except according to
18 -- the terms contained in the LICENSE.txt file.
19 -------------------------------------------------------------------------------
20 
21 library ieee;
22 use ieee.std_logic_1164.all;
23 use ieee.std_logic_arith.all;
24 use ieee.std_logic_unsigned.all;
25 
26 use work.StdRtlPkg.all;
27 use work.AxiStreamPkg.all;
28 use work.SsiPkg.all;
29 use work.AxiPkg.all;
30 use work.AxiDmaPkg.all;
31 use work.SrpV3Pkg.all;
32 
33 --! @see entity
34  --! @ingroup protocols_srp
35 entity SrpV3Axi is
36  generic (
37  TPD_G : time := 1 ns;
38  PIPE_STAGES_G : natural range 0 to 16 := 0;
39  FIFO_PAUSE_THRESH_G : positive range 1 to 511 := 256;
40  TX_VALID_THOLD_G : positive := 1;
41  SLAVE_READY_EN_G : boolean := true;
42  GEN_SYNC_FIFO_G : boolean := false;
43  ALTERA_SYN_G : boolean := false;
44  ALTERA_RAM_G : string := "M9K";
45  AXI_CLK_FREQ_G : real := 156.25E+6; -- units of Hz
46  AXI_CONFIG_G : AxiConfigType := (33, 4, 1, 8);
47  AXI_BURST_G : slv(1 downto 0) := "01";
48  AXI_CACHE_G : slv(3 downto 0) := "1111";
49  ACK_WAIT_BVALID_G : boolean := true;
50  AXI_STREAM_CONFIG_G : AxiStreamConfigType := ssiAxiStreamConfig(2);
51  UNALIGNED_ACCESS_G : boolean := false;
52  BYTE_ACCESS_G : boolean := false;
53  WRITE_EN_G : boolean := true; -- Write ops enabled
54  READ_EN_G : boolean := true); -- Read ops enabled
55  port (
56  -- AXIS Slave Interface (sAxisClk domain)
57  sAxisClk : in sl;
58  sAxisRst : in sl;
62  -- AXIS Master Interface (mAxisClk domain)
63  mAxisClk : in sl;
64  mAxisRst : in sl;
67  -- Master AXI Interface (mAxiClk domain)
68  axiClk : in sl;
69  axiRst : in sl;
74 end SrpV3Axi;
75 
76 architecture rtl of SrpV3Axi is
77 
78  constant DMA_AXIS_CONFIG_C : AxiStreamConfigType := (
79  TSTRB_EN_C => false,
80  TDATA_BYTES_C => 4,
81  TDEST_BITS_C => 0,
82  TID_BITS_C => 0,
83  TKEEP_MODE_C => TKEEP_NORMAL_C,
84  TUSER_BITS_C => 0,
85  TUSER_MODE_C => TUSER_NONE_C);
86 
87  type RegType is record
88  srpAck : SrpV3AckType;
89  wrDmaReq : AxiWriteDmaReqType;
90  rdDmaReq : AxiReadDmaReqType;
91  end record RegType;
92 
93  constant REG_INIT_C : RegType := (
94  srpAck => SRPV3_ACK_INIT_C,
95  wrDmaReq => AXI_WRITE_DMA_REQ_INIT_C,
96  rdDmaReq => AXI_READ_DMA_REQ_INIT_C);
97 
98  signal r : RegType := REG_INIT_C;
99  signal rin : RegType;
100 
101  signal srpReq : SrpV3ReqType;
102  signal wrDmaAck : AxiWriteDmaAckType;
103  signal rdDmaAck : AxiReadDmaAckType;
104  signal srpWrMaster : AxiStreamMasterType;
105  signal srpWrSlave : AxiStreamSlaveType;
106  signal srpRdMaster : AxiStreamMasterType;
107  signal srpRdSlave : AxiStreamSlaveType;
108 
109  -- attribute dont_touch : string;
110  -- attribute dont_touch of r : signal is "TRUE";
111 
112 begin
113 
114  U_SrpV3Core_1 : entity work.SrpV3Core
115  generic map (
116  TPD_G => TPD_G,
129  READ_EN_G => READ_EN_G)
130  port map (
131  sAxisClk => sAxisClk, -- [in]
132  sAxisRst => sAxisRst, -- [in]
133  sAxisMaster => sAxisMaster, -- [in]
134  sAxisSlave => sAxisSlave, -- [out]
135  sAxisCtrl => sAxisCtrl, -- [out]
136  mAxisClk => mAxisClk, -- [in]
137  mAxisRst => mAxisRst, -- [in]
138  mAxisMaster => mAxisMaster, -- [out]
139  mAxisSlave => mAxisSlave, -- [in]
140  srpClk => axiClk, -- [in]
141  srpRst => axiRst, -- [in]
142  srpReq => srpReq, -- [out]
143  srpAck => r.srpAck, -- [in]
144  srpWrMaster => srpWrMaster, -- [out]
145  srpWrSlave => srpWrSlave, -- [in]
146  srpRdMaster => srpRdMaster, -- [in]
147  srpRdSlave => srpRdSlave); -- [out]
148 
149  U_AxiStreamDmaWrite_1 : entity work.AxiStreamDmaWrite
150  generic map (
151  TPD_G => TPD_G,
152  AXI_READY_EN_G => true,
153  AXIS_CONFIG_G => DMA_AXIS_CONFIG_C,
158  port map (
159  axiClk => axiClk, -- [in]
160  axiRst => axiRst, -- [in]
161  dmaReq => r.wrDmaReq, -- [in]
162  dmaAck => wrDmaAck, -- [out]
163  axisMaster => srpWrMaster, -- [in]
164  axisSlave => srpWrSlave, -- [out]
165  axiWriteMaster => axiWriteMaster, -- [out]
166  axiWriteSlave => axiWriteSlave, -- [in]
167  axiWriteCtrl => AXI_CTRL_UNUSED_C); -- [in]
168 
169  U_AxiStreamDmaRead_1 : entity work.AxiStreamDmaRead
170  generic map (
171  TPD_G => TPD_G,
172  AXIS_READY_EN_G => true,
173  AXIS_CONFIG_G => DMA_AXIS_CONFIG_C,
177  port map (
178  axiClk => axiClk, -- [in]
179  axiRst => axiRst, -- [in]
180  dmaReq => r.rdDmaReq, -- [in]
181  dmaAck => rdDmaAck, -- [out]
182  axisMaster => srpRdMaster, -- [out]
183  axisSlave => srpRdSlave, -- [in]
185  axiReadMaster => axiReadMaster, -- [out]
186  axiReadSlave => axiReadSlave); -- [in]
187 
188 
189  comb : process (r, axiRst, rdDmaAck, srpReq, wrDmaAck) is
190  variable v : RegType;
191  variable addrError : sl;
192  begin
193  -- Latch the current value
194  v := r;
195 
196  -- Check that requested address is within range of attached AXI bus
197  addrError := '0';
198  if (srpReq.request = '1' and srpReq.addr(63 downto AXI_CONFIG_G.ADDR_WIDTH_C) /= 0) then
199  addrError := '1';
200  end if;
201 
202  v.wrDmaReq.request := srpReq.request and toSl(srpReq.opcode = SRP_WRITE_C or srpReq.opcode = SRP_POSTED_WRITE_C) and not addrError;
203  v.wrDmaReq.address := srpReq.addr;
204  -- This helps the DMA engines trim their unaligned access logic
205  if (UNALIGNED_ACCESS_G = false and BYTE_ACCESS_G = false) then
206  v.wrDmaReq.address(1 downto 0) := (others => '0');
207  end if;
208  v.wrDmaReq.maxSize := srpReq.reqSize + 1;
209 
210  v.rdDmaReq.request := srpReq.request and toSl(srpReq.opcode = SRP_READ_C) and not addrError;
211  v.rdDmaReq.address := srpReq.addr;
212  if (UNALIGNED_ACCESS_G = false and BYTE_ACCESS_G = false) then
213  v.rdDmaReq.address(1 downto 0) := (others => '0');
214  end if;
215  v.rdDmaReq.size := srpReq.reqSize + 1;
216 
217 
218  v.srpAck.done := '0';
219  if (srpReq.request = '1') then
220  if (srpReq.opcode = SRP_WRITE_C or srpReq.opcode = SRP_POSTED_WRITE_C) then
221  v.srpAck.done := wrDmaAck.done or addrError;
222  v.srpAck.respCode(1 downto 0) := wrDmaAck.errorValue;
223  v.srpAck.respCode(2) := wrDmaAck.writeError;
224  v.srpAck.respCode(3) := wrDmaAck.overflow;
225  elsif (srpReq.opcode = SRP_READ_C) then
226  v.srpAck.done := rdDmaAck.done or addrError;
227  v.srpAck.respCode(1 downto 0) := rdDmaAck.errorValue;
228  v.srpAck.respCode(2) := rdDmaAck.readError;
229  end if;
230  v.srpAck.respCode(7) := addrError;
231  end if;
232 
233  -- Reset
234  if (axiRst = '1') then
235  v := REG_INIT_C;
236  end if;
237 
238  -- Register the variable for next clock cycle
239  rin <= v;
240 
241  -- Outputs
242  end process comb;
243 
244  seq : process (axiClk) is
245  begin
246  if (rising_edge(axiClk)) then
247  r <= rin after TPD_G;
248  end if;
249  end process seq;
250 
251 end rtl;
in mAxisSlaveAxiStreamSlaveType
Definition: SrpV3Axi.vhd:66
SrpV3ReqType
Definition: SrpV3Pkg.vhd:46
in dmaReqAxiWriteDmaReqType
TX_VALID_THOLD_Gpositive := 1
Definition: SrpV3Core.vhd:42
READ_EN_Gboolean := true
Definition: SrpV3Axi.vhd:54
out dmaAckAxiWriteDmaAckType
natural range 0 to 8 TDEST_BITS_C
slv( 63 downto 0) address
Definition: AxiDmaPkg.vhd:49
out axiReadMasterAxiReadMasterType
Definition: SrpV3Axi.vhd:72
BYTE_ACCESS_Gboolean := false
Definition: SrpV3Axi.vhd:52
ALTERA_SYN_Gboolean := false
Definition: SrpV3Axi.vhd:43
AXIS_CONFIG_GAxiStreamConfigType := AXI_STREAM_CONFIG_INIT_C
out axiWriteMasterAxiWriteMasterType
in sAxisRstsl
Definition: SrpV3Core.vhd:57
sl readError
Definition: AxiDmaPkg.vhd:136
ALTERA_RAM_Gstring := "M9K"
Definition: SrpV3Core.vhd:46
in srpClksl
Definition: SrpV3Core.vhd:67
in mAxisRstsl
Definition: SrpV3Axi.vhd:64
AXI_CACHE_Gslv( 3 downto 0) := "1111"
out sAxisSlaveAxiStreamSlaveType
Definition: SrpV3Axi.vhd:60
slv( 31 downto 0) reqSize
Definition: SrpV3Pkg.vhd:53
std_logic sl
Definition: StdRtlPkg.vhd:28
out mAxisMasterAxiStreamMasterType
Definition: SrpV3Axi.vhd:65
GEN_SYNC_FIFO_Gboolean := false
Definition: SrpV3Core.vhd:44
in axiWriteCtrlAxiCtrlType := AXI_CTRL_UNUSED_C
BYTE_ACCESS_Gboolean := false
Definition: SrpV3Core.vhd:50
in dmaReqAxiReadDmaReqType
TX_VALID_THOLD_Gpositive := 1
Definition: SrpV3Axi.vhd:40
SLAVE_READY_EN_Gboolean := false
Definition: SrpV3Core.vhd:43
ACK_WAIT_BVALID_Gboolean := true
AXI_STREAM_CONFIG_GAxiStreamConfigType := ssiAxiStreamConfig( 2)
Definition: SrpV3Axi.vhd:50
out sAxisCtrlAxiStreamCtrlType
Definition: SrpV3Axi.vhd:61
in srpRdMasterAxiStreamMasterType
Definition: SrpV3Core.vhd:73
in mAxisRstsl
Definition: SrpV3Core.vhd:63
entity srp
Definition: SrpV3Core.vhd:37
sl writeError
Definition: AxiDmaPkg.vhd:74
slv( 1 downto 0) := "00" SRP_READ_C
Definition: SrpV3Pkg.vhd:41
AxiCtrlType :=(pause => '0',overflow => '0') AXI_CTRL_UNUSED_C
Definition: AxiPkg.vhd:206
natural range 1 to 16 TDATA_BYTES_C
FIFO_PAUSE_THRESH_Gpositive range 1 to 511:= 256
Definition: SrpV3Axi.vhd:39
ALTERA_SYN_Gboolean := false
Definition: SrpV3Core.vhd:45
PIPE_STAGES_Gnatural range 0 to 16:= 1
Definition: SrpV3Core.vhd:40
in mAxisSlaveAxiStreamSlaveType
Definition: SrpV3Core.vhd:65
out axiReadMasterAxiReadMasterType
UNALIGNED_ACCESS_Gboolean := false
Definition: SrpV3Core.vhd:49
TkeepModeType TKEEP_MODE_C
AxiWriteDmaAckType
Definition: AxiDmaPkg.vhd:69
positive range 12 to 64 ADDR_WIDTH_C
Definition: AxiPkg.vhd:214
AxiReadSlaveType
Definition: AxiPkg.vhd:79
slv( 63 downto 0) addr
Definition: SrpV3Pkg.vhd:52
AxiWriteMasterType
Definition: AxiPkg.vhd:108
SLAVE_READY_EN_Gboolean := true
Definition: SrpV3Axi.vhd:41
AXI_CONFIG_GAxiConfigType := AXI_CONFIG_INIT_C
in axiReadSlaveAxiReadSlaveType
TPD_Gtime := 1 ns
Definition: SrpV3Axi.vhd:37
natural range 0 to 8 TID_BITS_C
UNALIGNED_ACCESS_Gboolean := false
Definition: SrpV3Axi.vhd:51
out srpRdSlaveAxiStreamSlaveType
Definition: SrpV3Core.vhd:74
AXI_BURST_Gslv( 1 downto 0) := "01"
out dmaAckAxiReadDmaAckType
in sAxisClksl
Definition: SrpV3Core.vhd:56
in axisCtrlAxiStreamCtrlType
in axiReadSlaveAxiReadSlaveType
Definition: SrpV3Axi.vhd:73
in sAxisClksl
Definition: SrpV3Axi.vhd:57
AXI_CACHE_Gslv( 3 downto 0) := "1111"
slv( 7 downto 0) respCode
Definition: SrpV3Pkg.vhd:67
in mAxisClksl
Definition: SrpV3Core.vhd:62
in sAxisMasterAxiStreamMasterType
Definition: SrpV3Core.vhd:58
boolean TSTRB_EN_C
in axiClksl
Definition: SrpV3Axi.vhd:68
in srpWrSlaveAxiStreamSlaveType
Definition: SrpV3Core.vhd:72
AxiWriteDmaReqType
Definition: AxiDmaPkg.vhd:46
out sAxisCtrlAxiStreamCtrlType
Definition: SrpV3Core.vhd:60
AxiConfigType
Definition: AxiPkg.vhd:213
AxiReadDmaReqType :=(request => '0',address =>( others => '0'),size =>( others => '0'),firstUser =>( others => '0'),lastUser =>( others => '0'),dest =>( others => '0'),id =>( others => '0')) AXI_READ_DMA_REQ_INIT_C
Definition: AxiDmaPkg.vhd:115
TUserModeType TUSER_MODE_C
in srpRstsl
Definition: SrpV3Core.vhd:68
AXIS_READY_EN_Gboolean := false
in axiWriteSlaveAxiWriteSlaveType
AxiWriteSlaveType
Definition: AxiPkg.vhd:171
READ_EN_Gboolean := true
Definition: SrpV3Core.vhd:53
natural range 0 to 8 TUSER_BITS_C
AXI_BURST_Gslv( 1 downto 0) := "01"
in axisMasterAxiStreamMasterType
in axisSlaveAxiStreamSlaveType
AxiStreamCtrlType :=(pause => '0',overflow => '0',idle => '1') AXI_STREAM_CTRL_UNUSED_C
AXI_STREAM_CONFIG_GAxiStreamConfigType := ssiAxiStreamConfig( 2)
Definition: SrpV3Core.vhd:48
in mAxisClksl
Definition: SrpV3Axi.vhd:63
FIFO_PAUSE_THRESH_Gpositive range 1 to 511:= 256
Definition: SrpV3Core.vhd:41
ACK_WAIT_BVALID_Gboolean := true
Definition: SrpV3Axi.vhd:49
slv( 31 downto 0) size
Definition: AxiDmaPkg.vhd:72
_library_ ieeeieee
slv( 1 downto 0) errorValue
Definition: AxiDmaPkg.vhd:75
slv( 31 downto 0) maxSize
Definition: AxiDmaPkg.vhd:50
ALTERA_RAM_Gstring := "M9K"
Definition: SrpV3Axi.vhd:44
WRITE_EN_Gboolean := true
Definition: SrpV3Axi.vhd:53
AXI_BURST_Gslv( 1 downto 0) := "01"
Definition: SrpV3Axi.vhd:47
out srpWrMasterAxiStreamMasterType
Definition: SrpV3Core.vhd:71
GEN_SYNC_FIFO_Gboolean := false
Definition: SrpV3Axi.vhd:42
AXI_CACHE_Gslv( 3 downto 0) := "1111"
Definition: SrpV3Axi.vhd:48
slv( 1 downto 0) := "01" SRP_WRITE_C
Definition: SrpV3Pkg.vhd:42
in sAxisMasterAxiStreamMasterType
Definition: SrpV3Axi.vhd:59
out sAxisSlaveAxiStreamSlaveType
Definition: SrpV3Core.vhd:59
in sAxisRstsl
Definition: SrpV3Axi.vhd:58
in axiRstsl
Definition: SrpV3Axi.vhd:69
AXIS_CONFIG_GAxiStreamConfigType := AXI_STREAM_CONFIG_INIT_C
out srpReqSrpV3ReqType
Definition: SrpV3Core.vhd:69
AXI_CONFIG_GAxiConfigType :=( 33, 4, 1, 8)
Definition: SrpV3Axi.vhd:46
out mAxisMasterAxiStreamMasterType
Definition: SrpV3Core.vhd:64
sl request
Definition: AxiDmaPkg.vhd:47
PIPE_STAGES_Gnatural range 0 to 16:= 0
Definition: SrpV3Axi.vhd:38
in axiWriteSlaveAxiWriteSlaveType
Definition: SrpV3Axi.vhd:71
SrpV3AckType
Definition: SrpV3Pkg.vhd:65
AXI_CONFIG_GAxiConfigType := AXI_CONFIG_INIT_C
AXI_CLK_FREQ_Greal := 156.25E+6
Definition: SrpV3Axi.vhd:45
SrpV3AckType :=(done => '0',respCode =>( others => '0')) SRPV3_ACK_INIT_C
Definition: SrpV3Pkg.vhd:70
WRITE_EN_Gboolean := true
Definition: SrpV3Core.vhd:51
in srpAckSrpV3AckType
Definition: SrpV3Core.vhd:70
TPD_Gtime := 1 ns
Definition: SrpV3Core.vhd:39
SRP_CLK_FREQ_Greal := 156.25E+6
Definition: SrpV3Core.vhd:47
slv( 1 downto 0) := "10" SRP_POSTED_WRITE_C
Definition: SrpV3Pkg.vhd:43
AxiReadMasterType
Definition: AxiPkg.vhd:32
out axiWriteMasterAxiWriteMasterType
Definition: SrpV3Axi.vhd:70
out axisSlaveAxiStreamSlaveType
AXI_READY_EN_Gboolean := false
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
out axisMasterAxiStreamMasterType
AxiWriteDmaReqType :=(request => '0',drop => '0',address =>( others => '0'),maxSize =>( others => '0')) AXI_WRITE_DMA_REQ_INIT_C
Definition: AxiDmaPkg.vhd:54