Skip to content

Commit 0484417

Browse files
authored
Merge pull request #1015 from slaclab/pre-release
Release Candidate v2.34.3
2 parents f9fea6d + f1337b0 commit 0484417

File tree

12 files changed

+1060
-231
lines changed

12 files changed

+1060
-231
lines changed

axi/axi-stream/rtl/AxiStreamRingBuffer.vhd

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ entity AxiStreamRingBuffer is
4343
dataRst : in sl := '0';
4444
dataValid : in sl := '1';
4545
dataValue : in slv(8*DATA_BYTES_G-1 downto 0);
46-
bufferEnable : in sl := '0';
47-
bufferClear : in sl := '0';
46+
extTrig : in sl := '0';
4847
-- AXI-Lite interface (axilClk domain)
4948
axilClk : in sl;
5049
axilRst : in sl;
@@ -73,6 +72,8 @@ architecture rtl of AxiStreamRingBuffer is
7372
-- Stream clock domain signals
7473
------------------------------
7574
type DataRegType is record
75+
extTrig : sl;
76+
bufferEnable : sl;
7677
enable : sl;
7778
cleared : sl;
7879
armed : sl;
@@ -85,6 +86,8 @@ architecture rtl of AxiStreamRingBuffer is
8586
end record;
8687

8788
constant DATA_REG_INIT_C : DataRegType := (
89+
extTrig => '0',
90+
bufferEnable => '0',
8891
enable => '0',
8992
cleared => '1', -- Only set HIGH after reset
9093
armed => '0',
@@ -153,11 +156,9 @@ architecture rtl of AxiStreamRingBuffer is
153156
signal firstAddr : slv(RAM_ADDR_WIDTH_G-1 downto 0);
154157
signal bufferLength : slv(RAM_ADDR_WIDTH_G-1 downto 0);
155158

156-
signal extBufferEnable : sl;
157-
signal extBufferClear : sl;
158-
signal readReq : sl;
159-
signal cleared : sl;
160-
signal armed : sl;
159+
signal readReq : sl;
160+
signal cleared : sl;
161+
signal armed : sl;
161162

162163
signal txSlave : AxiStreamSlaveType;
163164

@@ -232,23 +233,30 @@ begin
232233
--------------------------------------------------
233234
-- Synchronize AXI registers to data clock dataClk
234235
--------------------------------------------------
235-
U_SyncVec_dataClk : entity surf.SynchronizerVector
236+
U_bufferEnable : entity surf.Synchronizer
236237
generic map (
237-
TPD_G => TPD_G,
238-
WIDTH_G => 2)
238+
TPD_G => TPD_G)
239+
port map (
240+
clk => dataClk,
241+
rst => dataRst,
242+
dataIn => axilR.bufferEnable,
243+
dataOut => bufferEnableSync);
244+
245+
U_bufferClear : entity surf.SynchronizerOneShot
246+
generic map (
247+
TPD_G => TPD_G,
248+
PULSE_WIDTH_G => 10)
239249
port map (
240-
clk => dataClk,
241-
rst => dataRst,
242-
dataIn(0) => axilR.bufferEnable,
243-
dataIn(1) => axilR.bufferClear,
244-
dataOut(0) => bufferEnableSync,
245-
dataOut(1) => bufferClearSync);
250+
clk => dataClk,
251+
rst => dataRst,
252+
dataIn => axilR.bufferClear,
253+
dataOut => bufferClearSync);
246254

247255
--------------------------
248256
-- Main AXI-Stream process
249257
--------------------------
250-
dataComb : process (bufferClear, bufferClearSync, bufferEnable,
251-
bufferEnableSync, dataR, dataRst, dataValid, dataValue) is
258+
dataComb : process (bufferClearSync, bufferEnableSync, dataR, dataRst,
259+
dataValid, dataValue, extTrig) is
252260
variable v : DataRegType;
253261
begin
254262
-- Latch the current value
@@ -259,9 +267,15 @@ begin
259267
v.readReq := '0';
260268
v.cleared := '0';
261269

270+
-- Check for external trigger
271+
if (extTrig = '1') and (dataR.extTrig = '0') then
272+
v.extTrig := '1';
273+
v.bufferEnable := '1';
274+
end if;
275+
262276
-- Default assignment
263277
v.ramWrData := dataValue;
264-
v.enable := bufferEnableSync or bufferEnable;
278+
v.enable := bufferEnableSync or dataR.bufferEnable;
265279

266280
-- Increment the addresses on each valid if logging enabled
267281
if (dataValid = '1') and (dataR.enable = '1') then
@@ -272,8 +286,9 @@ begin
272286
v.nextAddr := dataR.nextAddr + 1;
273287
-- Check if the write pointer = read pointer
274288
if (v.nextAddr = dataR.firstAddr) then
275-
v.firstAddr := dataR.firstAddr + 1;
276-
v.armed := '1';
289+
v.firstAddr := dataR.firstAddr + 1;
290+
v.armed := '1';
291+
v.bufferEnable := '0';
277292
end if;
278293
-- Calculate the length of the buffer
279294
v.bufferLength := dataR.nextAddr - dataR.firstAddr;
@@ -285,7 +300,7 @@ begin
285300
end if;
286301

