DEVEL: Tests for single window mode
This commit is contained in:
@ -12,6 +12,7 @@ library ieee;
|
||||
|
||||
library work;
|
||||
use work.psi_common_math_pkg.all;
|
||||
use work.psi_common_logic_pkg.all;
|
||||
use work.psi_common_array_pkg.all;
|
||||
use work.psi_ms_daq_pkg.all;
|
||||
|
||||
@ -344,14 +345,12 @@ begin
|
||||
|
||||
-- Response handling
|
||||
case r.HndlCtxCnt is
|
||||
when 2 => v.HndlWinBytes := '0' & CtxWin_Resp.RdatLo; -- guard bit required for calculations
|
||||
when 2 => v.HndlWinBytes := '0' & ShiftLeft(CtxWin_Resp.RdatLo, log2(StreamWidth_g(r.HndlStream)/8)); -- guard bit required for calculations
|
||||
when others => null;
|
||||
end case;
|
||||
|
||||
-- *** Calculate next access ***
|
||||
when CalcAccess0_s =>
|
||||
-- Mark stream as active
|
||||
v.OpenCommand(r.HndlStream) := '1';
|
||||
-- Calculate Command
|
||||
v.Dma_Cmd.Address := r.HndlPtr;
|
||||
v.Dma_Cmd.Stream := r.HndlStream;
|
||||
@ -367,6 +366,8 @@ begin
|
||||
else
|
||||
v.State := CalcAccess1_s;
|
||||
v.NewBuffer(r.HndlStream) := '0';
|
||||
-- Mark stream as active
|
||||
v.OpenCommand(r.HndlStream) := '1';
|
||||
end if;
|
||||
|
||||
when CalcAccess1_s =>
|
||||
@ -389,14 +390,14 @@ begin
|
||||
v.HndlPtr := std_logic_vector(unsigned(r.HndlPtr) + unsigned(Dma_Resp.Size));
|
||||
v.State := NextWin_s;
|
||||
-- Update window information step 1
|
||||
v.HndlWinBytes := std_logic_vector(unsigned(r.HndlWinBytes) + unsigned(Dma_Resp.Size)/(StreamWidth_g(r.HndlStream)/8));
|
||||
v.HndlWinBytes := std_logic_vector(unsigned(r.HndlWinBytes) + unsigned(Dma_Resp.Size));
|
||||
|
||||
|
||||
-- Calculate next window to use
|
||||
when NextWin_s =>
|
||||
-- Switch to next window if required
|
||||
if ((r.HndlPtr = r.HndlWinEnd) and (r.HndlRingbuf = '1')) or
|
||||
(Dma_Resp.Trigger = '1') then
|
||||
assert unsigned(r.HndlPtr) <= unsigned(r.HndlWinEnd) report "###ERROR###: psi_ms_daq_daq_sm internal error, Pointer is beyond window end" severity error;
|
||||
if ((r.HndlPtr = r.HndlWinEnd) and (r.HndlRingbuf = '0')) or (Dma_Resp.Trigger = '1') then
|
||||
v.HndlWinDone := '1';
|
||||
v.NewBuffer(r.HndlStream) := '1';
|
||||
if r.HndlWincur = r.HndlWincnt then
|
||||
@ -409,6 +410,10 @@ begin
|
||||
v.HndlWinEnd := std_logic_vector(unsigned(r.HndlWinEnd) + unsigned(r.HndlWinSize));
|
||||
end if;
|
||||
end if;
|
||||
-- wraparound for ringbuffer case
|
||||
if (r.HndlPtr = r.HndlWinEnd) and (r.HndlRingbuf = '1') then
|
||||
v.HndlPtr := std_logic_vector(unsigned(r.HndlPtr) - unsigned(r.HndlWinSize));
|
||||
end if;
|
||||
-- Update window information step 2 (limit to maximum value)
|
||||
if unsigned(r.HndlWinBytes) > unsigned(r.HndlWinSize) then
|
||||
v.HndlWinBytes := '0' & r.HndlWinSize; -- value has a guard bit
|
||||
@ -451,7 +456,7 @@ begin
|
||||
v.CtxWin_Cmd.Sel := CtxWin_Sel_WincntWinlast_c;
|
||||
v.CtxWin_Cmd.WenLo := '1';
|
||||
v.CtxWin_Cmd.WenHi := '1';
|
||||
v.CtxWin_Cmd.WdatLo := r.HndlWinBytes(31 downto 0); -- cut-off guard bit
|
||||
v.CtxWin_Cmd.WdatLo := ShiftRight(r.HndlWinBytes(31 downto 0), log2(StreamWidth_g(r.HndlStream)/8)); -- cut-off guard bit and convert bytes to samples
|
||||
v.CtxWin_Cmd.WdatHi := r.HndlWinLast;
|
||||
when 1 =>
|
||||
-- Stream Memory
|
||||
|
@ -229,7 +229,7 @@ package body psi_ms_daq_daq_sm_tb_case_priorities is
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
end loop;
|
||||
for i in 0 to 3 loop
|
||||
ExpCtxUpdateAuto( Stream => StreamOrder_c(i), tfSize => Size4k_c,
|
||||
ExpCtxUpdateAuto( Stream => StreamOrder_c(i),
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
end loop;
|
||||
ProcDone(0) := '1';
|
||||
@ -244,12 +244,12 @@ package body psi_ms_daq_daq_sm_tb_case_priorities is
|
||||
ExpCtxReadAuto( Stream => 0,
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
-- Wait for response and schnedule next high prio command
|
||||
ExpCtxUpdateAuto( Stream => 3, tfSize => Size4k_c,
|
||||
ExpCtxUpdateAuto( Stream => 3,
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxReadAuto( Stream => 3,
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
-- Wait for response and schnedule next high prio command
|
||||
ExpCtxUpdateAuto( Stream => 0, tfSize => Size4k_c,
|
||||
ExpCtxUpdateAuto( Stream => 0,
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxReadAuto( Stream => 0,
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
@ -257,11 +257,11 @@ package body psi_ms_daq_daq_sm_tb_case_priorities is
|
||||
ExpCtxReadAuto( Stream => 1,
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
-- pending responses
|
||||
ExpCtxUpdateAuto( Stream => 3, tfSize => Size4k_c, Msg => "RobinLast3",
|
||||
ExpCtxUpdateAuto( Stream => 3, Msg => "RobinLast3",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxUpdateAuto( Stream => 0, tfSize => Size4k_c, Msg => "RobinLast0",
|
||||
ExpCtxUpdateAuto( Stream => 0, Msg => "RobinLast0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxUpdateAuto( Stream => 1, tfSize => Size4k_c, Msg => "RobinLast1",
|
||||
ExpCtxUpdateAuto( Stream => 1, Msg => "RobinLast1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ProcDone(0) := '1';
|
||||
|
||||
@ -274,20 +274,20 @@ package body psi_ms_daq_daq_sm_tb_case_priorities is
|
||||
ExpCtxReadAuto( Stream => 1, Msg => "Start LP0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
-- High-prio data available, so wait for high-prio response and restart transfer
|
||||
ExpCtxUpdateAuto( Stream => 0, tfSize => Size4k_c, Msg => "Finish HP0",
|
||||
ExpCtxUpdateAuto( Stream => 0, Msg => "Finish HP0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxReadAuto( Stream => 0, Msg => "Start HP1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
-- Low-prio data available, so wait for high-prio response and restart transfer
|
||||
ExpCtxUpdateAuto( Stream => 1, tfSize => Size4k_c, Msg => "Finish LP0",
|
||||
ExpCtxUpdateAuto( Stream => 1, Msg => "Finish LP0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxReadAuto( Stream => 1, Msg => "Start LP1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
-- Completion of last high prio transfer
|
||||
ExpCtxUpdateAuto( Stream => 0, tfSize => Size4k_c, Msg => "Finish HP1",
|
||||
ExpCtxUpdateAuto( Stream => 0, Msg => "Finish HP1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
-- Completion of last low prio transfer
|
||||
ExpCtxUpdateAuto( Stream => 1, tfSize => Size4k_c, Msg => "Finish LP1",
|
||||
ExpCtxUpdateAuto( Stream => 1, Msg => "Finish LP1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
|
||||
ProcDone(0) := '1';
|
||||
|
@ -439,6 +439,7 @@ package body psi_ms_daq_daq_sm_tb_case_single_simple is
|
||||
ExpCtxFullBurst( Stream => 1,
|
||||
BufStart => 16#01230000#,
|
||||
TfSize => 502,
|
||||
NextWin => true,
|
||||
WinSize => 502,
|
||||
PtrBefore => PtrStr1_v,
|
||||
SamplesWinBefore => 0,
|
||||
|
@ -73,7 +73,69 @@ package body psi_ms_daq_daq_sm_tb_case_single_window is
|
||||
signal Dma_Cmd_Vld : in std_logic;
|
||||
constant Generics_c : Generics_t) is
|
||||
begin
|
||||
assert false report "Case SINGLE_WINDOW Procedure CONTROL: No Content added yet!" severity warning;
|
||||
print(">> -- single window --");
|
||||
|
||||
-- Linear write with Overwrite
|
||||
print(">> Linear write with Overwrite");
|
||||
InitTestCase(Clk, Rst);
|
||||
TestCase := 0;
|
||||
ConfigureAuto( WinSize => 4096+128, Ringbuf => '0', Overwrite => '1', Wincnt => 0, Wincur => 0);
|
||||
Inp_Level(2) <= LvlThreshold_c;
|
||||
for i in 0 to 5 loop
|
||||
wait until rising_edge(Clk) and Dma_Cmd_Vld = '1';
|
||||
end loop;
|
||||
Inp_Level(2) <= (others => '0');
|
||||
ControlWaitCompl(Clk);
|
||||
|
||||
-- Ringbuf with overwrite
|
||||
print(">> Ringbuf with overwrite");
|
||||
InitTestCase(Clk, Rst);
|
||||
TestCase := 1;
|
||||
ConfigureAuto( WinSize => 4096+128, Ringbuf => '1', Overwrite => '1', Wincnt => 0, Wincur => 0);
|
||||
Inp_Level(2) <= LvlThreshold_c;
|
||||
for i in 0 to 5 loop
|
||||
wait until rising_edge(Clk) and Dma_Cmd_Vld = '1';
|
||||
end loop;
|
||||
Inp_Level(2) <= (others => '0');
|
||||
ControlWaitCompl(Clk);
|
||||
|
||||
-- Linear without overwrite, no trigger
|
||||
print(">> Linear without overwrite, no trigger");
|
||||
InitTestCase(Clk, Rst);
|
||||
TestCase := 2;
|
||||
ConfigureAuto( WinSize => 4096+128, Ringbuf => '0', Overwrite => '0', Wincnt => 0, Wincur => 0);
|
||||
Inp_Level(2) <= LvlThreshold_c;
|
||||
for i in 0 to 2 loop
|
||||
wait until rising_edge(Clk) and Dma_Cmd_Vld = '1';
|
||||
end loop;
|
||||
Inp_Level(2) <= (others => '0');
|
||||
ControlWaitCompl(Clk);
|
||||
|
||||
-- Linear without overwrite, trigger
|
||||
print(">> Linear without overwrite, trigger");
|
||||
InitTestCase(Clk, Rst);
|
||||
TestCase := 3;
|
||||
ConfigureAuto( WinSize => 4096+128, Ringbuf => '0', Overwrite => '0', Wincnt => 0, Wincur => 0);
|
||||
Inp_Level(2) <= LvlThreshold_c;
|
||||
for i in 0 to 1 loop
|
||||
wait until rising_edge(Clk) and Dma_Cmd_Vld = '1';
|
||||
end loop;
|
||||
Inp_Level(2) <= (others => '0');
|
||||
ControlWaitCompl(Clk);
|
||||
|
||||
-- Ringbuf without overwrite
|
||||
print(">> Ringbuf without overwrite");
|
||||
wait for 1 us;
|
||||
InitTestCase(Clk, Rst);
|
||||
TestCase := 4;
|
||||
ConfigureAuto( WinSize => 4096+128, Ringbuf => '1', Overwrite => '0', Wincnt => 0, Wincur => 0);
|
||||
Inp_Level(2) <= LvlThreshold_c;
|
||||
for i in 0 to 3 loop
|
||||
wait until rising_edge(Clk) and Dma_Cmd_Vld = '1';
|
||||
end loop;
|
||||
Inp_Level(2) <= (others => '0');
|
||||
ControlWaitCompl(Clk);
|
||||
|
||||
end procedure;
|
||||
|
||||
procedure dma_cmd (
|
||||
@ -82,7 +144,79 @@ package body psi_ms_daq_daq_sm_tb_case_single_window is
|
||||
signal Dma_Cmd_Vld : in std_logic;
|
||||
constant Generics_c : Generics_t) is
|
||||
begin
|
||||
assert false report "Case SINGLE_WINDOW Procedure DMA_CMD: No Content added yet!" severity warning;
|
||||
-- Linear write with Overwrite
|
||||
WaitForCase(0, Clk);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr0.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 128, Msg => "Wr0.1", NextWin => true,
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr1.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 128, Msg => "Wr1.1", NextWin => true,
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
PtrDma_v(2) := BufStart_c(2);
|
||||
--> Finished by trigger
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, ExeSize => 512, Msg => "Wr2.0", NextWin => true,
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
--> Next window on trigger
|
||||
PtrDma_v(2) := BufStart_c(2);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr3.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ProcDone(2) := '1';
|
||||
|
||||
-- Ringbuf with overwrite
|
||||
WaitForCase(1, Clk);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr0.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 128, Msg => "Wr0.1", NextWin => true,
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr1.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 128, Msg => "Wr1.1", NextWin => true,
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
PtrDma_v(2) := BufStart_c(2);
|
||||
--> Finished by trigger
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, ExeSize => 512, Msg => "Wr2.0", NextWin => true,
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
--> Next window on trigger
|
||||
PtrDma_v(2) := BufStart_c(2);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr3.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ProcDone(2) := '1';
|
||||
|
||||
-- Linear without overwrite, no trigger
|
||||
WaitForCase(2, Clk);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr0.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 128, Msg => "Wr0.1", NextWin => true,
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr1.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ProcDone(2) := '1';
|
||||
|
||||
-- Linear without overwrite, trigger
|
||||
WaitForCase(3, Clk);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, ExeSize => 4000, Msg => "Wr0.0", NextWin => true,
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr1.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ProcDone(2) := '1';
|
||||
|
||||
|
||||
-- Ringbuf without overwrite
|
||||
WaitForCase(4, Clk);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr0.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 128, Msg => "Wr0.1", NextWin => true,
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, ExeSize => 4000, Msg => "Wr0.2", NextWin => true,
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ExpectDmaCmdAuto( Stream => 2, MaxSize => 4096, Msg => "Wr1.0",
|
||||
Clk => Clk, Dma_Cmd => Dma_Cmd, Dma_Vld => Dma_Cmd_Vld);
|
||||
ProcDone(2) := '1';
|
||||
|
||||
|
||||
-- Ringbuf with odd framesize
|
||||
end procedure;
|
||||
|
||||
procedure dma_resp (
|
||||
@ -92,7 +226,72 @@ package body psi_ms_daq_daq_sm_tb_case_single_window is
|
||||
signal Dma_Resp_Rdy : in std_logic;
|
||||
constant Generics_c : Generics_t) is
|
||||
begin
|
||||
assert false report "Case SINGLE_WINDOW Procedure DMA_RESP: No Content added yet!" severity warning;
|
||||
-- Linear write with Overwrite
|
||||
WaitForCase(0, Clk);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
--> Finished by trigger
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '1',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
--> Next window on trigger
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ProcDone(1) := '1';
|
||||
|
||||
-- Ringbuf with overwrite
|
||||
WaitForCase(1, Clk);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
--> Finished by trigger
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '1',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
--> Next window on trigger
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ProcDone(1) := '1';
|
||||
|
||||
-- Linear without overwrite, no trigger
|
||||
WaitForCase(2, Clk);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ProcDone(1) := '1';
|
||||
|
||||
-- Linear without overwrite, trigger
|
||||
WaitForCase(3, Clk);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '1',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ProcDone(1) := '1';
|
||||
|
||||
-- Ringbuf without overwrite
|
||||
WaitForCase(4, Clk);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '1',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ApplyDmaRespAuto( Stream => 2, Trigger => '0',
|
||||
Clk => Clk, Dma_Resp => Dma_Resp, Dma_Resp_Vld => Dma_Resp_Vld, Dma_Resp_Rdy => Dma_Resp_Rdy);
|
||||
ProcDone(1) := '1';
|
||||
|
||||
end procedure;
|
||||
|
||||
procedure ctx (
|
||||
@ -103,7 +302,85 @@ package body psi_ms_daq_daq_sm_tb_case_single_window is
|
||||
signal CtxWin_Resp : inout FromCtx_t;
|
||||
constant Generics_c : Generics_t) is
|
||||
begin
|
||||
assert false report "Case SINGLE_WINDOW Procedure CTX: No Content added yet!" severity warning;
|
||||
-- Linear write with Overwrite
|
||||
WaitForCase(0, Clk);
|
||||
ExpCtxFullBurstAuto( Stream => 2 ,Msg => "Wr0.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, NextWin => true, Msg => "Wr0.1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, Msg => "Wr1.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, NextWin => true, Msg => "Wr1.1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, NextWin => true, Msg => "Wr2.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, Msg => "Wr3.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ProcDone(0) := '1';
|
||||
|
||||
-- Ringbuf with overwrite
|
||||
WaitForCase(1, Clk);
|
||||
ExpCtxFullBurstAuto( Stream => 2 ,Msg => "Wr0.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, NextWin => true, Msg => "Wr0.1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, Msg => "Wr1.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, NextWin => true, Msg => "Wr1.1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, NextWin => true, Msg => "Wr2.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, Msg => "Wr3.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ProcDone(0) := '1';
|
||||
|
||||
-- Linear without overwrite, no trigger
|
||||
WaitForCase(2, Clk);
|
||||
ExpCtxFullBurstAuto( Stream => 2 ,Msg => "Wr0.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, NextWin => true, Msg => "Wr0.1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxReadAuto( Stream => 2, Msg => "SW not ready 0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxReadAuto( Stream => 2, Msg => "SW not ready 1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
SplsWinStr_v(2)(0) := 0;
|
||||
ExpCtxFullBurstAuto( Stream => 2 ,Msg => "SW ready",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ProcDone(0) := '1';
|
||||
|
||||
-- Linear without overwrite, trigger
|
||||
WaitForCase(3, Clk);
|
||||
ExpCtxFullBurstAuto( Stream => 2, NextWin => true, Msg => "Wr0.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxReadAuto( Stream => 2, Msg => "SW not ready 0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxReadAuto( Stream => 2, Msg => "SW not ready 1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
SplsWinStr_v(2)(0) := 0;
|
||||
ExpCtxFullBurstAuto( Stream => 2 ,Msg => "SW ready",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ProcDone(0) := '1';
|
||||
|
||||
-- Ringbuf without overwrite
|
||||
WaitForCase(4, Clk);
|
||||
ExpCtxFullBurstAuto( Stream => 2 ,Msg => "Wr0.0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, Msg => "Wr0.1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxFullBurstAuto( Stream => 2, Msg => "Wr0.3", NextWin => true,
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxReadAuto( Stream => 2, Msg => "SW not ready 0",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ExpCtxReadAuto( Stream => 2, Msg => "SW not ready 1",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
SplsWinStr_v(2)(0) := 0;
|
||||
ExpCtxFullBurstAuto( Stream => 2 ,Msg => "SW ready",
|
||||
Clk => Clk, CtxStr_Cmd => CtxStr_Cmd, CtxStr_Resp => CtxStr_Resp, CtxWin_Cmd => CtxWin_Cmd, CtxWin_Resp => CtxWin_Resp);
|
||||
ProcDone(0) := '1';
|
||||
|
||||
|
||||
-- Ringbuf with odd framesize
|
||||
end procedure;
|
||||
|
||||
end;
|
||||
|
@ -38,6 +38,7 @@ package psi_ms_daq_daq_sm_tb_pkg is
|
||||
constant Size4k_c : positive := 4096;
|
||||
constant DataWidth_c : positive := 64;
|
||||
constant DataWidthBytes_c : positive := DataWidth_c/8;
|
||||
constant LvlThreshold_c : std_logic_vector(15 downto 0) := std_logic_vector(to_unsigned(Size4k_c/DataWidthBytes_c, 16));
|
||||
|
||||
shared variable TestCase : integer := -1;
|
||||
shared variable ProcDone : std_logic_vector(0 to 2) := "000";
|
||||
@ -79,6 +80,7 @@ package psi_ms_daq_daq_sm_tb_pkg is
|
||||
Overwrite : in std_logic := '0';
|
||||
Wincnt : in integer := 2;
|
||||
Wincur : in integer := 0;
|
||||
WinNext : in integer := -1;
|
||||
SamplesWin : in integer;
|
||||
WinLast : in integer;
|
||||
WriteTs : in boolean := false;
|
||||
@ -90,6 +92,7 @@ package psi_ms_daq_daq_sm_tb_pkg is
|
||||
|
||||
procedure ExpCtxUpdate( Stream : in integer;
|
||||
TfSize : in integer; -- in bytes
|
||||
NextWin : in boolean := false;
|
||||
BufStart : in integer := 16#01230000#;
|
||||
WinSize : in integer := 16#00100000#;
|
||||
PtrBefore : in integer := 16#01238000#;
|
||||
@ -110,6 +113,7 @@ package psi_ms_daq_daq_sm_tb_pkg is
|
||||
|
||||
procedure ExpCtxFullBurst( Stream : in integer;
|
||||
TfSize : in integer; -- in bytes
|
||||
NextWin : in boolean := false;
|
||||
BufStart : in integer := 16#01230000#;
|
||||
WinSize : in integer := 16#00100000#;
|
||||
PtrBefore : in integer := 16#01238000#;
|
||||
@ -148,17 +152,20 @@ package psi_ms_daq_daq_sm_tb_pkg is
|
||||
Msg : in string := "");
|
||||
|
||||
-- higher level functions
|
||||
shared variable PtrStr_v : t_ainteger(0 to 3);
|
||||
shared variable PtrDma_v : t_ainteger(0 to 3);
|
||||
shared variable SplsStr_v : t_ainteger(0 to 3);
|
||||
constant BufStart_c : t_ainteger(0 to 3) := (16#01230000#, 16#02230000#, 16#03230000#, 16#04230000#);
|
||||
type IntStrWin_t is array (0 to 3) of t_ainteger(0 to 31);
|
||||
shared variable PtrStr_v : t_ainteger(0 to 3);
|
||||
shared variable PtrDma_v : t_ainteger(0 to 3);
|
||||
shared variable SplsWinStr_v : IntStrWin_t;
|
||||
constant BufStart_c : t_ainteger(0 to 3) := (16#01230000#, 16#02230000#, 16#03230000#, 16#04230000#);
|
||||
|
||||
shared variable AutoWinSize_v : integer;
|
||||
shared variable AutoRingbuf_v : std_logic;
|
||||
shared variable AutoOverwrite_v : std_logic;
|
||||
shared variable AutoWincnt_v : integer;
|
||||
shared variable AutoWincur_v : t_ainteger(0 to 3);
|
||||
shared variable AutoAccessSize_v : t_ainteger(0 to 3);
|
||||
|
||||
procedure ExpCtxReadAuto( Stream : in integer;
|
||||
WinSize : in integer := 16#00100000#;
|
||||
Ringbuf : in std_logic := '0';
|
||||
Overwrite : in std_logic := '0';
|
||||
Wincnt : in integer := 2;
|
||||
Wincur : in integer := 0;
|
||||
signal Clk : in std_logic;
|
||||
signal CtxStr_Cmd : in ToCtxStr_t;
|
||||
signal CtxStr_Resp : out FromCtx_t;
|
||||
@ -167,12 +174,18 @@ package psi_ms_daq_daq_sm_tb_pkg is
|
||||
Msg : in string := "");
|
||||
|
||||
procedure ExpCtxUpdateAuto( Stream : in integer;
|
||||
TfSize : in integer; -- in bytes
|
||||
WinSize : in integer := 16#00100000#;
|
||||
Ringbuf : in std_logic := '0';
|
||||
Overwrite : in std_logic := '0';
|
||||
Wincnt : in integer := 2;
|
||||
Wincur : in integer := 0;
|
||||
NextWin : in boolean := false;
|
||||
WriteTs : in boolean := false;
|
||||
Timstamp : in std_logic_vector(63 downto 0) := (others => 'X');
|
||||
signal Clk : in std_logic;
|
||||
signal CtxStr_Cmd : in ToCtxStr_t;
|
||||
signal CtxStr_Resp : out FromCtx_t;
|
||||
signal CtxWin_Cmd : in ToCtxWin_t;
|
||||
signal CtxWin_Resp : out FromCtx_t;
|
||||
Msg : in string := "");
|
||||
|
||||
procedure ExpCtxFullBurstAuto( Stream : in integer;
|
||||
NextWin : in boolean := false;
|
||||
WriteTs : in boolean := false;
|
||||
Timstamp : in std_logic_vector(63 downto 0) := (others => 'X');
|
||||
signal Clk : in std_logic;
|
||||
@ -182,12 +195,29 @@ package psi_ms_daq_daq_sm_tb_pkg is
|
||||
signal CtxWin_Resp : out FromCtx_t;
|
||||
Msg : in string := "");
|
||||
|
||||
procedure ConfigureAuto( WinSize : in integer := 16#00100000#;
|
||||
Ringbuf : in std_logic := '0';
|
||||
Overwrite : in std_logic := '0';
|
||||
Wincnt : in integer := 2;
|
||||
Wincur : in integer := 0);
|
||||
|
||||
procedure ExpectDmaCmdAuto( Stream : in integer;
|
||||
MaxSize : in integer;
|
||||
ExeSize : in integer := -1;
|
||||
NextWin : in boolean := false;
|
||||
signal Clk : in std_logic;
|
||||
signal Dma_Cmd : in DaqSm2DaqDma_Cmd_t;
|
||||
signal Dma_Vld : in std_logic;
|
||||
Msg : in string := "");
|
||||
Msg : in string := "");
|
||||
|
||||
procedure ApplyDmaRespAuto( Stream : in integer;
|
||||
Trigger : in std_logic;
|
||||
Delay : in time := 0 ns;
|
||||
signal Clk : in std_logic;
|
||||
signal Dma_Resp : out DaqDma2DaqSm_Resp_t;
|
||||
signal Dma_Resp_Vld : out std_logic;
|
||||
signal Dma_Resp_Rdy : in std_logic;
|
||||
Msg : in string := "");
|
||||
|
||||
|
||||
end package;
|
||||
@ -200,12 +230,13 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
procedure InitTestCase( signal Clk : in std_logic;
|
||||
signal Rst : out std_logic) is
|
||||
begin
|
||||
ConfigureAuto;
|
||||
ProcDone := (others => '0');
|
||||
TestCase := -1;
|
||||
DmaCmdOpen := 0;
|
||||
PtrStr_v := BufStart_c;
|
||||
PtrDma_v := BufStart_c;
|
||||
SplsStr_v := (others => 0);
|
||||
SplsWinStr_v := (others => (others => 0));
|
||||
wait until rising_edge(Clk);
|
||||
Rst <= '1';
|
||||
wait until rising_edge(Clk);
|
||||
@ -293,6 +324,7 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
Overwrite : in std_logic := '0';
|
||||
Wincnt : in integer := 2;
|
||||
Wincur : in integer := 0;
|
||||
WinNext : in integer := -1;
|
||||
SamplesWin : in integer;
|
||||
WinLast : in integer;
|
||||
WriteTs : in boolean := false;
|
||||
@ -301,7 +333,15 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
signal CtxStr_Cmd : in ToCtxStr_t;
|
||||
signal CtxWin_Cmd : in ToCtxWin_t;
|
||||
Msg : in string := "") is
|
||||
|
||||
variable WinNext_v : integer;
|
||||
begin
|
||||
-- No window change by default
|
||||
if WinNext = 0 then
|
||||
WinNext_v := Wincur;
|
||||
else
|
||||
WinNext_v := WinNext;
|
||||
end if;
|
||||
wait until rising_edge(Clk) and CtxStr_Cmd.WenLo = '1';
|
||||
-- Stream
|
||||
IntCompare(Stream, CtxStr_Cmd.Stream, "ExpectContext.Str: Wrong stream number 0 - " & Msg);
|
||||
@ -309,20 +349,21 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
StdlCompare(0, CtxStr_Cmd.WenHi, "ExpectContext.Str: WenHi asserted in first cycle (BufStart overwritten) - " & Msg);
|
||||
StdlCompare(choose(Ringbuf='1',1,0), CtxStr_Cmd.WdatLo(CtxStr_Sft_SCFG_RINGBUF_c), "ExpectContext.Str: Wrong RINGBUFFER - " & Msg);
|
||||
StdlCompare(choose(Overwrite='1',1,0), CtxStr_Cmd.WdatLo(CtxStr_Sft_SCFG_OVERWRITE_c), "ExpectContext.Str: Wrong OVERWRITE - " & Msg);
|
||||
StdlvCompareInt(Wincnt, CtxStr_Cmd.WdatLo(CtxStr_Sft_SCFG_WINCNT_c+7 downto CtxStr_Sft_SCFG_WINCNT_c), "ExpectContext.Str: Wrong WINCNT - " & Msg);
|
||||
StdlvCompareInt(Wincur, CtxStr_Cmd.WdatLo(CtxStr_Sft_SCFG_WINCUR_c+7 downto CtxStr_Sft_SCFG_WINCUR_c), "ExpectContext.Str: Wrong WINCUR - " & Msg);
|
||||
StdlvCompareInt(Wincnt, CtxStr_Cmd.WdatLo(CtxStr_Sft_SCFG_WINCNT_c+7 downto CtxStr_Sft_SCFG_WINCNT_c), "ExpectContext.Str: Wrong SCFG_WINCNT - " & Msg);
|
||||
StdlvCompareInt(WinNext_v, CtxStr_Cmd.WdatLo(CtxStr_Sft_SCFG_WINCUR_c+7 downto CtxStr_Sft_SCFG_WINCUR_c), "ExpectContext.Str: Wrong SCFG_WINCUR - " & Msg);
|
||||
-- Window
|
||||
IntCompare(Stream, CtxWin_Cmd.Stream, "ExpectContext.Win: Wrong stream number 0 - " & Msg);
|
||||
IntCompare(Wincur, CtxWin_Cmd.Window, "ExpectContext.Win: Wrong Window number 0 - " & Msg);
|
||||
StdlCompare(1, CtxWin_Cmd.WenLo, "ExpectContext.Win: WenLo not asserted in first cycle - " & Msg);
|
||||
StdlCompare(1, CtxWin_Cmd.WenHi, "ExpectContext.Win: WenHi not asserted in first cycle - " & Msg);
|
||||
StdlvCompareInt(SamplesWin, CtxWin_Cmd.WdatLo, "ExpectContext.Str: Wrong WINCNT - " & Msg);
|
||||
StdlvCompareInt(WinLast, CtxWin_Cmd.WdatHi, "ExpectContext.Str: Wrong WINLAST - " & Msg);
|
||||
StdlvCompareInt(SamplesWin, CtxWin_Cmd.WdatLo, "ExpectContext.Str: Wrong WIN_WINCNT - " & Msg);
|
||||
StdlvCompareInt(WinLast, CtxWin_Cmd.WdatHi, "ExpectContext.Str: Wrong WIN_WINLAST - " & Msg);
|
||||
wait until rising_edge(Clk) and CtxStr_Cmd.WenHi = '1';
|
||||
-- Stream
|
||||
IntCompare(Stream, CtxStr_Cmd.Stream, "ExpectContext.Str: Wrong stream number 1 - " & Msg);
|
||||
StdlvCompareStdlv(CtxStr_Sel_WinsizePtr_c, CtxStr_Cmd.Sel, "ExpectContext.Str: Wrong Sel (unexpected sequence 1) - " & Msg);
|
||||
StdlCompare(0, CtxStr_Cmd.WenLo, "ExpectContext.Str: WenLo asserted in second cycle (WinSize overwritten) - " & Msg);
|
||||
StdlvCompareInt(Ptr, CtxStr_Cmd.WdatHi, "ExpectContext.Str: Wrong WINCNT - " & Msg);
|
||||
StdlvCompareInt(Ptr, CtxStr_Cmd.WdatHi, "ExpectContext.Str: Wrong PTR - " & Msg);
|
||||
wait until rising_edge(Clk) and CtxStr_Cmd.WenLo = '1';
|
||||
if WriteTs then
|
||||
IntCompare(Stream, CtxWin_Cmd.Stream, "ExpectContext.Win: Wrong stream number 1 - " & Msg);
|
||||
@ -338,11 +379,12 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
IntCompare(Stream, CtxStr_Cmd.Stream, "ExpectContext.Str: Wrong stream number 2 - " & Msg);
|
||||
StdlvCompareStdlv(CtxStr_Sel_Winend_c, CtxStr_Cmd.Sel, "ExpectContext.Str: Wrong Sel (unexpected sequence 2) - " & Msg);
|
||||
StdlCompare(0, CtxStr_Cmd.WenHi, "ExpectContext.Str: WenHi asserted in third cycle (Unused overwritten) - " & Msg);
|
||||
StdlvCompareInt(BufStart+WinSize*(Wincur+1), CtxStr_Cmd.WdatLo, "ExpectContext.Str: Wrong WINEND - " & Msg);
|
||||
StdlvCompareInt(BufStart+WinSize*(WinNext_v+1), CtxStr_Cmd.WdatLo, "ExpectContext.Str: Wrong WINEND - " & Msg);
|
||||
end procedure;
|
||||
|
||||
procedure ExpCtxUpdate( Stream : in integer;
|
||||
TfSize : in integer; -- in bytes
|
||||
NextWin : in boolean := false;
|
||||
BufStart : in integer := 16#01230000#;
|
||||
WinSize : in integer := 16#00100000#;
|
||||
PtrBefore : in integer := 16#01238000#;
|
||||
@ -364,6 +406,7 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
variable SampleswinAfter_v : integer;
|
||||
variable WinLastAfter_v : integer;
|
||||
constant StrWidthBytes_c : integer := StreamWidth_g(Stream)/8;
|
||||
variable WinAfter_v : integer;
|
||||
begin
|
||||
-- Calculations
|
||||
PtrAfter_v := PtrBefore + TfSize;
|
||||
@ -372,6 +415,23 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
SampleswinAfter_v := WinSize/StrWidthBytes_c;
|
||||
end if;
|
||||
WinLastAfter_v := PtrBefore + TfSize - StrWidthBytes_c;
|
||||
if NextWin then
|
||||
if Wincur = Wincnt then
|
||||
WinAfter_v := 0;
|
||||
else
|
||||
WinAfter_v := Wincur + 1;
|
||||
end if;
|
||||
PtrAfter_v := BufStart+WinAfter_v*WinSize;
|
||||
else
|
||||
WinAfter_v := Wincur;
|
||||
-- wraparound for ringbuffer
|
||||
if Ringbuf = '1' then
|
||||
if PtrAfter_v >= BufStart + (Wincur+1)*WinSize then
|
||||
PtrAfter_v := PtrAfter_v - WinSize;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- Read
|
||||
ExpCtxRead( Stream => Stream,
|
||||
BufStart => BufStart,
|
||||
@ -397,6 +457,7 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
Overwrite => Overwrite,
|
||||
Wincnt => Wincnt,
|
||||
Wincur => Wincur,
|
||||
WinNext => WinAfter_v,
|
||||
SamplesWin => SampleswinAfter_v,
|
||||
WinLast => WinLastAfter_v,
|
||||
WriteTs => WriteTs,
|
||||
@ -411,6 +472,7 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
|
||||
procedure ExpCtxFullBurst( Stream : in integer;
|
||||
TfSize : in integer; -- in bytes
|
||||
NextWin : in boolean := false;
|
||||
BufStart : in integer := 16#01230000#;
|
||||
WinSize : in integer := 16#00100000#;
|
||||
PtrBefore : in integer := 16#01238000#;
|
||||
@ -448,6 +510,7 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
-- context update
|
||||
ExpCtxUpdate( Stream => Stream,
|
||||
TfSize => TfSize,
|
||||
NextWin => NextWin,
|
||||
BufStart => BufStart,
|
||||
WinSize => WinSize,
|
||||
PtrBefore => PtrBefore,
|
||||
@ -498,8 +561,6 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
wait until rising_edge(Clk);
|
||||
end loop;
|
||||
wait for Delay;
|
||||
-- Update DMA pointer for next expectation (only with xxxAuto functions)
|
||||
PtrDma_v(Stream) := PtrDma_v(Stream) + Size;
|
||||
-- Send response
|
||||
wait until rising_edge(Clk);
|
||||
Dma_Resp_Vld <= '1';
|
||||
@ -515,11 +576,6 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
end procedure;
|
||||
|
||||
procedure ExpCtxReadAuto( Stream : in integer;
|
||||
WinSize : in integer := 16#00100000#;
|
||||
Ringbuf : in std_logic := '0';
|
||||
Overwrite : in std_logic := '0';
|
||||
Wincnt : in integer := 2;
|
||||
Wincur : in integer := 0;
|
||||
signal Clk : in std_logic;
|
||||
signal CtxStr_Cmd : in ToCtxStr_t;
|
||||
signal CtxStr_Resp : out FromCtx_t;
|
||||
@ -529,13 +585,13 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
begin
|
||||
ExpCtxRead( Stream => Stream,
|
||||
BufStart => BufStart_c(Stream),
|
||||
WinSize => WinSize,
|
||||
WinSize => AutoWinSize_v,
|
||||
Ptr => PtrStr_v(Stream),
|
||||
Ringbuf => Ringbuf,
|
||||
Overwrite => Overwrite,
|
||||
Wincnt => Wincnt,
|
||||
Wincur => Wincur,
|
||||
SamplesWin => SplsStr_v(Stream),
|
||||
Ringbuf => AutoRingbuf_v,
|
||||
Overwrite => AutoOverwrite_v,
|
||||
Wincnt => AutoWincnt_v,
|
||||
Wincur => AutoWincur_v(Stream),
|
||||
SamplesWin => SplsWinStr_v(Stream)(AutoWincur_v(Stream)),
|
||||
Clk => Clk,
|
||||
CtxStr_Cmd => CtxStr_Cmd,
|
||||
CtxStr_Resp => CtxStr_Resp,
|
||||
@ -545,12 +601,7 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
end procedure;
|
||||
|
||||
procedure ExpCtxUpdateAuto( Stream : in integer;
|
||||
TfSize : in integer; -- in bytes
|
||||
WinSize : in integer := 16#00100000#;
|
||||
Ringbuf : in std_logic := '0';
|
||||
Overwrite : in std_logic := '0';
|
||||
Wincnt : in integer := 2;
|
||||
Wincur : in integer := 0;
|
||||
NextWin : in boolean := false;
|
||||
WriteTs : in boolean := false;
|
||||
Timstamp : in std_logic_vector(63 downto 0) := (others => 'X');
|
||||
signal Clk : in std_logic;
|
||||
@ -560,16 +611,20 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
signal CtxWin_Resp : out FromCtx_t;
|
||||
Msg : in string := "") is
|
||||
begin
|
||||
while DmaCmdOpen = 0 loop
|
||||
wait until rising_edge(Clk);
|
||||
end loop;
|
||||
ExpCtxUpdate( Stream => Stream,
|
||||
TfSize => TfSize,
|
||||
TfSize => AutoAccessSize_v(Stream),
|
||||
NextWin => NextWin,
|
||||
BufStart => BufStart_c(Stream),
|
||||
WinSize => WinSize,
|
||||
WinSize => AutoWinSize_v,
|
||||
PtrBefore => PtrStr_v(Stream),
|
||||
Ringbuf => Ringbuf,
|
||||
Overwrite => Overwrite,
|
||||
Wincnt => Wincnt,
|
||||
Wincur => Wincur,
|
||||
SamplesWinBefore => SplsStr_v(Stream),
|
||||
Ringbuf => AutoRingbuf_v,
|
||||
Overwrite => AutoOverwrite_v,
|
||||
Wincnt => AutoWincnt_v,
|
||||
Wincur => AutoWincur_v(Stream),
|
||||
SamplesWinBefore => SplsWinStr_v(Stream)(AutoWincur_v(Stream)),
|
||||
WriteTs => WriteTs,
|
||||
Timstamp => Timstamp,
|
||||
PtrAfter => PtrStr_v(Stream),
|
||||
@ -579,22 +634,135 @@ package body psi_ms_daq_daq_sm_tb_pkg is
|
||||
CtxWin_Cmd => CtxWin_Cmd,
|
||||
CtxWin_Resp => CtxWin_Resp,
|
||||
Msg => Msg);
|
||||
SplsWinStr_v(Stream)(AutoWincur_v(Stream)) := work.psi_common_math_pkg.min(AutoWinSize_v/(StreamWidth_g(Stream)/8), SplsWinStr_v(Stream)(AutoWincur_v(Stream))+AutoAccessSize_v(Stream)/(StreamWidth_g(Stream)/8));
|
||||
if NextWin then
|
||||
if AutoWincur_v(Stream) = AutoWincnt_v then
|
||||
AutoWincur_v(Stream) := 0;
|
||||
else
|
||||
AutoWincur_v(Stream) := AutoWincur_v(Stream) + 1;
|
||||
end if;
|
||||
else
|
||||
-- wraparound for ringbuffer case
|
||||
if (PtrStr_v(Stream) - BufStart_c(Stream) > AutoWinSize_v) then
|
||||
report "###ERROR### TB assertion, unhandled window crossing" severity error;
|
||||
elsif (PtrStr_v(Stream) - BufStart_c(Stream) = AutoWinSize_v) then
|
||||
if AutoRingbuf_v = '1' then
|
||||
PtrStr_v(Stream) := BufStart_c(Stream);
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
end procedure;
|
||||
|
||||
procedure ExpCtxFullBurstAuto( Stream : in integer;
|
||||
NextWin : in boolean := false;
|
||||
WriteTs : in boolean := false;
|
||||
Timstamp : in std_logic_vector(63 downto 0) := (others => 'X');
|
||||
signal Clk : in std_logic;
|
||||
signal CtxStr_Cmd : in ToCtxStr_t;
|
||||
signal CtxStr_Resp : out FromCtx_t;
|
||||
signal CtxWin_Cmd : in ToCtxWin_t;
|
||||
signal CtxWin_Resp : out FromCtx_t;
|
||||
Msg : in string := "") is
|
||||
begin
|
||||
ExpCtxReadAuto( Stream => Stream,
|
||||
Clk => Clk,
|
||||
CtxStr_Cmd => CtxStr_Cmd,
|
||||
CtxStr_Resp => CtxStr_Resp,
|
||||
CtxWin_Cmd => CtxWin_Cmd,
|
||||
CtxWin_Resp => CtxWin_Resp,
|
||||
Msg => Msg);
|
||||
ExpCtxUpdateAuto( Stream => Stream,
|
||||
NextWin => NextWin,
|
||||
WriteTs => WriteTs,
|
||||
Timstamp => Timstamp,
|
||||
Clk => Clk,
|
||||
CtxStr_Cmd => CtxStr_Cmd,
|
||||
CtxStr_Resp => CtxStr_Resp,
|
||||
CtxWin_Cmd => CtxWin_Cmd,
|
||||
CtxWin_Resp => CtxWin_Resp,
|
||||
Msg => Msg);
|
||||
end procedure;
|
||||
|
||||
procedure ConfigureAuto( WinSize : in integer := 16#00100000#;
|
||||
Ringbuf : in std_logic := '0';
|
||||
Overwrite : in std_logic := '0';
|
||||
Wincnt : in integer := 2;
|
||||
Wincur : in integer := 0) is
|
||||
begin
|
||||
AutoWinSize_v := WinSize;
|
||||
AutoRingbuf_v := Ringbuf;
|
||||
AutoOverwrite_v := Overwrite;
|
||||
AutoWincnt_v := Wincnt;
|
||||
AutoWincur_v := (others => Wincur);
|
||||
end procedure;
|
||||
|
||||
procedure ExpectDmaCmdAuto( Stream : in integer;
|
||||
MaxSize : in integer;
|
||||
ExeSize : in integer := -1;
|
||||
NextWin : in boolean := false;
|
||||
signal Clk : in std_logic;
|
||||
signal Dma_Cmd : in DaqSm2DaqDma_Cmd_t;
|
||||
signal Dma_Vld : in std_logic;
|
||||
Msg : in string := "") is
|
||||
variable ExeSize_v : integer;
|
||||
variable NextWinNr_v : integer;
|
||||
begin
|
||||
if ExeSize = -1 then
|
||||
ExeSize_v := MaxSize;
|
||||
else
|
||||
ExeSize_v := ExeSize;
|
||||
end if;
|
||||
ExpectDmaCmd( Stream => Stream,
|
||||
Address => PtrDma_v(Stream),
|
||||
MaxSize => MaxSize,
|
||||
Clk => Clk,
|
||||
Dma_Cmd => Dma_Cmd,
|
||||
Dma_Vld => Dma_Vld,
|
||||
Msg => Msg);
|
||||
Msg => Msg);
|
||||
if NextWin then
|
||||
if AutoWincur_v(Stream) = AutoWincnt_v then
|
||||
NextWinNr_v := 0;
|
||||
else
|
||||
NextWinNr_v := AutoWincur_v(Stream) + 1;
|
||||
end if;
|
||||
PtrDma_v(Stream) := BufStart_c(Stream) + NextWinNr_v*AutoWinSize_v;
|
||||
else
|
||||
PtrDma_v(Stream) := PtrDma_v(Stream) + ExeSize_v;
|
||||
-- wraparound for ringbuffer case
|
||||
if (PtrDma_v(Stream) - BufStart_c(Stream) > AutoWinSize_v) then
|
||||
report "###ERROR### TB assertion, unhandled window crossing" severity error;
|
||||
elsif (PtrDma_v(Stream) - BufStart_c(Stream) = AutoWinSize_v) then
|
||||
if AutoRingbuf_v = '1' then
|
||||
PtrDma_v(Stream) := BufStart_c(Stream);
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
AutoAccessSize_v(Stream) := ExeSize_v;
|
||||
end procedure;
|
||||
|
||||
procedure ApplyDmaRespAuto( Stream : in integer;
|
||||
Trigger : in std_logic;
|
||||
Delay : in time := 0 ns;
|
||||
signal Clk : in std_logic;
|
||||
signal Dma_Resp : out DaqDma2DaqSm_Resp_t;
|
||||
signal Dma_Resp_Vld : out std_logic;
|
||||
signal Dma_Resp_Rdy : in std_logic;
|
||||
Msg : in string := "") is
|
||||
begin
|
||||
while DmaCmdOpen = 0 loop
|
||||
wait until rising_edge(Clk);
|
||||
end loop;
|
||||
wait for 1 ps;
|
||||
ApplyDmaResp( Stream => Stream,
|
||||
Size => AutoAccessSize_v(Stream),
|
||||
Trigger => Trigger,
|
||||
Delay => Delay,
|
||||
Clk => Clk,
|
||||
Dma_Resp => Dma_Resp,
|
||||
Dma_Resp_Vld => Dma_Resp_Vld,
|
||||
Dma_Resp_Rdy => Dma_Resp_Rdy,
|
||||
Msg => Msg);
|
||||
end procedure;
|
||||
|
||||
end;
|
||||
|
Reference in New Issue
Block a user