1 |
2 |
weng_ziti |
----------------------------------------------------------------------------------
|
2 |
|
|
-- Company: ziti, Uni. HD
|
3 |
|
|
-- Engineer: wgao
|
4 |
|
|
--
|
5 |
|
|
-- Design Name:
|
6 |
|
|
-- Module Name: usDMA_Transact - Behavioral
|
7 |
|
|
-- Project Name:
|
8 |
|
|
-- Target Devices:
|
9 |
|
|
-- Tool versions:
|
10 |
|
|
-- Description:
|
11 |
|
|
--
|
12 |
|
|
-- Dependencies:
|
13 |
|
|
--
|
14 |
|
|
-- Revision 1.00 - first release. 14.12.2006
|
15 |
|
|
--
|
16 |
|
|
-- Additional Comments:
|
17 |
|
|
--
|
18 |
|
|
----------------------------------------------------------------------------------
|
19 |
|
|
|
20 |
|
|
library IEEE;
|
21 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
22 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
23 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
24 |
|
|
|
25 |
|
|
library work;
|
26 |
|
|
use work.abb64Package.all;
|
27 |
|
|
|
28 |
|
|
-- Uncomment the following library declaration if instantiating
|
29 |
|
|
-- any Xilinx primitives in this code.
|
30 |
|
|
--library UNISIM;
|
31 |
|
|
--use UNISIM.VComponents.all;
|
32 |
|
|
|
33 |
|
|
entity usDMA_Transact is
|
34 |
|
|
port (
|
35 |
|
|
-- Around the Channel Buffer
|
36 |
|
|
usTlp_Req : OUT std_logic;
|
37 |
|
|
usTlp_RE : IN std_logic;
|
38 |
|
|
usTlp_Qout : OUT std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
|
39 |
|
|
us_FC_stop : IN std_logic;
|
40 |
|
|
us_Last_sof : IN std_logic;
|
41 |
|
|
us_Last_eof : IN std_logic;
|
42 |
|
|
FIFO_Data_Count : IN std_logic_vector(C_FIFO_DC_WIDTH downto 0);
|
43 |
|
|
FIFO_Empty : IN std_logic;
|
44 |
|
|
FIFO_Reading : IN std_logic;
|
45 |
|
|
|
46 |
|
|
-- Upstream reset from MWr channel
|
47 |
|
|
usDMA_Channel_Rst : IN std_logic;
|
48 |
|
|
|
49 |
|
|
-- Upstream Registers from MWr Channel
|
50 |
|
|
DMA_us_PA : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
51 |
|
|
DMA_us_HA : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
52 |
|
|
DMA_us_BDA : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
53 |
|
|
DMA_us_Length : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
54 |
|
|
DMA_us_Control : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
55 |
|
|
usDMA_BDA_eq_Null : IN std_logic;
|
56 |
|
|
us_MWr_Param_Vec : IN std_logic_vector(6-1 downto 0);
|
57 |
|
|
|
58 |
|
|
-- Calculation in advance, for better timing
|
59 |
|
|
usHA_is_64b : IN std_logic;
|
60 |
|
|
usBDA_is_64b : IN std_logic;
|
61 |
|
|
|
62 |
|
|
-- Calculation in advance, for better timing
|
63 |
|
|
usLeng_Hi19b_True : IN std_logic;
|
64 |
|
|
usLeng_Lo7b_True : IN std_logic;
|
65 |
|
|
|
66 |
|
|
-- from Cpl/D channel
|
67 |
|
|
usDMA_dex_Tag : IN std_logic_vector(C_TAG_WIDTH-1 downto 0);
|
68 |
|
|
|
69 |
|
|
-- Upstream Control Signals from MWr Channel
|
70 |
|
|
usDMA_Start : IN std_logic; -- out of 1st dex
|
71 |
|
|
usDMA_Stop : IN std_logic; -- out of 1st dex
|
72 |
|
|
|
73 |
|
|
-- Upstream Control Signals from CplD Channel
|
74 |
|
|
usDMA_Start2 : IN std_logic; -- out of consecutive dex
|
75 |
|
|
usDMA_Stop2 : IN std_logic; -- out of consecutive dex
|
76 |
|
|
|
77 |
|
|
-- Upstream DMA Acknowledge to the start command
|
78 |
|
|
DMA_Cmd_Ack : OUT std_logic;
|
79 |
|
|
|
80 |
|
|
-- To Interrupt module
|
81 |
|
|
DMA_Done : OUT std_logic;
|
82 |
|
|
DMA_TimeOut : OUT std_logic;
|
83 |
|
|
DMA_Busy : OUT std_logic;
|
84 |
|
|
|
85 |
|
|
-- To Registers' Group
|
86 |
|
|
DMA_us_Status : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
87 |
|
|
|
88 |
|
|
-- Additional
|
89 |
|
|
cfg_dcommand : IN std_logic_vector(C_CFG_COMMAND_DWIDTH-1 downto 0);
|
90 |
|
|
|
91 |
|
|
-- Common ports
|
92 |
|
|
trn_clk : IN std_logic;
|
93 |
|
|
trn_reset_n : IN std_logic
|
94 |
|
|
);
|
95 |
|
|
|
96 |
|
|
end entity usDMA_Transact;
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
architecture Behavioral of usDMA_Transact is
|
101 |
|
|
|
102 |
|
|
-- Upstream DMA channel
|
103 |
|
|
signal Local_Reset_i : std_logic;
|
104 |
|
|
signal DMA_Status_i : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
105 |
|
|
|
106 |
|
|
signal cfg_MPS : std_logic_vector(C_CFG_MPS_BIT_TOP-C_CFG_MPS_BIT_BOT downto 0);
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
signal usDMA_MWr_Tag : std_logic_vector(C_TAG_WIDTH-1 downto 0);
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
-- DMA calculation
|
113 |
|
|
COMPONENT DMA_Calculate
|
114 |
|
|
PORT(
|
115 |
|
|
-- Downstream Registers from MWr Channel
|
116 |
|
|
DMA_PA : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0); -- EP (local)
|
117 |
|
|
DMA_HA : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0); -- Host (remote)
|
118 |
|
|
DMA_BDA : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
119 |
|
|
DMA_Length : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
120 |
|
|
DMA_Control : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
121 |
|
|
|
122 |
|
|
-- Calculation in advance, for better timing
|
123 |
|
|
HA_is_64b : IN std_logic;
|
124 |
|
|
BDA_is_64b : IN std_logic;
|
125 |
|
|
|
126 |
|
|
-- Calculation in advance, for better timing
|
127 |
|
|
Leng_Hi19b_True : IN std_logic;
|
128 |
|
|
Leng_Lo7b_True : IN std_logic;
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
-- Parameters fed to DMA_FSM
|
132 |
|
|
DMA_PA_Loaded : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
133 |
|
|
DMA_PA_Var : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
134 |
|
|
DMA_HA_Var : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
135 |
|
|
|
136 |
|
|
DMA_BDA_fsm : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
137 |
|
|
BDA_is_64b_fsm : OUT std_logic;
|
138 |
|
|
DMA_0_Leng : OUT std_logic;
|
139 |
|
|
|
140 |
|
|
-- Only for downstream channel
|
141 |
|
|
DMA_PA_Snout : OUT std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
142 |
|
|
DMA_BAR_Number : OUT std_logic_vector(C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0);
|
143 |
|
|
|
144 |
|
|
--
|
145 |
|
|
DMA_Snout_Length : OUT std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
|
146 |
|
|
DMA_Body_Length : OUT std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
|
147 |
|
|
DMA_Tail_Length : OUT std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG+1 downto 0);
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
-- Engine control signals
|
151 |
|
|
DMA_Start : IN std_logic;
|
152 |
|
|
DMA_Start2 : IN std_logic; -- out of consecutive dex
|
153 |
|
|
|
154 |
|
|
-- Control signals to FSM
|
155 |
|
|
No_More_Bodies : OUT std_logic;
|
156 |
|
|
ThereIs_Snout : OUT std_logic;
|
157 |
|
|
ThereIs_Body : OUT std_logic;
|
158 |
|
|
ThereIs_Tail : OUT std_logic;
|
159 |
|
|
ThereIs_Dex : OUT std_logic;
|
160 |
|
|
HA64bit : OUT std_logic;
|
161 |
|
|
Addr_Inc : OUT std_logic;
|
162 |
|
|
|
163 |
|
|
-- FSM indicators
|
164 |
|
|
State_Is_LoadParam : IN std_logic;
|
165 |
|
|
State_Is_Snout : IN std_logic;
|
166 |
|
|
State_Is_Body : IN std_logic;
|
167 |
|
|
-- State_Is_Tail : IN std_logic;
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
-- Additional
|
171 |
|
|
Param_Max_Cfg : IN std_logic_vector(2 downto 0);
|
172 |
|
|
|
173 |
|
|
-- Common ports
|
174 |
|
|
dma_clk : IN std_logic;
|
175 |
|
|
dma_reset : IN std_logic
|
176 |
|
|
);
|
177 |
|
|
END COMPONENT;
|
178 |
|
|
|
179 |
|
|
signal usDMA_PA_Loaded : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
180 |
|
|
signal usDMA_PA_Var : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
181 |
|
|
signal usDMA_HA_Var : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
182 |
|
|
|
183 |
|
|
signal usDMA_BDA_fsm : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
184 |
|
|
signal usBDA_is_64b_fsm : std_logic;
|
185 |
|
|
signal usDMA_0_Leng : std_logic;
|
186 |
|
|
|
187 |
|
|
signal usDMA_PA_snout : std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
188 |
|
|
|
189 |
|
|
signal usDMA_BAR_Number : std_logic_vector(C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0);
|
190 |
|
|
|
191 |
|
|
signal usDMA_Snout_Length : std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
|
192 |
|
|
signal usDMA_Body_Length : std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
|
193 |
|
|
signal usDMA_Tail_Length : std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG+1 downto 0);
|
194 |
|
|
|
195 |
|
|
signal usNo_More_Bodies : std_logic;
|
196 |
|
|
signal usThereIs_Snout : std_logic;
|
197 |
|
|
signal usThereIs_Body : std_logic;
|
198 |
|
|
signal usThereIs_Tail : std_logic;
|
199 |
|
|
signal usThereIs_Dex : std_logic;
|
200 |
|
|
signal usHA64bit : std_logic;
|
201 |
|
|
signal us_AInc : std_logic;
|
202 |
|
|
|
203 |
|
|
signal us_Last_sof_or : std_logic;
|
204 |
|
|
signal us_Last_eof_or : std_logic;
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
-- DMA state machine
|
208 |
|
|
COMPONENT DMA_FSM
|
209 |
|
|
PORT(
|
210 |
|
|
-- Fixed information for 1st header of TLP: MRd/MWr
|
211 |
|
|
TLP_Has_Payload : IN std_logic;
|
212 |
|
|
TLP_Hdr_is_4DW : IN std_logic;
|
213 |
|
|
DMA_Addr_Inc : IN std_logic;
|
214 |
|
|
|
215 |
|
|
DMA_BAR_Number : IN std_logic_vector(C_TAGBAR_BIT_TOP-C_TAGBAR_BIT_BOT downto 0);
|
216 |
|
|
|
217 |
|
|
-- FSM control signals
|
218 |
|
|
DMA_Start : IN std_logic;
|
219 |
|
|
DMA_Start2 : IN std_logic;
|
220 |
|
|
DMA_Stop : IN std_logic;
|
221 |
|
|
DMA_Stop2 : IN std_logic;
|
222 |
|
|
|
223 |
|
|
No_More_Bodies : IN std_logic;
|
224 |
|
|
ThereIs_Snout : IN std_logic;
|
225 |
|
|
ThereIs_Body : IN std_logic;
|
226 |
|
|
ThereIs_Tail : IN std_logic;
|
227 |
|
|
ThereIs_Dex : IN std_logic;
|
228 |
|
|
|
229 |
|
|
-- Parameters to be written into ChBuf
|
230 |
|
|
DMA_PA_Loaded : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
231 |
|
|
DMA_PA_Var : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
232 |
|
|
DMA_HA_Var : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
233 |
|
|
|
234 |
|
|
DMA_BDA_fsm : IN std_logic_vector(C_DBUS_WIDTH-1 downto 0);
|
235 |
|
|
BDA_is_64b_fsm : IN std_logic;
|
236 |
|
|
|
237 |
|
|
DMA_Snout_Length : IN std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
|
238 |
|
|
DMA_Body_Length : IN std_logic_vector(C_MAXSIZE_FLD_BIT_TOP downto 0);
|
239 |
|
|
DMA_Tail_Length : IN std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG+1 downto 0);
|
240 |
|
|
|
241 |
|
|
-- Busy/Done conditions
|
242 |
|
|
Done_Condition_1 : IN std_logic;
|
243 |
|
|
Done_Condition_2 : IN std_logic;
|
244 |
|
|
Done_Condition_3 : IN std_logic;
|
245 |
|
|
Done_Condition_4 : IN std_logic;
|
246 |
|
|
Done_Condition_5 : IN std_logic;
|
247 |
|
|
Done_Condition_6 : IN std_logic;
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
-- Channel buffer write
|
251 |
|
|
us_MWr_Param_Vec : IN std_logic_vector(6-1 downto 0);
|
252 |
|
|
ChBuf_aFull : IN std_logic;
|
253 |
|
|
ChBuf_WrEn : OUT std_logic;
|
254 |
|
|
ChBuf_WrDin : OUT std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
-- FSM indicators
|
258 |
|
|
State_Is_LoadParam : OUT std_logic;
|
259 |
|
|
State_Is_Snout : OUT std_logic;
|
260 |
|
|
State_Is_Body : OUT std_logic;
|
261 |
|
|
State_Is_Tail : OUT std_logic;
|
262 |
|
|
DMA_Cmd_Ack : OUT std_logic;
|
263 |
|
|
|
264 |
|
|
-- To Tx Port
|
265 |
|
|
ChBuf_ValidRd : IN std_logic;
|
266 |
|
|
BDA_nAligned : OUT std_logic;
|
267 |
|
|
DMA_TimeOut : OUT std_logic;
|
268 |
|
|
DMA_Busy : OUT std_logic;
|
269 |
|
|
DMA_Done : OUT std_logic;
|
270 |
|
|
-- DMA_Done_Rise : OUT std_logic;
|
271 |
|
|
|
272 |
|
|
-- Tags
|
273 |
|
|
Pkt_Tag : IN std_logic_vector(C_TAG_WIDTH-1 downto 0);
|
274 |
|
|
Dex_Tag : IN std_logic_vector(C_TAG_WIDTH-1 downto 0);
|
275 |
|
|
|
276 |
|
|
-- Common ports
|
277 |
|
|
dma_clk : IN std_logic;
|
278 |
|
|
dma_reset : IN std_logic
|
279 |
|
|
);
|
280 |
|
|
END COMPONENT;
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
-- FSM state indicators
|
284 |
|
|
signal usState_Is_LoadParam : std_logic;
|
285 |
|
|
signal usState_Is_Snout : std_logic;
|
286 |
|
|
signal usState_Is_Body : std_logic;
|
287 |
|
|
signal usState_Is_Tail : std_logic;
|
288 |
|
|
|
289 |
|
|
signal usChBuf_ValidRd : std_logic;
|
290 |
|
|
signal usBDA_nAligned : std_logic;
|
291 |
|
|
signal usDMA_TimeOut_i : std_logic;
|
292 |
|
|
signal usDMA_Busy_i : std_logic;
|
293 |
|
|
signal usDMA_Done_i : std_logic;
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
-- Built-in single-port fifo as downstream DMA channel buffer
|
297 |
|
|
-- 128-bit wide, for 64-bit address
|
298 |
|
|
component v5sfifo_15x128
|
299 |
|
|
port (
|
300 |
|
|
clk : IN std_logic;
|
301 |
|
|
rst : IN std_logic;
|
302 |
|
|
prog_full : OUT std_logic;
|
303 |
|
|
-- wr_clk : IN std_logic;
|
304 |
|
|
wr_en : IN std_logic;
|
305 |
|
|
din : IN std_logic_VECTOR(C_CHANNEL_BUF_WIDTH-1 downto 0);
|
306 |
|
|
full : OUT std_logic;
|
307 |
|
|
-- rd_clk : IN std_logic;
|
308 |
|
|
rd_en : IN std_logic;
|
309 |
|
|
dout : OUT std_logic_VECTOR(C_CHANNEL_BUF_WIDTH-1 downto 0);
|
310 |
|
|
prog_empty : OUT std_logic;
|
311 |
|
|
empty : OUT std_logic
|
312 |
|
|
);
|
313 |
|
|
end component;
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
-- Signal with DMA_upstream channel abstract buffer
|
317 |
|
|
signal usTlp_din : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
|
318 |
|
|
signal usTlp_Qout_wire : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
|
319 |
|
|
signal usTlp_Qout_reg : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
|
320 |
|
|
signal usTlp_Qout_i : std_logic_vector(C_CHANNEL_BUF_WIDTH-1 downto 0);
|
321 |
|
|
signal usTlp_RE_i : std_logic;
|
322 |
|
|
signal usTlp_RE_i_r1 : std_logic;
|
323 |
|
|
signal usTlp_we : std_logic;
|
324 |
|
|
signal usTlp_empty_i : std_logic;
|
325 |
|
|
signal usTlp_full : std_logic;
|
326 |
|
|
signal usTlp_prog_Full : std_logic;
|
327 |
|
|
|
328 |
|
|
signal usTlp_pempty : std_logic;
|
329 |
|
|
signal usTlp_Npempty_r1 : std_logic;
|
330 |
|
|
signal usTlp_Nempty_r1 : std_logic;
|
331 |
|
|
signal usTlp_empty_r1 : std_logic;
|
332 |
|
|
signal usTlp_empty_r2 : std_logic;
|
333 |
|
|
signal usTlp_empty_r3 : std_logic;
|
334 |
|
|
signal usTlp_empty_r4 : std_logic;
|
335 |
|
|
signal usTlp_prog_Full_r1 : std_logic;
|
336 |
|
|
|
337 |
|
|
-- Request for output arbitration
|
338 |
|
|
signal usTlp_NoMoreReq : std_logic;
|
339 |
|
|
signal usTlp_Req_i : std_logic;
|
340 |
|
|
signal usTlp_nReq_r1 : std_logic;
|
341 |
|
|
signal FIFO_Reading_r1 : std_logic;
|
342 |
|
|
signal FIFO_Reading_r2 : std_logic;
|
343 |
|
|
signal FIFO_Reading_r3p : std_logic;
|
344 |
|
|
signal usTlp_MWr_Leng : std_logic_vector(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0);
|
345 |
|
|
|
346 |
|
|
-- Busy/Done state bits generation
|
347 |
|
|
type FSM_Request is (
|
348 |
|
|
REQST_Idle
|
349 |
|
|
, REQST_1Read
|
350 |
|
|
, REQST_Decision
|
351 |
|
|
, REQST_nFIFO_Req
|
352 |
|
|
, REQST_Quantity
|
353 |
|
|
, REQST_FIFO_Req
|
354 |
|
|
);
|
355 |
|
|
|
356 |
|
|
signal FSM_REQ_us : FSM_Request;
|
357 |
|
|
|
358 |
|
|
begin
|
359 |
|
|
|
360 |
|
|
-- DMA done signal
|
361 |
|
|
DMA_Done <= usDMA_Done_i;
|
362 |
|
|
DMA_TimeOut <= usDMA_TimeOut_i;
|
363 |
|
|
DMA_Busy <= usDMA_Busy_i;
|
364 |
|
|
|
365 |
|
|
-- connecting FIFO's signals
|
366 |
|
|
usTlp_Qout <= usTlp_Qout_i;
|
367 |
|
|
usTlp_Req <= usTlp_Req_i and not FIFO_Reading_r3p;
|
368 |
|
|
|
369 |
|
|
-- sent packet frames
|
370 |
|
|
us_Last_sof_or <= us_Last_sof or usDMA_0_Leng;
|
371 |
|
|
us_Last_eof_or <= us_Last_eof or usDMA_0_Leng;
|
372 |
|
|
|
373 |
|
|
-- positive local reset
|
374 |
|
|
-- Local_Reset_i <= not trn_reset_n or usDMA_Channel_Rst;
|
375 |
|
|
Local_Reset_i <= usDMA_Channel_Rst;
|
376 |
|
|
|
377 |
|
|
-- Max Payload Size bits
|
378 |
|
|
cfg_MPS <= cfg_dcommand(C_CFG_MPS_BIT_TOP downto C_CFG_MPS_BIT_BOT);
|
379 |
|
|
|
380 |
|
|
|
381 |
|
|
-- Kernel Engine
|
382 |
|
|
us_DMA_Calculation:
|
383 |
|
|
DMA_Calculate
|
384 |
|
|
PORT MAP(
|
385 |
|
|
|
386 |
|
|
DMA_PA => DMA_us_PA ,
|
387 |
|
|
DMA_HA => DMA_us_HA ,
|
388 |
|
|
DMA_BDA => DMA_us_BDA ,
|
389 |
|
|
DMA_Length => DMA_us_Length ,
|
390 |
|
|
DMA_Control => DMA_us_Control ,
|
391 |
|
|
|
392 |
|
|
HA_is_64b => usHA_is_64b ,
|
393 |
|
|
BDA_is_64b => usBDA_is_64b ,
|
394 |
|
|
|
395 |
|
|
|
396 |
|
|
Leng_Hi19b_True => usLeng_Hi19b_True ,
|
397 |
|
|
Leng_Lo7b_True => usLeng_Lo7b_True ,
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
DMA_PA_Loaded => usDMA_PA_Loaded ,
|
401 |
|
|
DMA_PA_Var => usDMA_PA_Var ,
|
402 |
|
|
DMA_HA_Var => usDMA_HA_Var ,
|
403 |
|
|
|
404 |
|
|
DMA_BDA_fsm => usDMA_BDA_fsm ,
|
405 |
|
|
BDA_is_64b_fsm => usBDA_is_64b_fsm ,
|
406 |
|
|
DMA_0_Leng => usDMA_0_Leng ,
|
407 |
|
|
|
408 |
|
|
-- Only for downstream channel
|
409 |
|
|
DMA_PA_Snout => usDMA_PA_snout ,
|
410 |
|
|
DMA_BAR_Number => usDMA_BAR_Number ,
|
411 |
|
|
|
412 |
|
|
-- Lengths
|
413 |
|
|
DMA_Snout_Length => usDMA_Snout_Length ,
|
414 |
|
|
DMA_Body_Length => usDMA_Body_Length ,
|
415 |
|
|
DMA_Tail_Length => usDMA_Tail_Length ,
|
416 |
|
|
|
417 |
|
|
|
418 |
|
|
-- Control signals to FSM
|
419 |
|
|
No_More_Bodies => usNo_More_Bodies ,
|
420 |
|
|
ThereIs_Snout => usThereIs_Snout ,
|
421 |
|
|
ThereIs_Body => usThereIs_Body ,
|
422 |
|
|
ThereIs_Tail => usThereIs_Tail ,
|
423 |
|
|
ThereIs_Dex => usThereIs_Dex ,
|
424 |
|
|
HA64bit => usHA64bit ,
|
425 |
|
|
Addr_Inc => us_AInc ,
|
426 |
|
|
|
427 |
|
|
|
428 |
|
|
DMA_Start => usDMA_Start ,
|
429 |
|
|
DMA_Start2 => usDMA_Start2 ,
|
430 |
|
|
|
431 |
|
|
State_Is_LoadParam => usState_Is_LoadParam ,
|
432 |
|
|
State_Is_Snout => usState_Is_Snout ,
|
433 |
|
|
State_Is_Body => usState_Is_Body ,
|
434 |
|
|
-- State_Is_Tail => usState_Is_Tail ,
|
435 |
|
|
|
436 |
|
|
|
437 |
|
|
Param_Max_Cfg => cfg_MPS ,
|
438 |
|
|
|
439 |
|
|
dma_clk => trn_clk ,
|
440 |
|
|
dma_reset => Local_Reset_i
|
441 |
|
|
);
|
442 |
|
|
|
443 |
|
|
|
444 |
|
|
-- Kernel FSM
|
445 |
|
|
us_DMA_StateMachine:
|
446 |
|
|
DMA_FSM
|
447 |
|
|
PORT MAP(
|
448 |
|
|
TLP_Has_Payload => '1' ,
|
449 |
|
|
TLP_Hdr_is_4DW => usHA64bit ,
|
450 |
|
|
DMA_Addr_Inc => us_AInc ,
|
451 |
|
|
|
452 |
|
|
DMA_BAR_Number => usDMA_BAR_Number ,
|
453 |
|
|
|
454 |
|
|
DMA_Start => usDMA_Start ,
|
455 |
|
|
DMA_Start2 => usDMA_Start2 ,
|
456 |
|
|
DMA_Stop => usDMA_Stop ,
|
457 |
|
|
DMA_Stop2 => usDMA_Stop2 ,
|
458 |
|
|
|
459 |
|
|
-- Control signals to FSM
|
460 |
|
|
No_More_Bodies => usNo_More_Bodies ,
|
461 |
|
|
ThereIs_Snout => usThereIs_Snout ,
|
462 |
|
|
ThereIs_Body => usThereIs_Body ,
|
463 |
|
|
ThereIs_Tail => usThereIs_Tail ,
|
464 |
|
|
ThereIs_Dex => usThereIs_Dex ,
|
465 |
|
|
|
466 |
|
|
|
467 |
|
|
DMA_PA_Loaded => usDMA_PA_Loaded ,
|
468 |
|
|
DMA_PA_Var => usDMA_PA_Var ,
|
469 |
|
|
DMA_HA_Var => usDMA_HA_Var ,
|
470 |
|
|
|
471 |
|
|
DMA_BDA_fsm => usDMA_BDA_fsm ,
|
472 |
|
|
BDA_is_64b_fsm => usBDA_is_64b_fsm ,
|
473 |
|
|
|
474 |
|
|
|
475 |
|
|
DMA_Snout_Length => usDMA_Snout_Length ,
|
476 |
|
|
DMA_Body_Length => usDMA_Body_Length ,
|
477 |
|
|
DMA_Tail_Length => usDMA_Tail_Length ,
|
478 |
|
|
|
479 |
|
|
|
480 |
|
|
ChBuf_ValidRd => usChBuf_ValidRd ,
|
481 |
|
|
BDA_nAligned => usBDA_nAligned ,
|
482 |
|
|
DMA_TimeOut => usDMA_TimeOut_i ,
|
483 |
|
|
DMA_Busy => usDMA_Busy_i ,
|
484 |
|
|
DMA_Done => usDMA_Done_i ,
|
485 |
|
|
-- DMA_Done_Rise => open ,
|
486 |
|
|
|
487 |
|
|
Pkt_Tag => usDMA_MWr_Tag ,
|
488 |
|
|
Dex_Tag => usDMA_dex_Tag ,
|
489 |
|
|
|
490 |
|
|
|
491 |
|
|
Done_Condition_1 => '1' ,
|
492 |
|
|
Done_Condition_2 => usTlp_empty_r3 ,
|
493 |
|
|
Done_Condition_3 => usTlp_nReq_r1 ,
|
494 |
|
|
Done_Condition_4 => us_Last_sof_or ,
|
495 |
|
|
Done_Condition_5 => us_Last_eof_or ,
|
496 |
|
|
Done_Condition_6 => usTlp_NoMoreReq ,
|
497 |
|
|
|
498 |
|
|
us_MWr_Param_Vec => us_MWr_Param_Vec ,
|
499 |
|
|
ChBuf_aFull => usTlp_Npempty_r1 , -- usTlp_prog_Full_r1 ,
|
500 |
|
|
ChBuf_WrEn => usTlp_we ,
|
501 |
|
|
ChBuf_WrDin => usTlp_din ,
|
502 |
|
|
|
503 |
|
|
State_Is_LoadParam => usState_Is_LoadParam ,
|
504 |
|
|
State_Is_Snout => usState_Is_Snout ,
|
505 |
|
|
State_Is_Body => usState_Is_Body ,
|
506 |
|
|
State_Is_Tail => usState_Is_Tail ,
|
507 |
|
|
|
508 |
|
|
DMA_Cmd_Ack => DMA_Cmd_Ack ,
|
509 |
|
|
|
510 |
|
|
|
511 |
|
|
dma_clk => trn_clk ,
|
512 |
|
|
dma_reset => Local_Reset_i
|
513 |
|
|
);
|
514 |
|
|
|
515 |
|
|
usChBuf_ValidRd <= usTlp_RE; -- usTlp_RE_i and not usTlp_empty_i;
|
516 |
|
|
|
517 |
|
|
-- -------------------------------------------------
|
518 |
|
|
--
|
519 |
|
|
DMA_us_Status <= DMA_Status_i;
|
520 |
|
|
--
|
521 |
|
|
-- Synchronous output: DMA_Status_i
|
522 |
|
|
--
|
523 |
|
|
US_DMA_Status_Concat:
|
524 |
|
|
process ( trn_clk, Local_Reset_i)
|
525 |
|
|
begin
|
526 |
|
|
if Local_Reset_i = '1' then
|
527 |
|
|
DMA_Status_i <= (OTHERS =>'0');
|
528 |
|
|
elsif trn_clk'event and trn_clk = '1' then
|
529 |
|
|
|
530 |
|
|
DMA_Status_i <= (
|
531 |
|
|
CINT_BIT_DMA_STAT_NALIGN => usBDA_nAligned,
|
532 |
|
|
CINT_BIT_DMA_STAT_TIMEOUT => usDMA_TimeOut_i,
|
533 |
|
|
CINT_BIT_DMA_STAT_BDANULL => usDMA_BDA_eq_Null,
|
534 |
|
|
CINT_BIT_DMA_STAT_BUSY => usDMA_Busy_i,
|
535 |
|
|
CINT_BIT_DMA_STAT_DONE => usDMA_Done_i,
|
536 |
|
|
Others => '0'
|
537 |
|
|
);
|
538 |
|
|
|
539 |
|
|
end if;
|
540 |
|
|
end process;
|
541 |
|
|
|
542 |
|
|
|
543 |
|
|
-- -----------------------------------
|
544 |
|
|
-- Synchronous Register: usDMA_MWr_Tag
|
545 |
|
|
FSM_usDMA_usDMA_MWr_Tag:
|
546 |
|
|
process ( trn_clk, Local_Reset_i)
|
547 |
|
|
begin
|
548 |
|
|
if Local_Reset_i = '1' then
|
549 |
|
|
usDMA_MWr_Tag <= C_TAG0_DMA_US_MWR;
|
550 |
|
|
|
551 |
|
|
elsif trn_clk'event and trn_clk = '1' then
|
552 |
|
|
|
553 |
|
|
if usState_Is_Snout='1'
|
554 |
|
|
or usState_Is_Body='1'
|
555 |
|
|
or usState_Is_Tail='1'
|
556 |
|
|
then
|
557 |
|
|
-- Only 4 lower bits increment, higher 4 stay
|
558 |
|
|
usDMA_MWr_Tag(C_TAG_WIDTH-C_TAG_DECODE_BITS-1 downto 0)
|
559 |
|
|
<= usDMA_MWr_Tag(C_TAG_WIDTH-C_TAG_DECODE_BITS-1 downto 0)
|
560 |
|
|
+ CONV_STD_LOGIC_VECTOR(1, C_TAG_WIDTH-C_TAG_DECODE_BITS);
|
561 |
|
|
else
|
562 |
|
|
usDMA_MWr_Tag <= usDMA_MWr_Tag;
|
563 |
|
|
end if;
|
564 |
|
|
|
565 |
|
|
end if;
|
566 |
|
|
end process;
|
567 |
|
|
|
568 |
|
|
|
569 |
|
|
-- -------------------------------------------------
|
570 |
|
|
-- us MWr/MRd TLP Buffer
|
571 |
|
|
-- -------------------------------------------------
|
572 |
|
|
US_TLP_Buffer:
|
573 |
|
|
v5sfifo_15x128
|
574 |
|
|
port map (
|
575 |
|
|
clk => trn_clk,
|
576 |
|
|
rst => Local_Reset_i,
|
577 |
|
|
prog_full => usTlp_prog_Full ,
|
578 |
|
|
-- wr_clk => trn_clk,
|
579 |
|
|
wr_en => usTlp_we,
|
580 |
|
|
din => usTlp_din,
|
581 |
|
|
full => usTlp_full,
|
582 |
|
|
-- rd_clk => trn_clk,
|
583 |
|
|
rd_en => usTlp_RE_i,
|
584 |
|
|
dout => usTlp_Qout_wire,
|
585 |
|
|
prog_empty => usTlp_pempty,
|
586 |
|
|
empty => usTlp_empty_i
|
587 |
|
|
);
|
588 |
|
|
|
589 |
|
|
-- ---------------------------------------------
|
590 |
|
|
-- Synchronous delay
|
591 |
|
|
--
|
592 |
|
|
Synch_Delay_ren_Qout:
|
593 |
|
|
process (Local_Reset_i, trn_clk )
|
594 |
|
|
begin
|
595 |
|
|
if Local_Reset_i = '1' then
|
596 |
|
|
FIFO_Reading_r1 <= '0';
|
597 |
|
|
FIFO_Reading_r2 <= '0';
|
598 |
|
|
FIFO_Reading_r3p<= '0';
|
599 |
|
|
usTlp_RE_i_r1 <= '0';
|
600 |
|
|
usTlp_nReq_r1 <= '0';
|
601 |
|
|
usTlp_Qout_reg <= (OTHERS=>'0');
|
602 |
|
|
usTlp_MWr_Leng <= (OTHERS=>'0');
|
603 |
|
|
|
604 |
|
|
elsif trn_clk'event and trn_clk = '1' then
|
605 |
|
|
FIFO_Reading_r1 <= FIFO_Reading;
|
606 |
|
|
FIFO_Reading_r2 <= FIFO_Reading_r1;
|
607 |
|
|
FIFO_Reading_r3p<= FIFO_Reading_r1 or FIFO_Reading_r2;
|
608 |
|
|
usTlp_RE_i_r1 <= usTlp_RE_i;
|
609 |
|
|
usTlp_nReq_r1 <= not usTlp_Req_i;
|
610 |
|
|
if usTlp_RE_i_r1='1' then
|
611 |
|
|
usTlp_Qout_reg <= usTlp_Qout_wire;
|
612 |
|
|
usTlp_MWr_Leng <= usTlp_Qout_wire(C_CHBUF_LENG_BIT_TOP downto C_CHBUF_LENG_BIT_BOT);
|
613 |
|
|
else
|
614 |
|
|
usTlp_Qout_reg <= usTlp_Qout_reg;
|
615 |
|
|
usTlp_MWr_Leng <= usTlp_MWr_Leng;
|
616 |
|
|
end if;
|
617 |
|
|
|
618 |
|
|
end if;
|
619 |
|
|
end process;
|
620 |
|
|
|
621 |
|
|
|
622 |
|
|
-- ---------------------------------------------
|
623 |
|
|
-- Request for arbitration
|
624 |
|
|
--
|
625 |
|
|
Synch_Req_Proc:
|
626 |
|
|
process (Local_Reset_i, trn_clk )
|
627 |
|
|
begin
|
628 |
|
|
if Local_Reset_i = '1' then
|
629 |
|
|
usTlp_RE_i <= '0';
|
630 |
|
|
usTlp_Req_i <= '0';
|
631 |
|
|
usTlp_NoMoreReq<= '1';
|
632 |
|
|
FSM_REQ_us <= REQST_IDLE;
|
633 |
|
|
|
634 |
|
|
elsif trn_clk'event and trn_clk = '1' then
|
635 |
|
|
|
636 |
|
|
case FSM_REQ_us is
|
637 |
|
|
|
638 |
|
|
when REQST_IDLE =>
|
639 |
|
|
usTlp_NoMoreReq <= '1';
|
640 |
|
|
if usTlp_empty_i = '0' then
|
641 |
|
|
usTlp_RE_i <= '1';
|
642 |
|
|
usTlp_Req_i <= '0';
|
643 |
|
|
FSM_REQ_us <= REQST_1Read;
|
644 |
|
|
else
|
645 |
|
|
usTlp_RE_i <= '0';
|
646 |
|
|
usTlp_Req_i <= '0';
|
647 |
|
|
FSM_REQ_us <= REQST_IDLE;
|
648 |
|
|
end if;
|
649 |
|
|
|
650 |
|
|
when REQST_1Read =>
|
651 |
|
|
usTlp_NoMoreReq <= '0';
|
652 |
|
|
usTlp_RE_i <= '0';
|
653 |
|
|
usTlp_Req_i <= '0';
|
654 |
|
|
FSM_REQ_us <= REQST_Decision;
|
655 |
|
|
|
656 |
|
|
when REQST_Decision =>
|
657 |
|
|
usTlp_NoMoreReq <= '0';
|
658 |
|
|
if usTlp_Qout_wire(C_CHBUF_FMT_BIT_TOP) = '1' -- Has Payload
|
659 |
|
|
and usTlp_Qout_wire(C_CHBUF_DMA_BAR_BIT_TOP downto C_CHBUF_DMA_BAR_BIT_BOT)
|
660 |
|
|
=CONV_STD_LOGIC_VECTOR(CINT_FIFO_SPACE_BAR, C_ENCODE_BAR_NUMBER)
|
661 |
|
|
then
|
662 |
|
|
usTlp_RE_i <= '0';
|
663 |
|
|
usTlp_Req_i <= '0';
|
664 |
|
|
FSM_REQ_us <= REQST_Quantity;
|
665 |
|
|
else
|
666 |
|
|
usTlp_RE_i <= '0';
|
667 |
|
|
usTlp_Req_i <= not usDMA_Stop
|
668 |
|
|
and not usDMA_Stop2
|
669 |
|
|
and not us_FC_stop;
|
670 |
|
|
FSM_REQ_us <= REQST_nFIFO_Req;
|
671 |
|
|
end if;
|
672 |
|
|
|
673 |
|
|
when REQST_nFIFO_Req =>
|
674 |
|
|
usTlp_NoMoreReq <= '0';
|
675 |
|
|
if usTlp_RE = '1' then
|
676 |
|
|
usTlp_RE_i <= '0';
|
677 |
|
|
usTlp_Req_i <= '0';
|
678 |
|
|
FSM_REQ_us <= REQST_IDLE;
|
679 |
|
|
else
|
680 |
|
|
usTlp_RE_i <= '0';
|
681 |
|
|
usTlp_Req_i <= not usDMA_Stop
|
682 |
|
|
and not usDMA_Stop2
|
683 |
|
|
and not us_FC_stop;
|
684 |
|
|
FSM_REQ_us <= REQST_nFIFO_Req;
|
685 |
|
|
end if;
|
686 |
|
|
|
687 |
|
|
when REQST_Quantity =>
|
688 |
|
|
usTlp_NoMoreReq <= '0';
|
689 |
|
|
if usTlp_RE = '1' then
|
690 |
|
|
usTlp_RE_i <= '1';
|
691 |
|
|
usTlp_Req_i <= '0';
|
692 |
|
|
FSM_REQ_us <= REQST_Quantity;
|
693 |
|
|
elsif (FIFO_Data_Count(C_FIFO_DC_WIDTH downto C_TLP_FLD_WIDTH_OF_LENG)=C_ALL_ZEROS(C_FIFO_DC_WIDTH downto C_TLP_FLD_WIDTH_OF_LENG)
|
694 |
|
|
and FIFO_Data_Count(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0) < usTlp_MWr_Leng(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0))
|
695 |
|
|
or FIFO_Empty='1'
|
696 |
|
|
then
|
697 |
|
|
usTlp_RE_i <= '0';
|
698 |
|
|
usTlp_Req_i <= '0';
|
699 |
|
|
FSM_REQ_us <= REQST_Quantity;
|
700 |
|
|
else
|
701 |
|
|
usTlp_RE_i <= '0';
|
702 |
|
|
usTlp_Req_i <= not usDMA_Stop
|
703 |
|
|
and not usDMA_Stop2
|
704 |
|
|
and not us_FC_stop;
|
705 |
|
|
FSM_REQ_us <= REQST_FIFO_Req;
|
706 |
|
|
end if;
|
707 |
|
|
|
708 |
|
|
when REQST_FIFO_Req =>
|
709 |
|
|
usTlp_NoMoreReq <= '0';
|
710 |
|
|
if (FIFO_Data_Count(C_FIFO_DC_WIDTH downto C_TLP_FLD_WIDTH_OF_LENG)=C_ALL_ZEROS(C_FIFO_DC_WIDTH downto C_TLP_FLD_WIDTH_OF_LENG)
|
711 |
|
|
and FIFO_Data_Count(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0) < usTlp_MWr_Leng(C_TLP_FLD_WIDTH_OF_LENG-1 downto 0))
|
712 |
|
|
or FIFO_Empty='1'
|
713 |
|
|
then
|
714 |
|
|
usTlp_RE_i <= '0';
|
715 |
|
|
usTlp_Req_i <= '0';
|
716 |
|
|
FSM_REQ_us <= REQST_Quantity;
|
717 |
|
|
elsif usTlp_RE = '1' then
|
718 |
|
|
usTlp_RE_i <= '0';
|
719 |
|
|
usTlp_Req_i <= '0';
|
720 |
|
|
FSM_REQ_us <= REQST_IDLE;
|
721 |
|
|
else
|
722 |
|
|
usTlp_RE_i <= '0';
|
723 |
|
|
usTlp_Req_i <= not usDMA_Stop
|
724 |
|
|
and not usDMA_Stop2
|
725 |
|
|
and not us_FC_stop;
|
726 |
|
|
FSM_REQ_us <= REQST_FIFO_Req;
|
727 |
|
|
end if;
|
728 |
|
|
|
729 |
|
|
when OTHERS =>
|
730 |
|
|
usTlp_NoMoreReq <= '1';
|
731 |
|
|
usTlp_RE_i <= '0';
|
732 |
|
|
usTlp_Req_i <= '0';
|
733 |
|
|
FSM_REQ_us <= REQST_IDLE;
|
734 |
|
|
|
735 |
|
|
end case;
|
736 |
|
|
|
737 |
|
|
end if;
|
738 |
|
|
end process;
|
739 |
|
|
|
740 |
|
|
|
741 |
|
|
-- ---------------------------------------------
|
742 |
|
|
-- Sending usTlp_Qout
|
743 |
|
|
--
|
744 |
|
|
Synch_usTlp_Qout:
|
745 |
|
|
process (Local_Reset_i, trn_clk )
|
746 |
|
|
begin
|
747 |
|
|
if Local_Reset_i = '1' then
|
748 |
|
|
usTlp_Qout_i <= (OTHERS=>'0');
|
749 |
|
|
|
750 |
|
|
elsif trn_clk'event and trn_clk = '1' then
|
751 |
|
|
|
752 |
|
|
if usTlp_RE = '1' then
|
753 |
|
|
usTlp_Qout_i <= usTlp_Qout_reg;
|
754 |
|
|
else
|
755 |
|
|
usTlp_Qout_i <= usTlp_Qout_i;
|
756 |
|
|
end if;
|
757 |
|
|
|
758 |
|
|
end if;
|
759 |
|
|
end process;
|
760 |
|
|
|
761 |
|
|
|
762 |
|
|
-- ---------------------------------------------
|
763 |
|
|
-- Delay of Empty and prog_Full
|
764 |
|
|
--
|
765 |
|
|
Synch_Delay_empty_and_full:
|
766 |
|
|
process ( trn_clk )
|
767 |
|
|
begin
|
768 |
|
|
if trn_clk'event and trn_clk = '1' then
|
769 |
|
|
usTlp_Npempty_r1 <= not usTlp_pempty;
|
770 |
|
|
usTlp_Nempty_r1 <= not usTlp_empty_i;
|
771 |
|
|
usTlp_empty_r1 <= usTlp_empty_i;
|
772 |
|
|
usTlp_empty_r2 <= usTlp_empty_r1;
|
773 |
|
|
usTlp_empty_r3 <= usTlp_empty_r2;
|
774 |
|
|
usTlp_empty_r4 <= usTlp_empty_r3;
|
775 |
|
|
usTlp_prog_Full_r1 <= usTlp_prog_Full;
|
776 |
|
|
-- usTlp_Req_i <= not usTlp_empty_i
|
777 |
|
|
-- and not usDMA_Stop
|
778 |
|
|
-- and not usDMA_Stop2
|
779 |
|
|
-- and not us_FC_stop
|
780 |
|
|
-- ;
|
781 |
|
|
end if;
|
782 |
|
|
end process;
|
783 |
|
|
|
784 |
|
|
|
785 |
|
|
end architecture Behavioral;
|