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;
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;
......@@ -84,15 +84,8 @@ architecture behavioral of nic_descriptor_manager is
signal granted_desc_tx : t_tx_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_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)
return std_logic_vector is
......@@ -111,6 +104,15 @@ begin -- behavioral
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)
variable tmp_desc_rx : t_rx_descriptor;
variable tmp_desc_tx : t_tx_descriptor;
......@@ -120,7 +122,7 @@ begin -- behavioral
if(rst_n_i = '0') then
desc_write_done_o <= '0';
desc_grant_o <= '0';
state <= ARB_DISABLED;
state <= ARB_START_SCAN;
desc_idx <= (others => '0');
desc_subreg <= (others => '0');
dtbl_wr_o <= '0';
......@@ -129,30 +131,18 @@ begin -- behavioral
else
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 =>
if(enable_i = '0') then
state <= ARB_DISABLED;
desc_subreg <= (others => '0');
dtbl_wr_o <= '0';
if(enable_i = '1') then
state <= ARB_CHECK_EMPTY;
else
-- wait until the current descriptor is read from the memorry
state <= ARB_CHECK_EMPTY;
-- dtbl_rd_o <='1';
dtbl_wr_o <= '0';
desc_idx <= (others => '0');
end if;
when ARB_CHECK_EMPTY =>
dtbl_wr_o <= '0';
tmp_desc_rx := f_unmarshall_rx_descriptor(dtbl_data_i, 1);
tmp_desc_tx := f_unmarshall_tx_descriptor(dtbl_data_i, 1);
granted_desc_tx <= tmp_desc_tx;
......@@ -167,6 +157,7 @@ begin -- behavioral
end if;
when ARB_FETCH =>
dtbl_wr_o <= '0';
case desc_subreg is
when "10" => -- ignore the timestamps for RX
-- descriptors (they're
......@@ -192,67 +183,46 @@ begin -- behavioral
desc_subreg <= desc_subreg + 1;
when ARB_GRANT =>
dtbl_wr_o <= '0';
desc_subreg <= "11";
if(desc_request_next_i = '1') then
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;
end if;
desc_write_done_o <= '0';
when ARB_UPDATE =>
dtbl_wr_o <= '0';
desc_grant_o <= '0';
desc_subreg <= "11";
if(desc_write_i = '1') then
if(g_desc_mode = "rx") then
granted_desc_rx <= rxdesc_new_i;
elsif(g_desc_mode = "tx") then
granted_desc_tx <= txdesc_new_i;
end if;
desc_subreg <= (others => '0');
-- dtbl_rd_o <= '0';
state <= ARB_WRITE_DESC;
cntr <= "00";
end if;
when ARB_WRITE_DESC =>
cntr <= cntr + 1;
-- fprint(output,l, "WriteDesc %b %b\n",fo(cntr),fo(f_write_marshalling(1)));
case cntr is
when "00" =>
desc_subreg <= "00";
dtbl_data_o <= f_write_marshalling(1);
dtbl_wr_o <= '1';
when "01" =>
desc_subreg <= "01";
dtbl_data_o <= f_write_marshalling(2);
dtbl_wr_o <= '1';
when "10" =>
desc_subreg <= "10";
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;
dtbl_data_o <= f_write_marshalling(to_integer(desc_subreg));
if(desc_subreg = "10") then
dtbl_wr_o <= '0';
desc_subreg <= "00";
state <= ARB_START_SCAN;
if(desc_reload_current_i = '0') then
desc_idx <= desc_idx + 1;
end if;
desc_write_done_o <= '1';
else
dtbl_wr_o <= '1';
desc_subreg <= desc_subreg + 1;
end if;
when others => null;
end case;
......
......@@ -93,9 +93,9 @@ package body NIC_descriptors_pkg is
begin
case regnum is
when 1 => 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 3 => tmp := desc.dpm;
when 3 => tmp := desc.ts_id & x"000" & desc.pad_e & desc.ts_e & desc.error & desc.ready;
when 0 => tmp := f_resize_slv(desc.len, 16) & f_resize_slv(desc.offset, 16);
when 1 => tmp := desc.dpm;
when others => null;
end case;
......@@ -106,9 +106,9 @@ package body NIC_descriptors_pkg is
variable tmp : std_logic_vector(31 downto 0);
begin
case regnum is
when 1 => 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 3 => tmp := f_resize_slv(desc.len, 16) & f_resize_slv(desc.offset, 16);
when 3 => tmp := "0000000000000000" & desc.ts_incorrect & desc.got_ts & desc.port_id & "000000" & desc.error & desc.empty;
when 0 => tmp := desc.ts_f & desc.ts_r;
when 1 => tmp := f_resize_slv(desc.len, 16) & f_resize_slv(desc.offset, 16);
when others => null;
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