udpprot: Add round-robin scheduler

This commit is contained in:
Markus Koch 2025-10-07 13:58:41 +02:00
parent 474d444f59
commit 3a42c865c6

View File

@ -16,6 +16,9 @@ use ieee.numeric_std.all;
use work.trashernet_pkg.all;
entity trashernet_udpprot is
generic(
ROUND_ROBIN : boolean := true -- Prioritize, but prevent one channel from hogging all bandwidth (may add one cycle of latency between frames)
);
port(
-- Global
clk : in std_logic; -- Global clock
@ -98,8 +101,9 @@ begin
elsif rising_edge(clk) then
case state is
when IDLE =>
tx_sel <= udpprot_tx_out'left;
for i in udpprot_tx_in'range loop
if udpprot_tx_in(i).tx_en then
if (udpprot_tx_in(i).tx_en = '1') and (i >= tx_sel) then
tx_sel <= i;
state <= TXD;
exit; -- Prioritize according to vector
@ -111,8 +115,12 @@ begin
when WAITDONE =>
if udp_out.tx_err_stb or udp_out.tx_ok_stb then
state <= IDLE;
tx_sel <= udpprot_tx_in'left; -- To avoid arbitration errors, always select the highest priority one by default
state <= IDLE;
if (not ROUND_ROBIN) or (tx_sel = udpprot_tx_out'high) then
tx_sel <= udpprot_tx_out'left;
else
tx_sel <= tx_sel + 1;
end if;
end if;
end case;
end if;