287302
-- Synchronous Reset
288-
if (dataRst = '1') or (bufferClearSync = '1') or (bufferClear = '1') then
303+
if (dataRst = '1') or (bufferClearSync = '1') then
289304
v := DATA_REG_INIT_C;
290305
end if;
291306

@@ -328,31 +343,30 @@ begin
328343
U_SyncVec_axilClk : entity surf.SynchronizerVector
329344
generic map (
330345
TPD_G => TPD_G,
331-
WIDTH_G => 4)
346+
WIDTH_G => 2)
332347
port map (
333348
clk => axilClk,
334349
rst => axilRst,
335-
dataIn(0) => bufferEnable,
336-
dataIn(1) => bufferClear,
337-
dataIn(2) => dataR.cleared,
338-
dataIn(3) => dataR.armed,
339-
dataOut(0) => extBufferEnable,
340-
dataOut(1) => extbufferClear,
341-
dataOut(2) => cleared,
342-
dataOut(3) => armed);
350+
dataIn(0) => dataR.cleared,
351+
dataIn(1) => dataR.armed,
352+
dataOut(0) => cleared,
353+
dataOut(1) => armed);
343354

344355
------------------------
345356
-- Main AXI-Lite process
346357
------------------------
347358
axiComb : process (armed, axilR, axilReadMaster, axilRst, axilWriteMaster,
348-
bufferLength, cleared, extBufferClear, extBufferEnable,
349-
firstAddr, ramRdData, readReq, txSlave) is
359+
bufferLength, cleared, firstAddr, ramRdData, readReq,
360+
txSlave) is
350361
variable v : AxilRegType;
351362
variable axilEp : AxiLiteEndpointType;
352363
begin
353364
-- Latch the current value
354365
v := axilR;
355366

367+
-- Reset strobe
368+
v.bufferClear := '0';
369+
356370
------------------------
357371
-- AXI-Lite Transactions
358372
------------------------
@@ -362,10 +376,7 @@ begin
362376

363377
axiSlaveRegisterR(axilEp, x"0", 0, bufferLength);
364378
axiSlaveRegisterR(axilEp, x"0", 20, toSlv(RAM_ADDR_WIDTH_G, 8));
365-
axiSlaveRegisterR(axilEp, x"0", 28, extBufferClear);
366-
axiSlaveRegisterR(axilEp, x"0", 29, extBufferEnable);
367379
axiSlaveRegisterR(axilEp, x"4", 0, axilR.trigCnt);
368-
369380
axiSlaveRegister (axilEp, x"8", 0, v.trigCnt);
370381
axiSlaveRegister (axilEp, x"C", 0, v.continuous);
371382

@@ -380,10 +391,10 @@ begin
380391
----------------------------------------------------------------------
381392
when IDLE_S =>
382393
-- Check for trigger request
383-
if (axilR.trigCnt /= 0) or (axilR.continuous = '1') then
394+
if ((axilR.trigCnt /= 0) or (axilR.continuous = '1')) and (axilR.dataState = IDLE_S) then
384395
-- Set the flags
385-
v.bufferClear := '1';
386396
v.bufferEnable := '1';
397+
v.bufferClear := '1';
387398
-- Check if we need to decrement the counter
388399
if (axilR.trigCnt /= 0) then
389400
-- Decrement the counter
@@ -392,16 +403,14 @@ begin
392403
-- Next state
393404
v.trigState := CLEAR_S;
394405
else
395-
-- Reset the flags
396-
v.bufferClear := '0';
406+
-- Reset the flag
397407
v.bufferEnable := '0';
398408
end if;
399409
----------------------------------------------------------------------
400410
when CLEAR_S =>
401411
-- Check if cleared
402412
if (cleared = '1') then
403-
-- Set the flags
404-
v.bufferClear := '0';
413+
-- Set the flag
405414
v.bufferEnable := '1';
406415
-- Next state
407416
v.trigState := ARMED_S;
@@ -410,16 +419,14 @@ begin
410419
when ARMED_S =>
411420
-- Check if armed
412421
if (armed = '1') then
413-
-- Set the flags
414-
v.bufferClear := '0';
422+
-- Set the flag
415423
v.bufferEnable := '0';
416424
-- Next state
417425
v.trigState := WAIT_S;
418426
end if;
419427
----------------------------------------------------------------------
420428
when WAIT_S =>
421-
-- Set the flags
422-
v.bufferClear := '0';
429+
-- Set the flag
423430
v.bufferEnable := '0';
424431
----------------------------------------------------------------------
425432
end case;
@@ -474,6 +481,9 @@ begin
474481
-- Set the EOF bit
475482
v.txMaster.tLast := '1';
476483

484+
-- Set the clear flag
485+
v.bufferClear := '1';
486+
477487
-- Next states
478488
v.dataState := IDLE_S;
479489
v.trigState := IDLE_S;

0 commit comments

Comments
 (0)