Skip to content
Snippets Groups Projects
Commit 1db3492d authored by RoccoA97's avatar RoccoA97 Committed by Rocco Ardino
Browse files

New possible implementation of chunking (previous one not working...)

parent 272ea651
No related branches found
No related tags found
1 merge request!80Refactoring VCU128 project with "scouting pipelines" framework to allow multiple scouting sources on same board
...@@ -110,8 +110,8 @@ architecture Behavioral of packager is ...@@ -110,8 +110,8 @@ architecture Behavioral of packager is
signal s_axis_tuser_reg : std_logic_vector( 1 downto 0); signal s_axis_tuser_reg : std_logic_vector( 1 downto 0);
-- filler state type and signal -- filler state type and signal
type t_FillerState is (FILLING, DROPPING, STARTING); type t_FillerState is (FILLING, DROPPING);
signal fillerState : t_FillerState := STARTING; signal fillerState : t_FillerState;
---- counters ---- counters
-- orbits dropped (HBM almost full) -- orbits dropped (HBM almost full)
...@@ -139,6 +139,7 @@ architecture Behavioral of packager is ...@@ -139,6 +139,7 @@ architecture Behavioral of packager is
-- orbits per chunk -- orbits per chunk
signal orbits_per_chunk_v : integer; signal orbits_per_chunk_v : integer;
signal chunk_start_found : std_logic := '0';
-- packet header -- packet header
signal header_dout : std_logic_vector(255 downto 0) := (others => '0'); signal header_dout : std_logic_vector(255 downto 0) := (others => '0');
...@@ -205,7 +206,7 @@ begin ...@@ -205,7 +206,7 @@ begin
if (rst = '1') then if (rst = '1') then
-- after reset, the FSM should wait for chunk start -- after reset, the FSM should wait for chunk start
-- thus we go into STARTING state after reset -- thus we go into STARTING state after reset
fillerState <= STARTING; fillerState <= FILLING;
-- orbit counters -- orbit counters
s_orbit_counter <= to_unsigned(0, 64); s_orbit_counter <= to_unsigned(0, 64);
s_dropped_orbit_counter <= to_unsigned(0, 64); s_dropped_orbit_counter <= to_unsigned(0, 64);
...@@ -236,6 +237,8 @@ begin ...@@ -236,6 +237,8 @@ begin
frag_header_dout <= (others => '0'); frag_header_dout <= (others => '0');
-- --
b_orbit_exceeds_size := false; b_orbit_exceeds_size := false;
-- chunk start found
chunk_start_found <= '0';
else else
...@@ -267,10 +270,18 @@ begin ...@@ -267,10 +270,18 @@ begin
frag_header_dout <= (others => '0'); frag_header_dout <= (others => '0');
-- START of chunk
if d_ctrl.header = '1' and chunk_start_found = '0' then
if (d(0)(30 downto 0) /= x"00000000") and (d(0)(orbits_per_chunk_v downto 0) = orbits_per_chunk(orbits_per_chunk_v downto 0)) then
chunk_start_found <= '1';
end if;
end if;
-- START of orbit -- START of orbit
-- d3 d2 d1 d0 -- d3 d2 d1 d0
-- header x 0 1 0 -- header x 0 1 0
if d_ctrl_d1.header = '1' then if d_ctrl_d1.header = '1' and chunk_start_found = '1' then
-- start counters from 1 -- start counters from 1
orbit_length_int <= to_unsigned(1, 64); orbit_length_int <= to_unsigned(1, 64);
s_orbit_length_cnt <= to_unsigned(1, 64); s_orbit_length_cnt <= to_unsigned(1, 64);
...@@ -282,7 +293,7 @@ begin ...@@ -282,7 +293,7 @@ begin
-- d3 d2 d1 d0 -- d3 d2 d1 d0
-- valid x 1 1 x -- valid x 1 1 x
-- strobe x x 1 x -- strobe x x 1 x
if d_ctrl_d1.valid = '1' and d_ctrl_d2.valid = '1' and d_ctrl_d1.strobe = '1' then if d_ctrl_d1.valid = '1' and d_ctrl_d2.valid = '1' and d_ctrl_d1.strobe = '1' and chunk_start_found = '1' then
-- increase counters -- increase counters
orbit_length_int <= orbit_length_int + 1; orbit_length_int <= orbit_length_int + 1;
s_orbit_length_cnt <= s_orbit_length_cnt + 1; s_orbit_length_cnt <= s_orbit_length_cnt + 1;
...@@ -305,7 +316,7 @@ begin ...@@ -305,7 +316,7 @@ begin
-- END of orbit -- END of orbit
-- d3 d2 d1 d0 -- d3 d2 d1 d0
-- last 0 1 0 x -- last 0 1 0 x
if d_ctrl_d2.last = '1' then if d_ctrl_d2.last = '1' and chunk_start_found = '1' then
orbit_length <= orbit_length_int; orbit_length <= orbit_length_int;
orbit_length_int <= to_unsigned(0, 64); orbit_length_int <= to_unsigned(0, 64);
s_orbit_length_cnt <= to_unsigned(0, 64); s_orbit_length_cnt <= to_unsigned(0, 64);
...@@ -335,7 +346,7 @@ begin ...@@ -335,7 +346,7 @@ begin
s_axi_backpressure_seen <= '1'; s_axi_backpressure_seen <= '1';
end if; end if;
s_axis_tvalid <= d_ctrl_d1.valid and d_ctrl_d1.strobe; s_axis_tvalid <= d_ctrl_d1.valid and d_ctrl_d1.strobe and chunk_start_found;
s_axis_tdata <= (others => '0'); s_axis_tdata <= (others => '0');
for i in d'range loop for i in d'range loop
...@@ -356,7 +367,7 @@ begin ...@@ -356,7 +367,7 @@ begin
-- START of orbit -- START of orbit
-- d3 d2 d1 d0 -- d3 d2 d1 d0
-- header x 0 1 0 -- header x 0 1 0
if d_ctrl_d1.header = '1' then if d_ctrl_d1.header = '1' and chunk_start_found = '1' then
-- start of packet -- start of packet
if std_logic_vector(orbits_in_packet) = x"0000" then if std_logic_vector(orbits_in_packet) = x"0000" then
packet_length_int <= to_unsigned(1, 64); packet_length_int <= to_unsigned(1, 64);
...@@ -371,7 +382,7 @@ begin ...@@ -371,7 +382,7 @@ begin
-- strobe x x 1 x -- strobe x x 1 x
-- header x x 0 x -- header x x 0 x
-- last x x x x -- last x x x x
elsif (d_ctrl_d1.valid = '1' and d_ctrl_d1.strobe = '1') then elsif (d_ctrl_d1.valid = '1' and d_ctrl_d1.strobe = '1') and chunk_start_found = '1' then
packet_length_int <= packet_length_int + 1; packet_length_int <= packet_length_int + 1;
-- END of orbit -- END of orbit
...@@ -380,7 +391,7 @@ begin ...@@ -380,7 +391,7 @@ begin
-- strobe x 1 x x -- strobe x 1 x x
-- header x 0 0 x -- header x 0 0 x
-- last 0 1 0 x -- last 0 1 0 x
elsif d_ctrl_d2.last = '1' then elsif d_ctrl_d2.last = '1' and chunk_start_found = '1' then
-- ON-GOING packet -- ON-GOING packet
s_orbit_counter <= s_orbit_counter + 1; s_orbit_counter <= s_orbit_counter + 1;
if (orbits_in_packet < orbits_per_packet-1) then if (orbits_in_packet < orbits_per_packet-1) then
...@@ -388,7 +399,7 @@ begin ...@@ -388,7 +399,7 @@ begin
-- END of packet -- END of packet
else else
-- create packet trailer and write to fifo chain -- create packet trailer and write to fifo chain
s_axis_tvalid <= '1'; s_axis_tvalid <= '1' and chunk_start_found;
s_axis_tlast <= '1'; s_axis_tlast <= '1';
s_axis_tuser <= "01"; -- trailer s_axis_tuser <= "01"; -- trailer
s_axis_tdata <= std_logic_vector(s_orbit_counter + 1) & -- 64b orbits seen counter s_axis_tdata <= std_logic_vector(s_orbit_counter + 1) & -- 64b orbits seen counter
...@@ -409,7 +420,7 @@ begin ...@@ -409,7 +420,7 @@ begin
std_logic_vector(packet_length_int(31 downto 0)) & -- 32b packet length in frames std_logic_vector(packet_length_int(31 downto 0)) & -- 32b packet length in frames
source_id & -- 32b scouting source id source_id & -- 32b scouting source id
x"feedbeeffeedbeef"; -- 64b start of packet marker x"feedbeeffeedbeef"; -- 64b start of packet marker
header_wen <= '1'; header_wen <= '1' and chunk_start_found;
end if; end if;
-- create fragment header and send out -- create fragment header and send out
...@@ -421,7 +432,7 @@ begin ...@@ -421,7 +432,7 @@ begin
std_logic_vector(orbit_length_int(31 downto 0)) & -- 32b orbit length in frames std_logic_vector(orbit_length_int(31 downto 0)) & -- 32b orbit length in frames
x"0000" & -- 16b not yet used (flags?) x"0000" & -- 16b not yet used (flags?)
x"4648"; -- 16b start of fragment marker x"4648"; -- 16b start of fragment marker
frag_header_wen <= '1'; frag_header_wen <= '1' and chunk_start_found;
-- check if fifo is full to pass to DROPPING STATE -- check if fifo is full to pass to DROPPING STATE
if HBM_almost_full = '1' then if HBM_almost_full = '1' then
...@@ -460,33 +471,6 @@ begin ...@@ -460,33 +471,6 @@ begin
fillerState <= FILLING; fillerState <= FILLING;
end if; end if;
end if; end if;
---- FSM in STARTING state
when STARTING =>
-- send null and invalid data
s_axis_tvalid <= '0';
s_axis_tlast <= '0';
s_axis_tuser <= "00";
s_axis_tdata <= (others => '0');
-- START of orbit
-- d3 d2 d1 d0
-- header x 0 0 1
if d_ctrl.header = '1' then
-- check if 31 bits orbit number is not null and
-- start filling (or dropping) if the orbit is the start of the chunk
if (d(0)(30 downto 0) > x"00000000") and (d(0)(orbits_per_chunk_v downto 0) = orbits_per_chunk(orbits_per_chunk_v downto 0)) then
if HBM_almost_full = '0' then
fillerState <= FILLING;
else -- TODO: this case should not happen, but we leave it hear as a protection
fillerState <= DROPPING;
end if;
else
fillerState <= STARTING;
end if;
end if;
end case; end case;
----------------------------------------------------------------- -----------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment