Commit 6d2960c7 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

wrsw_nic/nic_descriptor_manager: reorganized FSM and some signal assignments

- removed ARB_DISABLED state, instead FSM is hold in ARB_START_SCAN
  unless module is enabled
- removed declarations of unused signals (granted_desc_idx, desc_idx_d0,
  check_count, stupid_hack)
- moved assignment of outputs validated with other signals outside FSM
  to simplify the logic (txdesc_current_o/rxdesc_current_o are validated
  by desc_grant_o, and stored in internal registers of nic_rx_fsm and
  nic_tx_fsm)
- rewritten ARB_WRITE_DESC state, so that data output is driven by
  desc_subreg counter instead of separate counter in case statement.
- more exotic regnums in marshalling functions (nic_descriptors_pkg) to
  minimize logic required to output correct data when needed in modified
  ARB_WRITE_DESC state
parent 5ec93cd8
...@@ -76,7 +76,7 @@ end nic_descriptor_manager; ...@@ -76,7 +76,7 @@ end nic_descriptor_manager;
architecture behavioral of nic_descriptor_manager is architecture behavioral of nic_descriptor_manager is
type t_desc_arb_state is (ARB_DISABLED, ARB_START_SCAN, ARB_CHECK_EMPTY, ARB_FETCH, ARB_GRANT, ARB_UPDATE, ARB_WRITE_DESC); type t_desc_arb_state is (ARB_START_SCAN, ARB_CHECK_EMPTY, ARB_FETCH, ARB_GRANT, ARB_UPDATE, ARB_WRITE_DESC);
signal state : t_desc_arb_state; signal state : t_desc_arb_state;
...@@ -84,15 +84,8 @@ architecture behavioral of nic_descriptor_manager is ...@@ -84,15 +84,8 @@ architecture behavioral of nic_descriptor_manager is
signal granted_desc_tx : t_tx_descriptor; signal granted_desc_tx : t_tx_descriptor;
signal granted_desc_rx : t_rx_descriptor; signal granted_desc_rx : t_rx_descriptor;
signal granted_desc_idx : unsigned(g_num_descriptors_log2-1 downto 0);
signal desc_idx_d0 : unsigned(g_num_descriptors_log2-1 downto 0);
signal desc_idx : unsigned(g_num_descriptors_log2-1 downto 0); signal desc_idx : unsigned(g_num_descriptors_log2-1 downto 0);
signal desc_subreg : unsigned(1 downto 0); signal desc_subreg : unsigned(1 downto 0);
signal cntr : unsigned(1 downto 0);
signal check_count : unsigned(g_num_descriptors_log2 downto 0);
signal stupid_hack : std_logic;
impure function f_write_marshalling(index : integer) impure function f_write_marshalling(index : integer)
return std_logic_vector is return std_logic_vector is
...@@ -111,6 +104,15 @@ begin -- behavioral ...@@ -111,6 +104,15 @@ begin -- behavioral
cur_desc_idx_o <= std_logic_vector(desc_idx); cur_desc_idx_o <= std_logic_vector(desc_idx);
--GD can do that, those outputs are validated by desc_grant_o
--and nic_rx_fsm stores it in internal register too
GEN_TXDESC_CUR: if g_desc_mode = "tx" generate
txdesc_current_o <= granted_desc_tx;
end generate;
GEN_RXDESC_CUR: if g_desc_mode = "rx" generate
rxdesc_current_o <= granted_desc_rx;
end generate;
p_rxdesc_arbiter : process(clk_sys_i, rst_n_i) p_rxdesc_arbiter : process(clk_sys_i, rst_n_i)
variable tmp_desc_rx : t_rx_descriptor; variable tmp_desc_rx : t_rx_descriptor;
variable tmp_desc_tx : t_tx_descriptor; variable tmp_desc_tx : t_tx_descriptor;
...@@ -120,7 +122,7 @@ begin -- behavioral ...@@ -120,7 +122,7 @@ begin -- behavioral
if(rst_n_i = '0') then if(rst_n_i = '0') then
desc_write_done_o <= '0'; desc_write_done_o <= '0';
desc_grant_o <= '0'; desc_grant_o <= '0';
state <= ARB_DISABLED; state <= ARB_START_SCAN;
desc_idx <= (others => '0'); desc_idx <= (others => '0');
desc_subreg <= (others => '0'); desc_subreg <= (others => '0');
dtbl_wr_o <= '0'; dtbl_wr_o <= '0';
...@@ -129,30 +131,18 @@ begin -- behavioral ...@@ -129,30 +131,18 @@ begin -- behavioral
else else
case state is case state is
when ARB_DISABLED =>
desc_idx <= (others => '0');
desc_subreg <= (others => '0');
if(enable_i = '1') then
-- dtbl_rd_o <= '1';
state <= ARB_START_SCAN;
desc_idx <= (others => '0');
check_count <= (others => '0');
end if;
when ARB_START_SCAN => when ARB_START_SCAN =>
desc_subreg <= (others => '0');
if(enable_i = '0') then dtbl_wr_o <= '0';
state <= ARB_DISABLED; if(enable_i = '1') then
state <= ARB_CHECK_EMPTY;
else else
-- wait until the current descriptor is read from the memorry desc_idx <= (others => '0');
state <= ARB_CHECK_EMPTY;
-- dtbl_rd_o <='1';
dtbl_wr_o <= '0';
end if; end if;
when ARB_CHECK_EMPTY => when ARB_CHECK_EMPTY =>
dtbl_wr_o <= '0';
tmp_desc_rx := f_unmarshall_rx_descriptor(dtbl_data_i, 1); tmp_desc_rx := f_unmarshall_rx_descriptor(dtbl_data_i, 1);
tmp_desc_tx := f_unmarshall_tx_descriptor(dtbl_data_i, 1); tmp_desc_tx := f_unmarshall_tx_descriptor(dtbl_data_i, 1);
granted_desc_tx <= tmp_desc_tx; granted_desc_tx <= tmp_desc_tx;
...@@ -167,6 +157,7 @@ begin -- behavioral ...@@ -167,6 +157,7 @@ begin -- behavioral
end if; end if;
when ARB_FETCH => when ARB_FETCH =>
dtbl_wr_o <= '0';
case desc_subreg is case desc_subreg is
when "10" => -- ignore the timestamps for RX when "10" => -- ignore the timestamps for RX
-- descriptors (they're -- descriptors (they're
...@@ -192,67 +183,46 @@ begin -- behavioral ...@@ -192,67 +183,46 @@ begin -- behavioral
desc_subreg <= desc_subreg + 1; desc_subreg <= desc_subreg + 1;
when ARB_GRANT => when ARB_GRANT =>
dtbl_wr_o <= '0';
desc_subreg <= "11";
if(desc_request_next_i = '1') then if(desc_request_next_i = '1') then
desc_grant_o <= '1'; desc_grant_o <= '1';
if(g_desc_mode = "tx") then
txdesc_current_o <= granted_desc_tx;
elsif (g_desc_mode = "rx") then
rxdesc_current_o <= granted_desc_rx;
end if;
state <= ARB_UPDATE; state <= ARB_UPDATE;
end if; end if;
desc_write_done_o <= '0'; desc_write_done_o <= '0';
when ARB_UPDATE => when ARB_UPDATE =>
dtbl_wr_o <= '0';
desc_grant_o <= '0'; desc_grant_o <= '0';
desc_subreg <= "11";
if(desc_write_i = '1') then if(desc_write_i = '1') then
if(g_desc_mode = "rx") then if(g_desc_mode = "rx") then
granted_desc_rx <= rxdesc_new_i; granted_desc_rx <= rxdesc_new_i;
elsif(g_desc_mode = "tx") then elsif(g_desc_mode = "tx") then
granted_desc_tx <= txdesc_new_i; granted_desc_tx <= txdesc_new_i;
end if; end if;
desc_subreg <= (others => '0');
-- dtbl_rd_o <= '0';
state <= ARB_WRITE_DESC; state <= ARB_WRITE_DESC;
cntr <= "00";
end if; end if;
when ARB_WRITE_DESC => when ARB_WRITE_DESC =>
cntr <= cntr + 1; dtbl_data_o <= f_write_marshalling(to_integer(desc_subreg));
-- fprint(output,l, "WriteDesc %b %b\n",fo(cntr),fo(f_write_marshalling(1))); if(desc_subreg = "10") then
case cntr is dtbl_wr_o <= '0';
when "00" => desc_subreg <= "00";
desc_subreg <= "00"; state <= ARB_START_SCAN;
dtbl_data_o <= f_write_marshalling(1); if(desc_reload_current_i = '0') then
dtbl_wr_o <= '1'; desc_idx <= desc_idx + 1;
when "01" => end if;
desc_subreg <= "01"; desc_write_done_o <= '1';
dtbl_data_o <= f_write_marshalling(2); else
dtbl_wr_o <= '1'; dtbl_wr_o <= '1';
when "10" => desc_subreg <= desc_subreg + 1;
desc_subreg <= "10"; end if;
dtbl_data_o <= f_write_marshalling(3);
dtbl_wr_o <= '1';
when "11" =>
dtbl_wr_o <= '0';
desc_subreg <= (others => '0');
state <= ARB_START_SCAN;
if(desc_reload_current_i = '0') then
desc_idx <= desc_idx + 1;
end if;
desc_write_done_o <= '1';
when others => null;
end case;
when others => null; when others => null;
end case; end case;
......
...@@ -93,9 +93,9 @@ package body NIC_descriptors_pkg is ...@@ -93,9 +93,9 @@ package body NIC_descriptors_pkg is
begin begin
case regnum is case regnum is
when 1 => tmp := desc.ts_id & x"000" & desc.pad_e & desc.ts_e & desc.error & desc.ready; when 3 => tmp := desc.ts_id & x"000" & desc.pad_e & desc.ts_e & desc.error & desc.ready;
when 2 => tmp := f_resize_slv(desc.len, 16) & f_resize_slv(desc.offset, 16); when 0 => tmp := f_resize_slv(desc.len, 16) & f_resize_slv(desc.offset, 16);
when 3 => tmp := desc.dpm; when 1 => tmp := desc.dpm;
when others => null; when others => null;
end case; end case;
...@@ -106,9 +106,9 @@ package body NIC_descriptors_pkg is ...@@ -106,9 +106,9 @@ package body NIC_descriptors_pkg is
variable tmp : std_logic_vector(31 downto 0); variable tmp : std_logic_vector(31 downto 0);
begin begin
case regnum is case regnum is
when 1 => tmp := "0000000000000000" & desc.ts_incorrect & desc.got_ts & desc.port_id & "000000" & desc.error & desc.empty; when 3 => tmp := "0000000000000000" & desc.ts_incorrect & desc.got_ts & desc.port_id & "000000" & desc.error & desc.empty;
when 2 => tmp := desc.ts_f & desc.ts_r; when 0 => tmp := desc.ts_f & desc.ts_r;
when 3 => tmp := f_resize_slv(desc.len, 16) & f_resize_slv(desc.offset, 16); when 1 => tmp := f_resize_slv(desc.len, 16) & f_resize_slv(desc.offset, 16);
when others => null; when others => null;
end case; end case;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment