Commit acf9de82 authored by Ille, Ondrej, Ing.'s avatar Ille, Ondrej, Ing.

src: Implement protocol exception in Protocol control FSM.

parent 4243eab9
Pipeline #19558 failed with stages
in 19 minutes and 57 seconds
......@@ -456,6 +456,8 @@ architecture rtl of protocol_control is
-- Secondary sampling point configuration
signal drv_ssp_delay_select : std_logic_vector(1 downto 0);
-- Protocol exception
signal drv_pex : std_logic;
-----------------------------------------------------------------------------
-- Internal signals
......@@ -626,6 +628,7 @@ begin
drv_bus_off_reset <= drv_bus(DRV_ERR_CTR_CLR);
drv_ssp_delay_select <= drv_bus(DRV_SSP_DELAY_SELECT_HIGH downto
DRV_SSP_DELAY_SELECT_LOW);
drv_pex <= drv_bus(DRV_PEX_INDEX);
---------------------------------------------------------------------------
-- TX Data word endian swapper
......@@ -668,6 +671,7 @@ begin
drv_int_loopback_ena => drv_int_loopback_ena,-- IN
drv_can_fd_ena => drv_can_fd_ena, -- IN
drv_ssp_delay_select => drv_ssp_delay_select,-- IN
drv_pex => drv_pex, -- IN
is_control => is_control, -- OUT
is_data => is_data, -- OUT
is_stuff_count => is_stuff_count, -- OUT
......
......@@ -138,6 +138,9 @@ entity protocol_control_fsm is
-- Secondary sampling point delay select
drv_ssp_delay_select :in std_logic_vector(1 downto 0);
-- Protocol exception handling
drv_pex :in std_logic;
-- Control field is being transmitted
is_control :out std_logic;
......@@ -744,7 +747,11 @@ architecture rtl of protocol_control_fsm is
signal ctrl_signal_upd : std_logic;
-- Clear bus-off reset flag
signal clr_bus_off_rst_flg : std_logic;
signal clr_bus_off_rst_flg : std_logic;
-- Protocol exception signals
signal pex_on_fdf_enable : std_logic;
signal pex_on_res_enable : std_logic;
begin
......@@ -821,6 +828,16 @@ begin
else
'0';
pex_on_fdf_enable <= '1' when (drv_ena = FDE_DISABLE and
drv_pex = PROTOCOL_EXCEPTION_ENABLED)
else
'0';
pex_on_res_enable <= '1' when (drv_ena = FDE_ENABLE and
drv_pex = PROTOCOL_EXCEPTION_ENABLED)
else
'0';
---------------------------------------------------------------------------
-- CRC sequence selection
---------------------------------------------------------------------------
......@@ -1001,7 +1018,11 @@ begin
if (rx_data_nbs = DOMINANT) then
next_state <= s_pc_r0_ext;
else
next_state <= s_pc_r0_fd;
if (pex_on_fdf_enable = '1') then
next_state <= s_pc_integrating;
else
next_state <= s_pc_r0_fd;
end if;
end if;
-------------------------------------------------------------------
......@@ -1011,10 +1032,14 @@ begin
next_state <= s_pc_dlc;
-------------------------------------------------------------------
-- r0 bit in CAN FD Frames (both Base and Extended identifier)
-- r0(res) bit in CAN FD Frames (both Base and Extended identifier)
-------------------------------------------------------------------
when s_pc_r0_fd =>
next_state <= s_pc_brs;
if (rx_data_nbs = RECESSIVE and pex_on_res_enable = '1') then
next_state <= s_pc_integrating;
else
next_state <= s_pc_brs;
end if;
-------------------------------------------------------------------
-- EDL/r0 bit in CAN 2.0 and CAN FD Frames with BASE identifier
......@@ -1024,7 +1049,13 @@ begin
if (rx_data_nbs = DOMINANT) then
next_state <= s_pc_dlc;
else
next_state <= s_pc_r0_fd;
-- Protocol exception on recessive FDF/EDL in "Classical CAN"
-- configuration
if (pex_on_fdf_enable = '1') then
next_state <= s_pc_integrating;
else
next_state <= s_pc_r0_fd;
end if;
end if;
-------------------------------------------------------------------
......@@ -1746,11 +1777,29 @@ begin
end if;
end if;
if ((drv_can_fd_ena = FDE_DISABLE) or
(tran_frame_type = NORMAL_CAN and is_transmitter = '1'))
and (rx_data_nbs = RECESSIVE)
-- Sample recessive but CAN FD is disabled -> Form error or
-- protocol exception!
if (rx_data_nbs = RECESSIVE and
drv_can_fd_ena = FDE_DISABLE)
then
form_err_i <= '1';
if (drv_pex = PROTOCOL_EXCEPTION_DISABLED) then
form_err_i <= '1';
-----------------------------------------------------------
-- Here we detect protocol exception. Although unit should
-- not be transmitter at this moment (see datasheet), it
-- is possible user is stupid! Unlock TXT Buffer so that
-- it does not end up in deadlock!
-----------------------------------------------------------
elsif (is_transmitter = '1') then
txtb_hw_cmd_d.unlock <= '1';
stuff_enable_clear <= '1';
if (tx_failed = '1') then
txtb_hw_cmd_d.failed <= '1';
else
txtb_hw_cmd_d.arbl <= '1';
end if;
end if;
end if;
-------------------------------------------------------------------
......@@ -1793,7 +1842,24 @@ begin
-- protocol (CAN XL in future). Now we don't have protocol
-- exception, so we throw error here!
if (rx_data_nbs = RECESSIVE) then
form_err_i <= '1';
if (drv_pex = PROTOCOL_EXCEPTION_DISABLED) then
form_err_i <= '1';
-----------------------------------------------------------
-- Here we detect protocol exception. Although unit should
-- not be transmitter at this moment (see datasheet), it
-- is possible user is stupid! Unlock TXT Buffer so that
-- it does not end up in deadlock!
-----------------------------------------------------------
elsif (is_transmitter = '1') then
txtb_hw_cmd_d.unlock <= '1';
stuff_enable_clear <= '1';
if (tx_failed = '1') then
txtb_hw_cmd_d.failed <= '1';
else
txtb_hw_cmd_d.arbl <= '1';
end if;
end if;
end if;
-------------------------------------------------------------------
......@@ -1821,11 +1887,29 @@ begin
ssp_reset_i <= '1';
end if;
if ((drv_can_fd_ena = FDE_DISABLE) or
(tran_frame_type = NORMAL_CAN and is_transmitter = '1'))
and (rx_data_nbs = RECESSIVE)
-- Sample recessive but CAN FD is disabled -> Form error or
-- protocol exception!
if (rx_data_nbs = RECESSIVE and
drv_can_fd_ena = FDE_DISABLE)
then
form_err_i <= '1';
if (drv_pex = PROTOCOL_EXCEPTION_DISABLED) then
form_err_i <= '1';
-----------------------------------------------------------
-- Here we detect protocol exception. Although unit should
-- not be transmitter at this moment (see datasheet), it
-- is possible user is stupid! Unlock TXT Buffer so that
-- it does not end up in deadlock!
-----------------------------------------------------------
elsif (is_transmitter = '1') then
txtb_hw_cmd_d.unlock <= '1';
stuff_enable_clear <= '1';
if (tx_failed = '1') then
txtb_hw_cmd_d.failed <= '1';
else
txtb_hw_cmd_d.arbl <= '1';
end if;
end if;
end if;
-------------------------------------------------------------------
......
......@@ -1520,6 +1520,9 @@ package can_components is
-- Secondary sampling point delay select
drv_ssp_delay_select :in std_logic_vector(1 downto 0);
-- Protocol exception handling
drv_pex :in std_logic;
-- Arbitration field is being transmitted
is_arbitration :out std_logic;
......
......@@ -217,6 +217,8 @@ package drv_stat_pkg is
constant DRV_ENA_INDEX : natural := 509;
constant DRV_FD_TYPE_INDEX : natural := 510;
constant DRV_PEX_INDEX : natural := 511;
----------------------------------------------------------------------------
-- RX, TX and TXT Buffer frame format signal indexes
......
......@@ -592,6 +592,9 @@ begin
drv_bus(DRV_INT_LOOBACK_ENA_INDEX) <= align_wrd_to_reg(
control_registers_out.settings, ILBP_IND);
-- PEX - Protocol exception mode
drv_bus(DRV_PEX_INDEX) <= align_wrd_to_reg(
control_registers_out.settings, PEX_IND);
---------------------------------------------------------------------------
-- INT_STAT - Clearing interrupt vector by write
......@@ -1424,14 +1427,13 @@ begin
drv_bus(360 downto 358) <= (OTHERS => '0');
drv_bus(362 downto 361) <= (OTHERS => '0');
drv_bus(365 downto 363) <= (OTHERS => '0');
drv_bus(370 downto 368) <= (OTHERS => '0');
drv_bus(371) <= '0';
drv_bus(371 downto 368) <= (OTHERS => '0');
drv_bus(399 downto 383) <= (OTHERS => '0');
drv_bus(459 downto 445) <= (OTHERS => '0');
drv_bus(464 downto 462) <= (OTHERS => '0');
drv_bus(609 downto 601) <= (OTHERS => '0');
drv_bus(579 downto 570) <= (OTHERS => '0');
drv_bus(519 downto 511) <= (OTHERS => '0');
drv_bus(519 downto 512) <= (OTHERS => '0');
drv_bus(506 downto 475) <= (OTHERS => '0');
drv_bus(444 downto 430) <= (OTHERS => '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