Commit 518fd697 authored by Ille, Ondrej, Ing.'s avatar Ille, Ondrej, Ing.

src: Fix stuff bit counting when no SOF is transmitted.

parent ec5c7391
......@@ -108,7 +108,10 @@ entity bit_stuffing is
fixed_stuff :in std_logic;
-- Length of Bit Stuffing rule
stuff_length :in std_logic_vector(2 downto 0);
stuff_length :in std_logic_vector(2 downto 0);
-- Frame transmission without SOF started
tx_frame_no_sof :in std_logic;
------------------------------------------------------------------------
-- Status signals
......@@ -327,11 +330,15 @@ begin
---------------------------------------------------------------------------
-- Next value for counter of equal consecutive bits:
-- 1. Reset
-- 2. Increment if not reset when processing bit.
-- 3. Keep original value otherwise.
---------------------------------------------------------------------------
same_bits_d <= "001" when (same_bits_rst = '1') else
-- 1. Set to 2 when transmission started without SOF and first bit of
-- Base ID is dominant! This accounts for SOF + Base ID (1)!
-- 2. Reset
-- 3. Increment if not reset when processing bit.
-- 4. Keep original value otherwise.
---------------------------------------------------------------------------
same_bits_d <= "010" when (tx_frame_no_sof = '1' and
data_in = DOMINANT) else
"001" when (same_bits_rst = '1') else
same_bits_add when (bst_trigger = '1') else
same_bits_q;
......
......@@ -335,6 +335,7 @@ architecture rtl of can_core is
signal stuff_enable : std_logic;
signal destuff_enable : std_logic;
signal fixed_stuff : std_logic;
signal tx_frame_no_sof : std_logic;
signal stuff_length : std_logic_vector(2 downto 0);
signal dst_ctr : std_logic_vector(2 downto 0);
signal bst_ctr : std_logic_vector(2 downto 0);
......@@ -538,6 +539,7 @@ begin
stuff_enable => stuff_enable, -- OUT
destuff_enable => destuff_enable, -- OUT
fixed_stuff => fixed_stuff, -- OUT
tx_frame_no_sof => tx_frame_no_sof, -- OUT
stuff_length => stuff_length, -- OUT
dst_ctr => dst_ctr, -- IN
bst_ctr => bst_ctr, -- IN
......@@ -718,6 +720,7 @@ begin
stuff_enable => stuff_enable, -- IN
fixed_stuff => fixed_stuff, -- IN
stuff_length => stuff_length, -- IN
tx_frame_no_sof => tx_frame_no_sof, -- IN
-- Status signals
bst_ctr => bst_ctr, -- OUT
......
......@@ -306,6 +306,9 @@ entity protocol_control is
-- Bit Stuffing type (0-Normal, 1-Fixed)
fixed_stuff :out std_logic;
-- Frame transmission without SOF started
tx_frame_no_sof :out std_logic;
-- Length of Bit Stuffing rule
stuff_length :out std_logic_vector(2 downto 0);
......@@ -762,6 +765,7 @@ begin
destuff_enable => destuff_enable, -- OUT
stuff_length => stuff_length, -- OUT
fixed_stuff => fixed_stuff_i, -- OUT
tx_frame_no_sof => tx_frame_no_sof, -- OUT
-- Operation control interface
is_transmitter => is_transmitter, -- IN
......
......@@ -411,7 +411,10 @@ entity protocol_control_fsm is
-- Fixed Bit stuffing method
fixed_stuff :out std_logic;
-- Frame transmission without SOF started
tx_frame_no_sof :out std_logic;
-----------------------------------------------------------------------
-- Operation control interface
-----------------------------------------------------------------------
......@@ -723,6 +726,10 @@ architecture rtl of protocol_control_fsm is
-- Blocking HW command for Unlock When Error frame request is active
signal block_txtb_unlock_due_error : std_logic;
-- No SOF transmitted
signal tx_frame_no_sof_d : std_logic;
signal tx_frame_no_sof_q : std_logic;
begin
tx_frame_ready <= '1' when (tran_frame_valid = '1' and drv_bus_mon_ena = '0')
......@@ -1365,6 +1372,7 @@ begin
stuff_enable_clear <= '0';
destuff_enable_set <= '0';
destuff_enable_clear <= '0';
tx_frame_no_sof_d <= '0';
-- Synchronisation control
perform_hsync <= '0';
......@@ -2147,7 +2155,10 @@ begin
-- is received, become receiver!
if (tx_frame_ready = '1' and go_to_suspend = '0') then
txtb_hw_cmd_d.lock <= '1';
set_transmitter_i <= '1';
set_transmitter_i <= '1';
if (rx_data_nbs = DOMINANT) then
tx_frame_no_sof_d <= '1';
end if;
elsif (rx_data_nbs = DOMINANT) then
set_receiver_i <= '1';
end if;
......@@ -2241,7 +2252,6 @@ begin
if (rx_data_nbs = DOMINANT and is_bus_off = '0') then
ctrl_ctr_pload_i <= '1';
ctrl_ctr_pload_val <= C_BASE_ID_DURATION;
tx_load_base_id_i <= '1';
sof_pulse_i <= '1';
crc_enable <= '1';
end if;
......@@ -2249,6 +2259,11 @@ begin
if (tx_frame_ready = '1' and is_bus_off = '0') then
txtb_hw_cmd_d.lock <= '1';
set_transmitter_i <= '1';
tx_load_base_id_i <= '1';
if (rx_data_nbs = DOMINANT) then
tx_frame_no_sof_d <= '1';
end if;
elsif (rx_data_nbs = DOMINANT) then
set_receiver_i <= '1';
end if;
......@@ -2819,6 +2834,19 @@ begin
end if;
end process;
-----------------------------------------------------------------------
-- Frame transmission (transmitter) started without SOF!
-----------------------------------------------------------------------
tx_frame_no_sof_proc : process(clk_sys, res_n)
begin
if (res_n = G_RESET_POLARITY) then
tx_frame_no_sof_q <= '0';
elsif (rising_edge(clk_sys)) then
if (rx_trigger = '1') then
tx_frame_no_sof_q <= tx_frame_no_sof_d;
end if;
end if;
end process;
-----------------------------------------------------------------------
-- Internal signals to output propagation
......@@ -2838,6 +2866,7 @@ begin
retr_ctr_clear <= retr_ctr_clear_i;
arbitration_lost <= arbitration_lost_i;
retr_ctr_add <= retr_ctr_add_i;
tx_frame_no_sof <= tx_frame_no_sof_q;
-- <RELEASE_OFF>
-----------------------------------------------------------------------
......
......@@ -591,7 +591,10 @@ package can_components is
-- Length of Bit Stuffing rule
stuff_length :in std_logic_vector(2 downto 0);
-- Frame transmission without SOF started
tx_frame_no_sof :in std_logic;
------------------------------------------------------------------------
-- Status signals
------------------------------------------------------------------------
......@@ -1717,6 +1720,9 @@ package can_components is
-- Fixed Bit stuffing method
fixed_stuff :out std_logic;
-- Frame transmission without SOF started
tx_frame_no_sof :out std_logic;
-----------------------------------------------------------------------
-- Operation control interface
-----------------------------------------------------------------------
......@@ -2058,6 +2064,9 @@ package can_components is
-- Bit Stuffing type (0-Normal, 1-Fixed)
fixed_stuff :out std_logic;
-- Frame transmission without SOF started
tx_frame_no_sof :out std_logic;
-- Length of Bit Stuffing rule
stuff_length :out std_logic_vector(2 downto 0);
......
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