Commit 3e8e8e64 authored by Martin Jeřábek's avatar Martin Jeřábek

testwf: feature tests: wip

parent e5c26452
...@@ -64,21 +64,18 @@ USE ieee.math_real.ALL; ...@@ -64,21 +64,18 @@ USE ieee.math_real.ALL;
use work.CANconstants.all; use work.CANconstants.all;
USE work.CANtestLib.All; USE work.CANtestLib.All;
USE work.randomLib.All; USE work.randomLib.All;
use work.pkg_feature_exec_dispath.all;
use work.CAN_FD_register_map.all; use work.CAN_FD_register_map.all;
package abort_transmittion_feature is package abort_transmittion_feature is
procedure abort_transmittion_feature_exec( procedure abort_transmittion_feature_exec(
variable outcome : inout boolean; variable o : out feature_outputs_t;
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 iout : in instance_inputs_arr_t;
signal mem_bus_2 : inout Avalon_mem_type; signal mem_bus : inout mem_bus_arr_t;
signal bus_level : in std_logic; signal bus_level : in std_logic
signal drv_bus_1 : in std_logic_vector(1023 downto 0);
signal drv_bus_2 : in std_logic_vector(1023 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;
...@@ -87,15 +84,11 @@ end package; ...@@ -87,15 +84,11 @@ end package;
package body abort_transmittion_feature is package body abort_transmittion_feature is
procedure abort_transmittion_feature_exec( procedure abort_transmittion_feature_exec(
variable outcome : inout boolean; variable o : out feature_outputs_t;
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 iout : in instance_inputs_arr_t;
signal mem_bus_2 : inout Avalon_mem_type; signal mem_bus : inout mem_bus_arr_t;
signal bus_level : in std_logic; signal bus_level : in std_logic
signal drv_bus_1 : in std_logic_vector(1023 downto 0);
signal drv_bus_2 : in std_logic_vector(1023 downto 0);
signal stat_bus_1 : in std_logic_vector(511 downto 0);
signal stat_bus_2 : in std_logic_vector(511 downto 0)
)is )is
variable r_data : std_logic_vector(31 downto 0) := variable r_data : std_logic_vector(31 downto 0) :=
(OTHERS => '0'); (OTHERS => '0');
...@@ -115,7 +108,7 @@ package body abort_transmittion_feature is ...@@ -115,7 +108,7 @@ package body abort_transmittion_feature is
variable command : SW_command := (false, false, false); variable command : SW_command := (false, false, false);
variable status : SW_status; variable status : SW_status;
begin begin
outcome := true; o.outcome := true;
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Generate CAN frame -- Generate CAN frame
...@@ -125,13 +118,13 @@ package body abort_transmittion_feature is ...@@ -125,13 +118,13 @@ package body abort_transmittion_feature is
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Insert the frame for transmittion -- Insert the frame for transmittion
------------------------------------------------------------------------ ------------------------------------------------------------------------
CAN_send_frame(CAN_frame, 1, ID_1, mem_bus_1, frame_sent); CAN_send_frame(CAN_frame, 1, ID_1, mem_bus(1), frame_sent);
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Wait until unit turns transmitter -- Wait until unit turns transmitter
------------------------------------------------------------------------ ------------------------------------------------------------------------
loop loop
get_controller_status(status, ID_1, mem_bus_1); get_controller_status(status, ID_1, mem_bus(1));
if (status.transmitter) then if (status.transmitter) then
exit; exit;
end if; end if;
...@@ -143,7 +136,7 @@ package body abort_transmittion_feature is ...@@ -143,7 +136,7 @@ package body abort_transmittion_feature is
-- aborts immediately after the frame was commited and SOF was not -- aborts immediately after the frame was commited and SOF was not
-- yet sent! -- yet sent!
------------------------------------------------------------------------ ------------------------------------------------------------------------
wait_rand_cycles(rand_ctr, mem_bus_1.clk_sys, 200, 25000); wait_rand_cycles(rand_ctr, mem_bus(1).clk_sys, 200, 25000);
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Check that unit is not transciever anymore, unit should be now as if -- Check that unit is not transciever anymore, unit should be now as if
...@@ -151,7 +144,7 @@ package body abort_transmittion_feature is ...@@ -151,7 +144,7 @@ package body abort_transmittion_feature is
-- space. So we check the PC_State from status bus explicitly. -- space. So we check the PC_State from status bus explicitly.
------------------------------------------------------------------------ ------------------------------------------------------------------------
PC_State := protocol_type'VAL(to_integer(unsigned( PC_State := protocol_type'VAL(to_integer(unsigned(
stat_bus_1(STAT_PC_STATE_HIGH downto STAT_PC_STATE_LOW)))); iout(1).stat_bus(STAT_PC_STATE_HIGH downto STAT_PC_STATE_LOW))));
report "PC State: " & protocol_type'Image(PC_State); report "PC State: " & protocol_type'Image(PC_State);
if (PC_State = sof or PC_State = arbitration or PC_State = control or if (PC_State = sof or PC_State = arbitration or PC_State = control or
...@@ -169,18 +162,18 @@ package body abort_transmittion_feature is ...@@ -169,18 +162,18 @@ package body abort_transmittion_feature is
-- Now send the command to abort the transmittion -- Now send the command to abort the transmittion
-------------------------------------------------------------------- --------------------------------------------------------------------
command.abort_transmission := true; command.abort_transmission := true;
give_controller_command(command, ID_1, mem_bus_1); give_controller_command(command, ID_1, mem_bus(1));
-------------------------------------------------------------------- --------------------------------------------------------------------
-- Now wait for few clock cycles until Node aborts the transmittion -- Now wait for few clock cycles until Node aborts the transmittion
-------------------------------------------------------------------- --------------------------------------------------------------------
for i in 0 to 5 loop for i in 0 to 5 loop
wait until rising_edge(mem_bus_1.clk_sys); wait until rising_edge(mem_bus(1).clk_sys);
end loop; end loop;
get_controller_status(status, ID_1, mem_bus_1); get_controller_status(status, ID_1, mem_bus(1));
if (status.transmitter) then if (status.transmitter) then
outcome := false; o.outcome := false;
end if; end if;
-------------------------------------------------------------------- --------------------------------------------------------------------
...@@ -191,28 +184,28 @@ package body abort_transmittion_feature is ...@@ -191,28 +184,28 @@ package body abort_transmittion_feature is
-- frame. It stays idle since it recieves recessive error passive -- frame. It stays idle since it recieves recessive error passive
-- error frame from 2! -- error frame from 2!
-------------------------------------------------------------------- --------------------------------------------------------------------
CAN_wait_error_transmitted(ID_2, mem_bus_2); CAN_wait_error_transmitted(ID_2, mem_bus(2));
-------------------------------------------------------------------- --------------------------------------------------------------------
-- Now wait until bus is idle in both units -- Now wait until bus is idle in both units
-------------------------------------------------------------------- --------------------------------------------------------------------
CAN_wait_bus_idle(ID_2, mem_bus_2); CAN_wait_bus_idle(ID_2, mem_bus(2));
CAN_wait_bus_idle(ID_1, mem_bus_1); CAN_wait_bus_idle(ID_1, mem_bus(1));
else else
-------------------------------------------------------------------- --------------------------------------------------------------------
-- Now wait until bus is idle in both units -- Now wait until bus is idle in both units
-------------------------------------------------------------------- --------------------------------------------------------------------
CAN_wait_bus_idle(ID_2, mem_bus_2); CAN_wait_bus_idle(ID_2, mem_bus(2));
CAN_wait_bus_idle(ID_1, mem_bus_1); CAN_wait_bus_idle(ID_1, mem_bus(1));
-------------------------------------------------------------------- --------------------------------------------------------------------
-- Check that unit is now idle since it is after transmittion already -- Check that unit is now idle since it is after transmittion already
-------------------------------------------------------------------- --------------------------------------------------------------------
get_controller_status(status, ID_1, mem_bus_1); get_controller_status(status, ID_1, mem_bus(1));
if (not status.bus_status) then if (not status.bus_status) then
outcome := false; o.outcome := false;
end if; end if;
end if; end if;
...@@ -228,7 +221,7 @@ package body abort_transmittion_feature is ...@@ -228,7 +221,7 @@ package body abort_transmittion_feature is
err_counters.err_fd := 0; err_counters.err_fd := 0;
err_counters.rx_counter := 0; err_counters.rx_counter := 0;
err_counters.tx_counter := 0; err_counters.tx_counter := 0;
set_error_counters(err_counters, ID_1, mem_bus_1); set_error_counters(err_counters, ID_1, mem_bus(1));
end procedure; end procedure;
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
-- 5. Insert frames for transmission and give "set_ready" command. -- 5. Insert frames for transmission and give "set_ready" command.
-- 6. Wait until units start transmission. -- 6. Wait until units start transmission.
-- 7. Wait until one of the units turn receiver or collision appears. -- 7. Wait until one of the units turn receiver or collision appears.
-- 8. Compare expected outcome with actual outcome. -- 8. Compare expected o.outcome with actual o.outcome.
-- 9. Wait until bus is idle. -- 9. Wait until bus is idle.
-- --
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
...@@ -76,75 +76,64 @@ USE ieee.math_real.ALL; ...@@ -76,75 +76,64 @@ USE ieee.math_real.ALL;
use work.CANconstants.all; use work.CANconstants.all;
USE work.CANtestLib.All; USE work.CANtestLib.All;
USE work.randomLib.All; USE work.randomLib.All;
use work.pkg_feature_exec_dispath.all;
use work.CAN_FD_register_map.all; use work.CAN_FD_register_map.all;
use work.CAN_FD_frame_format.all; use work.CAN_FD_frame_format.all;
package arbitration_feature is package arbitration_feature is
procedure arbitration_feature_exec( procedure arbitration_feature_exec(
variable outcome :inout boolean; variable o : out feature_outputs_t;
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 iout : in instance_inputs_arr_t;
signal mem_bus_2 :inout Avalon_mem_type; signal mem_bus : inout mem_bus_arr_t;
signal bus_level :in std_logic; signal bus_level : in std_logic
signal drv_bus_1 :in std_logic_vector(1023 downto 0);
signal drv_bus_2 :in std_logic_vector(1023 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 Arbitration_feature is package body Arbitration_feature is
procedure arbitration_feature_exec( procedure arbitration_feature_exec(
variable outcome :inout boolean; variable o : out feature_outputs_t;
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 iout : in instance_inputs_arr_t;
signal mem_bus_2 :inout Avalon_mem_type; signal mem_bus : inout mem_bus_arr_t;
signal bus_level :in std_logic; signal bus_level : in std_logic
signal drv_bus_1 :in std_logic_vector(1023 downto 0);
signal drv_bus_2 :in std_logic_vector(1023 downto 0);
signal stat_bus_1 :in std_logic_vector(511 downto 0);
signal stat_bus_2 :in std_logic_vector(511 downto 0)
) is ) is
variable rand_value : real; variable rand_value : real;
variable alc : natural; variable alc : natural;
-- 0-Node 1; 1-Node 2; 2-Collision -- 0-Node 1; 1-Node 2; 2-Collision
variable exp_winner : natural := 0; variable exp_winner : natural := 0;
-- Some unit lost the arbitration... -- Some unit lost the arbitration...
-- 0 - initial , 1-Node 1 turned rec, 2 - Node 2 turned rec -- 0 - initial , 1-Node 1 turned rec, 2 - Node 2 turned rec
variable unit_rec : natural := 0; variable unit_rec : natural := 0;
variable ID_1 : natural := 1; variable ID_1 : natural := 1;
variable ID_2 : natural := 2; variable ID_2 : natural := 2;
variable r_data : std_logic_vector(31 downto 0) := variable r_data : std_logic_vector(31 downto 0) :=
(OTHERS => '0'); (OTHERS => '0');
-- Generated frames -- Generated frames
variable frame_1 : SW_CAN_frame_type; variable frame_1 : SW_CAN_frame_type;
variable frame_2 : SW_CAN_frame_type; variable frame_2 : SW_CAN_frame_type;
-- Node status -- Node status
variable stat_1 : SW_status; variable stat_1 : SW_status;
variable stat_2 : SW_status; variable stat_2 : SW_status;
-- Temporary variables for IDs recalculated to decimal value with -- Temporary variables for IDs recalculated to decimal value with
-- identifier type taken into account -- identifier type taken into account
variable ident_1 : natural; variable ident_1 : natural;
variable ident_2 : natural; variable ident_2 : natural;
begin begin
outcome := true; o.outcome := true;
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Forbid retransmitt limiting! -- Forbid retransmitt limiting!
------------------------------------------------------------------------ ------------------------------------------------------------------------
CAN_enable_retr_limit(false, 0, ID_1, mem_bus_1); CAN_enable_retr_limit(false, 0, ID_1, mem_bus(1));
CAN_enable_retr_limit(false, 0, ID_2, mem_bus_2); CAN_enable_retr_limit(false, 0, ID_2, mem_bus(2));
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Generate Two random CAN Frames. -- Generate Two random CAN Frames.
...@@ -268,21 +257,21 @@ package body Arbitration_feature is ...@@ -268,21 +257,21 @@ package body Arbitration_feature is
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Insert both frames to transmitt. -- Insert both frames to transmitt.
------------------------------------------------------------------------ ------------------------------------------------------------------------
CAN_insert_TX_frame(frame_1, 1, ID_1, mem_bus_1); CAN_insert_TX_frame(frame_1, 1, ID_1, mem_bus(1));
CAN_insert_TX_frame(frame_2, 1, ID_2, mem_bus_2); CAN_insert_TX_frame(frame_2, 1, ID_2, mem_bus(2));
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Give "set_ready" command to TXT Buffers in both CAN Nodes! -- Give "set_ready" command to TXT Buffers in both CAN Nodes!
------------------------------------------------------------------------ ------------------------------------------------------------------------
send_TXT_buf_cmd(buf_set_ready, 1, ID_1, mem_bus_1); send_TXT_buf_cmd(buf_set_ready, 1, ID_1, mem_bus(1));
send_TXT_buf_cmd(buf_set_ready, 1, ID_2, mem_bus_2); send_TXT_buf_cmd(buf_set_ready, 1, ID_2, mem_bus(2));
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Now we have to wait until both units starts to transmitt!!! -- Now we have to wait until both units starts to transmitt!!!
------------------------------------------------------------------------ ------------------------------------------------------------------------
loop loop
get_controller_status(stat_1, ID_1, mem_bus_1); get_controller_status(stat_1, ID_1, mem_bus(1));
get_controller_status(stat_2, ID_2, mem_bus_2); get_controller_status(stat_2, ID_2, mem_bus(2));
if (stat_1.transmitter and stat_2.transmitter) then if (stat_1.transmitter and stat_2.transmitter) then
exit; exit;
end if; end if;
...@@ -294,8 +283,8 @@ package body Arbitration_feature is ...@@ -294,8 +283,8 @@ package body Arbitration_feature is
------------------------------------------------------------------------ ------------------------------------------------------------------------
while (unit_rec = 0) loop while (unit_rec = 0) loop
get_controller_status(stat_1, ID_1, mem_bus_1); get_controller_status(stat_1, ID_1, mem_bus(1));
get_controller_status(stat_2, ID_2, mem_bus_2); get_controller_status(stat_2, ID_2, mem_bus(2));
-- Unit 1 turned reciever -- Unit 1 turned reciever
if (stat_1.receiver) then if (stat_1.receiver) then
...@@ -333,25 +322,25 @@ package body Arbitration_feature is ...@@ -333,25 +322,25 @@ package body Arbitration_feature is
report "Frame 2:"; report "Frame 2:";
CAN_print_frame(frame_2, info_l); CAN_print_frame(frame_2, info_l);
outcome := false; o.outcome := false;
end if; end if;
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Send abort transmission to both frames so that no unit will -- Send abort transmission to both frames so that no unit will
-- attempt to retransmitt. -- attempt to retransmitt.
------------------------------------------------------------------------ ------------------------------------------------------------------------
send_TXT_buf_cmd(buf_set_abort, 1, ID_1, mem_bus_1); send_TXT_buf_cmd(buf_set_abort, 1, ID_1, mem_bus(1));
send_TXT_buf_cmd(buf_set_abort, 1, ID_2, mem_bus_2); send_TXT_buf_cmd(buf_set_abort, 1, ID_2, mem_bus(2));
CAN_wait_frame_sent(ID_1, mem_bus_1); CAN_wait_frame_sent(ID_1, mem_bus(1));
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Check what is the value in the ALC register -- Check what is the value in the ALC register
------------------------------------------------------------------------ ------------------------------------------------------------------------
if (unit_rec = 1) then if (unit_rec = 1) then
read_alc(alc, ID_1, mem_bus_1); read_alc(alc, ID_1, mem_bus(1));
elsif (unit_rec = 2) then elsif (unit_rec = 2) then
read_alc(alc, ID_2, mem_bus_2); read_alc(alc, ID_2, mem_bus(2));
end if; end if;
-- TODO: Compare ALC value with expected value where node should -- TODO: Compare ALC value with expected value where node should
...@@ -368,7 +357,7 @@ package body Arbitration_feature is ...@@ -368,7 +357,7 @@ package body Arbitration_feature is
report "Frame 2:"; report "Frame 2:";
CAN_print_frame(frame_2, info_l); CAN_print_frame(frame_2, info_l);
outcome := false; o.outcome := false;
end if; end if;
wait for 100000 ns; wait for 100000 ns;
......
...@@ -54,39 +54,29 @@ USE ieee.math_real.ALL; ...@@ -54,39 +54,29 @@ USE ieee.math_real.ALL;
use work.CANconstants.all; use work.CANconstants.all;
USE work.CANtestLib.All; USE work.CANtestLib.All;
USE work.randomLib.All; USE work.randomLib.All;
use work.pkg_feature_exec_dispath.all;
use work.CAN_FD_register_map.all; use work.CAN_FD_register_map.all;
package fault_confinement_feature is package fault_confinement_feature is
procedure fault_confinement_feature_exec( procedure fault_confinement_feature_exec(
variable outcome : inout boolean; variable o : out feature_outputs_t;
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 iout : in instance_inputs_arr_t;
signal mem_bus_2 : inout Avalon_mem_type; signal mem_bus : inout mem_bus_arr_t;
signal bus_level : in std_logic; signal bus_level : in std_logic
signal drv_bus_1 : in std_logic_vector(1023 downto 0);
signal drv_bus_2 : in std_logic_vector(1023 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_confinement_feature is package body fault_confinement_feature is
procedure fault_confinement_feature_exec( procedure fault_confinement_feature_exec(
variable outcome : inout boolean; variable o : out feature_outputs_t;
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 iout : in instance_inputs_arr_t;
signal mem_bus_2 : inout Avalon_mem_type; signal mem_bus : inout mem_bus_arr_t;
signal bus_level : in std_logic; signal bus_level : in std_logic
signal drv_bus_1 : in std_logic_vector(1023 downto 0); ) is
signal drv_bus_2 : in std_logic_vector(1023 downto 0);
signal stat_bus_1 : in std_logic_vector(511 downto 0);
signal stat_bus_2 : in std_logic_vector(511 downto 0)
)is
variable r_data : std_logic_vector(31 downto 0) := variable r_data : std_logic_vector(31 downto 0) :=
(OTHERS => '0'); (OTHERS => '0');
variable CAN_frame : SW_CAN_frame_type; variable CAN_frame : SW_CAN_frame_type;
...@@ -105,7 +95,7 @@ package body fault_confinement_feature is ...@@ -105,7 +95,7 @@ package body fault_confinement_feature is
variable fault_th_2 : SW_fault_thresholds := (0, 0); variable fault_th_2 : SW_fault_thresholds := (0, 0);
variable fault_state : SW_fault_state; variable fault_state : SW_fault_state;
begin begin
outcome := true; o.outcome := true;
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Generate random setting of ERP treshold and RX counters to preset -- Generate random setting of ERP treshold and RX counters to preset
...@@ -123,43 +113,43 @@ package body fault_confinement_feature is ...@@ -123,43 +113,43 @@ package body fault_confinement_feature is
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Set the counter and tresholds -- Set the counter and tresholds
------------------------------------------------------------------------ ------------------------------------------------------------------------
set_error_counters(err_counters, 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); set_fault_thresholds(fault_th, ID_1, mem_bus(1));
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Read counters back -- Read counters back
------------------------------------------------------------------------ ------------------------------------------------------------------------
get_fault_thresholds(fault_th_2, ID_1, mem_bus_1); get_fault_thresholds(fault_th_2, ID_1, mem_bus(1));
if (fault_th.ewl /= fault_th_2.ewl) then if (fault_th.ewl /= fault_th_2.ewl) then
outcome := false; o.outcome := false;
end if; end if;
if (fault_th.erp /= fault_th_2.erp) then if (fault_th.erp /= fault_th_2.erp) then
outcome := false; o.outcome := false;
end if; end if;
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Read fault confinement state -- Read fault confinement state
------------------------------------------------------------------------ ------------------------------------------------------------------------
get_fault_state(fault_state, ID_1, mem_bus_1); get_fault_state(fault_state, ID_1, mem_bus(1));
if (err_counters.tx_counter > 255 or if (err_counters.tx_counter > 255 or
err_counters.rx_counter > 255) err_counters.rx_counter > 255)
then then
if (fault_state /= fc_bus_off) then if (fault_state /= fc_bus_off) then
outcome := false; o.outcome := false;
end if; end if;
elsif (err_counters.tx_counter < fault_th.ewl and elsif (err_counters.tx_counter < fault_th.ewl and
err_counters.rx_counter < fault_th.ewl) err_counters.rx_counter < fault_th.ewl)
then then