Skip to content
Snippets Groups Projects
Commit bb7588be authored by Reinier van der Walle's avatar Reinier van der Walle
Browse files

replaced if statement with generate statement

parent 02a9a4bf
No related branches found
No related tags found
1 merge request!338added ip checksum inserter + added generics to eth_tester for setting
Pipeline #52849 passed
...@@ -74,6 +74,7 @@ architecture rtl of eth_ip_header_checksum is ...@@ -74,6 +74,7 @@ architecture rtl of eth_ip_header_checksum is
constant c_hdr_nof_words : natural := ceil_div(c_hdr_len, g_data_w); constant c_hdr_nof_words : natural := ceil_div(c_hdr_len, g_data_w);
constant c_crc_word_span : natural := 1 + c_hdr_crc_word_hi - c_hdr_crc_word_lo; constant c_crc_word_span : natural := 1 + c_hdr_crc_word_hi - c_hdr_crc_word_lo;
constant c_crc_in_one_word : boolean := c_crc_word_span = 1;
signal checksum : std_logic_vector(c_network_ip_header_checksum_w - 1 downto 0) := (others => '0'); signal checksum : std_logic_vector(c_network_ip_header_checksum_w - 1 downto 0) := (others => '0');
signal count : std_logic_vector(31 downto 0); signal count : std_logic_vector(31 downto 0);
...@@ -92,7 +93,26 @@ begin ...@@ -92,7 +93,26 @@ begin
--------------------------------------------------- ---------------------------------------------------
-- process to insert checksum in outgoing stream -- -- process to insert checksum in outgoing stream --
--------------------------------------------------- ---------------------------------------------------
p_insert_crc : process(dp_pipeline_src_out, checksum, count, reg_done) gen_insert_crc_one : if c_crc_in_one_word generate -- checksum is in 1 word.
p_insert_crc_one : process(dp_pipeline_src_out, checksum, count, reg_done)
variable v_count : natural := 0;
begin
v_count := TO_UINT(count);
src_out <= dp_pipeline_src_out;
nxt_reg_done <= reg_done;
if reg_done = '0' and dp_pipeline_src_out.valid = '1' and v_count = c_hdr_crc_word_hi then
src_out.data(c_crc_hi_bit_in_word downto c_crc_lo_bit_in_word) <= checksum;
nxt_reg_done <= '1';
end if;
if reg_done = '1' and dp_pipeline_src_out.eop = '1' then
nxt_reg_done <= '0';
end if;
end process;
end generate;
gen_insert_crc_multi : if not c_crc_in_one_word generate
p_insert_crc_multi : process(dp_pipeline_src_out, checksum, count, reg_done)
variable v_count : natural := 0; variable v_count : natural := 0;
variable v_hi : natural := 0; variable v_hi : natural := 0;
variable v_lo : natural := 0; variable v_lo : natural := 0;
...@@ -101,10 +121,7 @@ begin ...@@ -101,10 +121,7 @@ begin
src_out <= dp_pipeline_src_out; src_out <= dp_pipeline_src_out;
nxt_reg_done <= reg_done; nxt_reg_done <= reg_done;
if reg_done = '0' and dp_pipeline_src_out.valid = '1' then if reg_done = '0' and dp_pipeline_src_out.valid = '1' then
if v_count = c_hdr_crc_word_hi and v_count = c_hdr_crc_word_lo then -- checksum is in 1 word. if v_count = c_hdr_crc_word_hi then
src_out.data(c_crc_hi_bit_in_word downto c_crc_lo_bit_in_word) <= checksum;
nxt_reg_done <= '1';
elsif v_count = c_hdr_crc_word_hi then
src_out.data(c_crc_hi_bit_in_word downto 0) <= checksum(c_network_ip_header_checksum_w - 1 downto c_network_ip_header_checksum_w - c_crc_hi_bit_in_word - 1); src_out.data(c_crc_hi_bit_in_word downto 0) <= checksum(c_network_ip_header_checksum_w - 1 downto c_network_ip_header_checksum_w - c_crc_hi_bit_in_word - 1);
elsif v_count = c_hdr_crc_word_lo then elsif v_count = c_hdr_crc_word_lo then
src_out.data(g_data_w - 1 downto c_crc_lo_bit_in_word) <= checksum(g_data_w - c_crc_lo_bit_in_word - 1 downto 0); src_out.data(g_data_w - 1 downto c_crc_lo_bit_in_word) <= checksum(g_data_w - c_crc_lo_bit_in_word - 1 downto 0);
...@@ -120,6 +137,7 @@ begin ...@@ -120,6 +137,7 @@ begin
nxt_reg_done <= '0'; nxt_reg_done <= '0';
end if; end if;
end process; end process;
end generate;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
-- using common_counter to keep track of the word alignment during checksum calculation -- -- using common_counter to keep track of the word alignment during checksum calculation --
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment