Commit 3470b74c authored by Ille, Ondrej, Ing.'s avatar Ille, Ondrej, Ing.

Brought up fault confinement feature test.

parent a8e2b97d
...@@ -59,130 +59,110 @@ use work.CAN_FD_register_map.all; ...@@ -59,130 +59,110 @@ use work.CAN_FD_register_map.all;
package fault_conf_feature is package fault_conf_feature is
procedure fault_conf_feature_exec( procedure fault_conf_feature_exec(
variable outcome : inout boolean; variable outcome : inout boolean;
signal rand_ctr :inout natural range 0 to RAND_POOL_SIZE; signal rand_ctr : inout natural range 0 to RAND_POOL_SIZE;
signal mem_bus_1 :inout Avalon_mem_type; signal mem_bus_1 : inout Avalon_mem_type;
signal mem_bus_2 :inout Avalon_mem_type; signal mem_bus_2 : inout Avalon_mem_type;
--Additional signals for tests signal bus_level : in std_logic;
--Pretty much everything can be read out of stat bus... signal drv_bus_1 : in std_logic_vector(1023 downto 0);
signal bus_level :in std_logic; signal drv_bus_2 : in std_logic_vector(1023 downto 0);
signal drv_bus_1 :in std_logic_vector(1023 downto 0); signal stat_bus_1 : in std_logic_vector(511 downto 0);
signal drv_bus_2 :in std_logic_vector(1023 downto 0); signal stat_bus_2 : in std_logic_vector(511 downto 0)
signal stat_bus_1 :in std_logic_vector(511 downto 0); );
signal stat_bus_2 :in std_logic_vector(511 downto 0)
);
end package; end package;
package body fault_conf_feature is package body fault_conf_feature is
procedure fault_conf_feature_exec( procedure fault_conf_feature_exec(
variable outcome : inout boolean; variable outcome : inout boolean;
signal rand_ctr :inout natural range 0 to RAND_POOL_SIZE; signal rand_ctr : inout natural range 0 to RAND_POOL_SIZE;
signal mem_bus_1 :inout Avalon_mem_type; signal mem_bus_1 : inout Avalon_mem_type;
signal mem_bus_2 :inout Avalon_mem_type; signal mem_bus_2 : inout Avalon_mem_type;
--Additional signals for tests signal bus_level : in std_logic;
--Pretty much everything can be read out of stat bus... signal drv_bus_1 : in std_logic_vector(1023 downto 0);
signal bus_level :in std_logic; signal drv_bus_2 : in std_logic_vector(1023 downto 0);
signal drv_bus_1 :in std_logic_vector(1023 downto 0); signal stat_bus_1 : in std_logic_vector(511 downto 0);
signal drv_bus_2 :in std_logic_vector(1023 downto 0); signal stat_bus_2 : in std_logic_vector(511 downto 0)
signal stat_bus_1 :in std_logic_vector(511 downto 0); )is
signal stat_bus_2 :in std_logic_vector(511 downto 0) variable r_data : std_logic_vector(31 downto 0) :=
)is (OTHERS => '0');
variable r_data : std_logic_vector(31 downto 0):=(OTHERS => '0'); variable CAN_frame : SW_CAN_frame_type;
variable CAN_frame : SW_CAN_frame_type; variable frame_sent : boolean := false;
variable frame_sent : boolean:=false; variable ctr_1 : natural;
variable ctr_1 : natural; variable ctr_2 : natural;
variable ctr_2 : natural; variable ID_1 : natural := 1;
variable ID_1 : natural:=1; variable ID_2 : natural := 2;
variable ID_2 : natural:=2; variable rand_val : real;
variable rand_val : real; variable th_1 : natural := 0;
variable th_1 : natural:=0; variable rxc : natural := 0;
variable rxc : natural:=0; variable txc : natural := 0;
variable txc : natural:=0;
begin variable err_counters : SW_error_counters;
outcome:=true; variable fault_th : SW_fault_thresholds := (0, 0);
variable fault_th_2 : SW_fault_thresholds := (0, 0);
----------------------------------------------- variable fault_state : SW_fault_state;
-- Generate random setting of ERP treshold begin
-- and RX counters to preset outcome := true;
-----------------------------------------------
rand_real_v(rand_ctr,rand_val); ------------------------------------------------------------------------
th_1:=integer(rand_val*254.0); -- Generate random setting of ERP treshold and RX counters to preset
------------------------------------------------------------------------
rand_real_v(rand_ctr,rand_val); rand_real_v(rand_ctr, rand_val);
rxc:=integer(rand_val*257.0); fault_th.erp := integer(rand_val * 254.0);
rand_real_v(rand_ctr,rand_val); rand_real_v(rand_ctr, rand_val);
txc:=integer(rand_val*257.0); err_counters.rx_counter := integer(rand_val * 257.0);
rand_real_v(rand_ctr,rand_val);
----------------------------------------------- err_counters.tx_counter := integer(rand_val * 257.0);
-- Set the counter and tresholds
-----------------------------------------------
r_data := (OTHERS => '0'); ------------------------------------------------------------------------
r_data(ERP_LIMIT_H downto ERP_LIMIT_L):= -- Set the counter and tresholds
std_logic_vector(to_unsigned(th_1,8)); ------------------------------------------------------------------------
CAN_write(r_data,EWL_ADR,ID_1,mem_bus_1); set_error_counters(err_counters, ID_1, mem_bus_1);
set_fault_thresholds(fault_th, ID_1, mem_bus_1);
r_data := (OTHERS => '0');
r_data(CTPV_H downto CTPV_L):=
std_logic_vector(to_unsigned(txc,9)); ------------------------------------------------------------------------
r_data(PTX_IND):='1'; -- Read counters back
CAN_write(r_data,CTR_PRES_ADR,ID_1,mem_bus_1); ------------------------------------------------------------------------
get_fault_thresholds(fault_th_2, ID_1, mem_bus_1);
r_data := (OTHERS => '0');
r_data(CTPV_H downto CTPV_L):= if (fault_th.ewl /= fault_th_2.ewl) then
std_logic_vector(to_unsigned(rxc,9)); outcome := false;
r_data(PRX_IND):='1'; end if;
CAN_write(r_data,CTR_PRES_ADR,ID_1,mem_bus_1);
if (fault_th.erp /= fault_th_2.erp) then
outcome := false;
----------------------------------------------- end if;
-- Read counters back
-----------------------------------------------
CAN_read(r_data,RXC_ADR,ID_1,mem_bus_1);
if( to_integer(unsigned(r_data(RXC_VAL_H downto RXC_VAL_L))) /= rxc )then
outcome:=false;
end if;
if( to_integer(unsigned(r_data(TXC_VAL_H downto TXC_VAL_L))) /= txc )then
outcome:=false;
end if;
-----------------------------------------------
-- Read fault confinement state
-----------------------------------------------
CAN_read(r_data,EWL_ADR,ID_1,mem_bus_1);
if(txc>255 or rxc>255)then
if(r_data(ERA_IND)='1' or
r_data(ERP_IND)='1' or
r_data(BOF_IND)='0')
then
outcome:=false;
end if;
elsif(txc<th_1 and rxc<th_1) then
if(r_data(ERA_IND)='0' or
r_data(ERP_IND)='1' or
r_data(BOF_IND)='1')
then
outcome:=false;
end if;
else
if(r_data(ERA_IND)='1' or
r_data(ERP_IND)='0' or
r_data(BOF_IND)='1')
then
outcome:=false;
end if;
end if;
end procedure; ------------------------------------------------------------------------
-- Read fault confinement state
------------------------------------------------------------------------
get_fault_state(fault_state, ID_1, mem_bus_1);
if (err_counters.tx_counter > 255 or
err_counters.rx_counter > 255)
then
if (fault_state /= fc_bus_off) then
outcome := false;
end if;
elsif (err_counters.tx_counter < fault_th.ewl and
err_counters.rx_counter < fault_th.ewl)
then
if (fault_state /= fc_error_active) then
outcome := false;
end if;
else
if (fault_state /= fc_error_passive) then
outcome := false;
end if;
end if;
end procedure;
end package body; end package body;
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