TIMING: Timing optimization for pointer calculation

This commit is contained in:
Oliver Bruendler
2018-07-11 14:22:43 +02:00
parent 1a77b43b39
commit 2411504ff0

View File

@ -152,7 +152,9 @@ architecture rtl of psi_ms_daq_daq_sm is
HndlWincur : std_logic_vector(log2ceil(Windows_g)-1 downto 0);
HndlBufstart : std_logic_vector(31 downto 0);
HndlWinSize : std_logic_vector(31 downto 0);
HndlPtr : std_logic_vector(31 downto 0);
HndlPtr0 : std_logic_vector(31 downto 0);
HndlPtr1 : std_logic_vector(31 downto 0);
HndlPtr2 : std_logic_vector(31 downto 0);
HndlLevel : std_logic_vector(15 downto 0);
Hndl4kMax : std_logic_vector(12 downto 0);
HndlWinMax : std_logic_vector(31 downto 0);
@ -337,14 +339,14 @@ begin
case r.HndlCtxCnt is
when 2 => v.HndlWinEnd := CtxStr_Resp.RdatLo;
when 3 => v.HndlWinSize := CtxStr_Resp.RdatLo;
v.HndlPtr := CtxStr_Resp.RdatHi;
v.HndlPtr0 := CtxStr_Resp.RdatHi;
when 4 => v.HndlRingbuf := CtxStr_Resp.RdatLo(CtxStr_Sft_SCFG_RINGBUF_c);
v.HndlOverwrite := CtxStr_Resp.RdatLo(CtxStr_Sft_SCFG_OVERWRITE_c);
v.HndlWincnt := CtxStr_Resp.RdatLo(CtxStr_Sft_SCFG_WINCNT_c+v.HndlWincnt'high downto CtxStr_Sft_SCFG_WINCNT_c);
v.HndlWincur := CtxStr_Resp.RdatLo(CtxStr_Sft_SCFG_WINCUR_c+v.HndlWincur'high downto CtxStr_Sft_SCFG_WINCUR_c);
v.HndlBufstart := CtxStr_Resp.RdatHi;
v.Hndl4kMax := std_logic_vector(to_unsigned(4096, 13) - unsigned(r.HndlPtr(11 downto 0))); -- Calculate maximum size within this 4k Region
v.HndlWinMax := std_logic_vector(unsigned(r.HndlWinEnd) - unsigned(r.HndlPtr)); -- Calculate maximum size within this window
v.Hndl4kMax := std_logic_vector(to_unsigned(4096, 13) - unsigned(r.HndlPtr0(11 downto 0))); -- Calculate maximum size within this 4k Region
v.HndlWinMax := std_logic_vector(unsigned(r.HndlWinEnd) - unsigned(r.HndlPtr0)); -- Calculate maximum size within this window
when others => null;
end case;
@ -364,7 +366,7 @@ begin
-- Update values for first access
if v.FirstOngoing(r.HndlStream) = '1' then
v.HndlWinEnd := std_logic_vector(unsigned(r.HndlBufstart) + unsigned(r.HndlWinSize));
v.HndlPtr := r.HndlBufstart;
v.HndlPtr0 := r.HndlBufstart;
v.HndlWincur := (others => '0');
v.Hndl4kMax := std_logic_vector(to_unsigned(4096, 13) - unsigned(r.HndlBufstart(11 downto 0)));
v.HndlWinMax := r.HndlWinSize;
@ -398,7 +400,7 @@ begin
-- *** Calculate next access ***
when CalcAccess0_s =>
-- Calculate Command
v.Dma_Cmd.Address := r.HndlPtr;
v.Dma_Cmd.Address := r.HndlPtr0;
v.Dma_Cmd.Stream := r.HndlStream;
if unsigned(r.HndlLevel) > MaxBurstSize_g then
v.Dma_Cmd.MaxSize := std_logic_vector(to_unsigned(MaxBurstSize_g*8, v.Dma_Cmd.MaxSize'length)); -- 8 bytes per 64-bit QWORD
@ -434,7 +436,7 @@ begin
when ProcResp0_s =>
v.OpenCommand(r.HndlStream) := '0';
v.FirstOngoing(r.HndlStream) := '0';
v.HndlPtr := std_logic_vector(unsigned(r.HndlPtr) + unsigned(Dma_Resp.Size));
v.HndlPtr1 := std_logic_vector(unsigned(r.HndlPtr0) + 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));
@ -442,31 +444,33 @@ begin
-- Calculate next window to use
when NextWin_s =>
-- Default Values
v.HndlPtr2 := r.HndlPtr1;
-- Switch to next window if required
v.IrqFifoWrite := '1';
if ((r.HndlPtr = r.HndlWinEnd) and (r.HndlRingbuf = '0')) or (Dma_Resp.Trigger = '1') then
if ((r.HndlPtr1 = 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
v.HndlWincur := (others => '0');
v.HndlPtr := r.HndlBufstart;
v.HndlPtr2 := r.HndlBufstart;
v.HndlWinEnd := std_logic_vector(unsigned(r.HndlBufstart) + unsigned(r.HndlWinSize));
else
v.HndlWincur := std_logic_vector(unsigned(r.HndlWincur) + 1);
v.HndlPtr := r.HndlWinEnd;
v.HndlPtr2 := r.HndlWinEnd;
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));
if (r.HndlPtr1 = r.HndlWinEnd) and (r.HndlRingbuf = '1') then
v.HndlPtr2 := std_logic_vector(unsigned(r.HndlPtr1) - 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
end if;
-- Store address of last sample in window
v.HndlWinLast := std_logic_vector(unsigned(r.HndlPtr) - StreamWidth_g(r.HndlStream)/8);
v.HndlWinLast := std_logic_vector(unsigned(r.HndlPtr1) - StreamWidth_g(r.HndlStream)/8);
-- Latch timestamp
if (Dma_Resp.Trigger = '1') and (Ts_Vld(r.HndlStream) = '1') then
v.Ts_Rdy(r.HndlStream) := '1';
@ -509,7 +513,7 @@ begin
-- Stream Memory
v.CtxStr_Cmd.Sel := CtxStr_Sel_WinsizePtr_c;
v.CtxStr_Cmd.WenHi := '1';
v.CtxStr_Cmd.WdatHi := r.HndlPtr;
v.CtxStr_Cmd.WdatHi := r.HndlPtr2;
-- Window Memory
if r.HndlWinDone = '1' then
v.CtxWin_Cmd.Sel := CtxWin_Sel_WinTs_c;