Skip to content
Snippets Groups Projects
Commit 1e61213f authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Support dynamic pkt_len. Use busy to capture pkt_len. Support that last...

Support dynamic pkt_len. Use busy to capture pkt_len. Support that last unmerge packet can be shorter than pkt_len.
parent e158fc6c
No related branches found
No related tags found
1 merge request!357Move func_sdp_bdo_cep_hdr_field_sel_dest() from sdp_bdo_pkg to...
Pipeline #58564 passed
...@@ -22,13 +22,21 @@ ...@@ -22,13 +22,21 @@
-- Author: E. Kooistra -- Author: E. Kooistra
-- Purpose: Unmerge each input packet into output packets of length g_pkt_len. -- Purpose: Unmerge each input packet into output packets of length g_pkt_len.
-- Description: -- Description:
-- . The merged packet length of the snk_in input packets must be an integer -- . The merged packet length of the snk_in input packets is unmerged into
-- multiple of g_pkt_len. The number of output packets g_nof_pkt_max is only -- ceil(input packet length / pkt_len). The unmerged output packets have
-- used to determine the maximum supported pkt_cnt range. The actual number -- length pkt_len, but if input packet length mod pkt_len /= 0, then the
-- of output packets has to be <= g_nof_pkt_max, and is determined by input -- last packet will contain the remaining data of the input packet and have
-- packet length / g_pkt_len. Hence the dp_packet_unmerge can dynamically -- length < pkt_len. Corner cases:
-- handle different sizes of input packets, provided that their length is an -- - If pkt_len > input packet length, then the output = input
-- integer multiple of g_pkt_len. -- - The length of the last output packet is input packet length mod
-- pkt_len, so it can have minimal lenght 1.
-- . The dynamic pkt_len value is captured at the input eop, or between input
-- packets, to have a stable value during the unmerge.
-- . The number of output packets g_nof_pkt is only used to determine the
-- maximum supported pkt_cnt range. The actual number of output packets has
-- to be <= g_nof_pkt, and is determined by input packet length /
-- pkt_len. Hence the dp_packet_unmerge can dynamically handle different
-- sizes of input packets.
-- . The pkt_cnt is passed on as src_out.channel index. -- . The pkt_cnt is passed on as src_out.channel index.
-- . The g_bsn_increment sets the BSN increment for the unmerged output -- . The g_bsn_increment sets the BSN increment for the unmerged output
-- packets relative to the BSN of the snk_in input packet. When -- packets relative to the BSN of the snk_in input packet. When
...@@ -51,6 +59,9 @@ ...@@ -51,6 +59,9 @@
-- --
-- . Optional flow control dependent on g_use_ready and g_pipeline_ready, see -- . Optional flow control dependent on g_use_ready and g_pipeline_ready, see
-- description of dp_add_flow_control. -- description of dp_add_flow_control.
-- . g_pkt_len statically sets the length of the unmerged packets in absence of
-- dynamic pkt_len control. When the pkt_len control input is used, g_pkt_len
-- sets the maximum number length of the unmerged packets.
library IEEE,common_lib; library IEEE,common_lib;
use IEEE.std_logic_1164.all; use IEEE.std_logic_1164.all;
...@@ -62,7 +73,7 @@ entity dp_packet_unmerge is ...@@ -62,7 +73,7 @@ entity dp_packet_unmerge is
generic ( generic (
g_use_ready : boolean := true; g_use_ready : boolean := true;
g_pipeline_ready : boolean := false; g_pipeline_ready : boolean := false;
g_nof_pkt_max : natural := 1; -- Maximum nof packets to unmerge each incoming packet to g_nof_pkt : natural := 1; -- Number of packets to unmerge each incoming packet to
g_pkt_len : natural := 1; -- Length of the unmerged packets g_pkt_len : natural := 1; -- Length of the unmerged packets
g_bsn_increment : natural := 0 g_bsn_increment : natural := 0
); );
...@@ -70,6 +81,9 @@ entity dp_packet_unmerge is ...@@ -70,6 +81,9 @@ entity dp_packet_unmerge is
rst : in std_logic; rst : in std_logic;
clk : in std_logic; clk : in std_logic;
pkt_len : in std_logic_vector(ceil_log2(g_pkt_len + 1) - 1 downto 0) := to_uvec(g_pkt_len, ceil_log2(g_pkt_len + 1));
pkt_len_out : out std_logic_vector(ceil_log2(g_pkt_len + 1) - 1 downto 0); -- Valid at src_out.sop
snk_out : out t_dp_siso; snk_out : out t_dp_siso;
snk_in : in t_dp_sosi; snk_in : in t_dp_sosi;
...@@ -79,20 +93,28 @@ entity dp_packet_unmerge is ...@@ -79,20 +93,28 @@ entity dp_packet_unmerge is
end dp_packet_unmerge; end dp_packet_unmerge;
architecture rtl of dp_packet_unmerge is architecture rtl of dp_packet_unmerge is
constant c_nof_pkt_max : natural := g_nof_pkt + 1;
constant c_pkt_len_max : natural := g_pkt_len + 1;
constant c_pkt_len_w : natural := ceil_log2(c_pkt_len_max);
-- Internal state of logic function -- Internal state of logic function
type t_reg is record type t_reg is record
pkt_cnt : natural range 0 to g_nof_pkt_max + 1; pkt_cnt : natural range 0 to c_nof_pkt_max;
val_cnt : natural range 0 to g_pkt_len + 1; pkt_len : natural range 0 to c_pkt_len_max;
val_cnt : natural range 0 to c_pkt_len_max;
busy : std_logic;
src_out : t_dp_sosi; src_out : t_dp_sosi;
end record; end record;
constant c_reg_rst : t_reg := (0, 0, c_dp_sosi_rst); constant c_reg_rst : t_reg := (0, 0, 0, '0', c_dp_sosi_rst);
signal r : t_reg; signal r : t_reg;
signal d : t_reg; signal d : t_reg;
begin begin
-- Map logic function outputs to entity outputs -- Map logic function outputs to entity outputs
pkt_len_out <= to_uvec(r.pkt_len, c_pkt_len_w);
u_dp_add_flow_control : entity work.dp_add_flow_control u_dp_add_flow_control : entity work.dp_add_flow_control
generic map ( generic map (
g_use_ready => g_use_ready, g_use_ready => g_use_ready,
...@@ -114,19 +136,19 @@ begin ...@@ -114,19 +136,19 @@ begin
r <= d when rising_edge(clk); r <= d when rising_edge(clk);
-- Logic function -- Logic function
p_comb : process(rst, r, snk_in) p_comb : process(rst, r, snk_in, pkt_len)
variable v : t_reg; variable v : t_reg;
begin begin
-- Default -- Default
v := r; v := r;
-- Function -- Function: unmerge input packet into output packets
-- _ _ _ -- _ _ _
-- snk_in.sop __| |_______________| |_______________| |_______________| -- snk_in.sop __| |_______________| |_______________| |_______________|
-- _ _ _ -- _ _ _
-- snk_in.eop _________________| |_______________| |_______________| |_ -- snk_in.eop _________________| |_______________| |_______________| |_
-- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
-- snk_in.valid __| -- snk_in.valid __|
-- v.val_cnt 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 -- v.val_cnt 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
-- v.pkt_cnt 0 1 2 0 1 2 0 1 2 -- v.pkt_cnt 0 1 2 0 1 2 0 1 2
-- ______________ _______________ _______________ _ -- ______________ _______________ _______________ _
...@@ -154,6 +176,18 @@ begin ...@@ -154,6 +176,18 @@ begin
v.pkt_cnt := r.pkt_cnt + 1; v.pkt_cnt := r.pkt_cnt + 1;
end if; end if;
-- capture pkt_len between input packets when there is no unmerge busy
if snk_in.sop = '1' then
v.busy := '1';
end if;
if snk_in.eop = '1' then
v.busy := '0';
end if;
if v.busy = '0' then
v.pkt_len := to_uint(pkt_len);
end if;
-- output packet bsn, sync, sop and eop -- output packet bsn, sync, sop and eop
-- . Default passes on snk_in.sync, valid, data, re, im -- . Default passes on snk_in.sync, valid, data, re, im
-- . The sync, valid can be passed on from snk_in, without checking -- . The sync, valid can be passed on from snk_in, without checking
...@@ -173,7 +207,12 @@ begin ...@@ -173,7 +207,12 @@ begin
if v.val_cnt = 0 then if v.val_cnt = 0 then
v.src_out.sop := '1'; v.src_out.sop := '1';
end if; end if;
if v.val_cnt = g_pkt_len - 1 then -- Unmerge packets of length r.pkt_len
if v.val_cnt = r.pkt_len - 1 then
v.src_out.eop := '1';
end if;
-- Unmerge last packet with length <= r.pkt_len
if snk_in.eop = '1' then
v.src_out.eop := '1'; v.src_out.eop := '1';
end if; end if;
end if; end if;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment