Commit 0e5a9acc authored by Ille, Ondrej, Ing.'s avatar Ille, Ondrej, Ing.

Merge branch '172-code-coverage-improvements' into 'master'

Resolve "Code coverage improvements"

Closes #172

See merge request illeondr/CAN_FD_IP_Core!133
parents d19a7524 199cfe87
Pipeline #1624 failed with stages
in 46 seconds
......@@ -1049,20 +1049,26 @@ begin
-- pragma translate_off
if (rising_edge(clk_sys) and now /= 0 fs) then
if (store_metadata = '1' and rx_fsm /= rxb_idle) then
-- LCOV_EXCL_START
report "RX Buffer: Store metadata command did NOT come during " &
"'rx_buf_idle'!"severity error;
"'rx_buf_idle'!"severity error;
-- LCOV_EXCL_STOP
end if;
if ((rec_message_valid = '1' or store_data = '1') and
rx_fsm /= rxb_store_data)
then
-- LCOV_EXCL_START
report "RX Buffer: Store data or finish storing did NOT come " &
"during 'rec_data'" severity error;
"during 'rec_data'" severity error;
-- LCOV_EXCL_STOP
end if;
if (sof_pulse = '1' and rx_fsm /= rxb_idle) then
-- LCOV_EXCL_START
report "RX Buffer: SOF pulse should come during 'rx_fsm_idle'"
severity error;
-- LCOV_EXCL_STOP
end if;
cmd_join := store_metadata & store_data & rec_message_valid &
......@@ -1070,8 +1076,10 @@ begin
if (cmd_join /= "0000" and cmd_join /= "0001" and cmd_join /= "0010"
and cmd_join /= "0100" and cmd_join /= "1000")
then
-- LCOV_EXCL_START
report "RX Buffer: One-hot coding on RX Buffer commands " &
"corrupted!" severity error;
-- LCOV_EXCL_STOP
end if;
end if;
-- pragma translate_on
......
......@@ -173,10 +173,6 @@ begin
enable_prev <= enable;
dst_bit_ctr <= dst_bit_ctr;
if ((length = "000" or length = "001") and (enable = '1')) then
report "0 and 1 bit stuffing length is invalid" severity warning;
end if;
if (enable = '1') then
-- When transition starts prev_val needs to be deleted! Otherwise
......@@ -278,11 +274,27 @@ begin
end if;
end process;
-- Register propagation on output
data_out <= data_in;
destuffed <= destuffed_reg;
stuff_Error <= error_reg;
dst_ctr <= dst_bit_ctr;
----------------------------------------------------------------------------
-- Assertions on input settings
----------------------------------------------------------------------------
input_length_assert_proc : process(clk_sys)
begin
if (rising_edge(clk_sys)) then
if ((length = "000" or length = "001") and (enable = '1')) then
-- LCOV_EXCL_START
report "0 and 1 bit stuffing length is invalid!" severity warning;
-- LCOV_EXCL_STOP
end if;
end if;
end process;
-- Register propagation on output
data_out <= data_in;
destuffed <= destuffed_reg;
stuff_Error <= error_reg;
dst_ctr <= dst_bit_ctr;
end architecture;
......@@ -425,10 +425,13 @@ begin
-- pragma translate_off
if (rising_edge(clk_sys) and now /= 0 fs) then
if (joined_ctr /= "000" and joined_ctr /= "001" and
joined_ctr /= "010" and joined_ctr /= "100") then
joined_ctr /= "010" and joined_ctr /= "100")
then
-- LCOV_EXCL_START
report "Error counters commands from Protocol Control to " &
"Fault confinemnet corrupt one hot decoding" severity
error;
-- LCOV_EXCL_STOP
end if;
end if;
-- pragma translate_on
......
......@@ -175,7 +175,10 @@ package body abort_transmittion_feature is
get_controller_status(status, ID_1, mem_bus(1));
if (status.transmitter) then
-- LCOV_EXCL_START
o.outcome := false;
report "Unit did not abort the transmission!" severity error;
-- LCOV_EXCL_STOP
end if;
--------------------------------------------------------------------
......@@ -207,7 +210,10 @@ package body abort_transmittion_feature is
--------------------------------------------------------------------
get_controller_status(status, ID_1, mem_bus(1));
if (not status.bus_status) then
-- LCOV_EXCL_START
report "Unit is not Idle!" severity error;
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
end if;
......
......@@ -315,6 +315,7 @@ package body Arbitration_feature is
if (unit_rec = 1 and exp_winner = 0) or
(unit_rec = 2 and exp_winner = 1)
then
-- LCOV_EXCL_START
report "Wrong unit lost arbitration. Expected: " &
integer'image(exp_winner) & " Real: " & integer'image(unit_rec)
severity error;
......@@ -325,6 +326,7 @@ package body Arbitration_feature is
CAN_print_frame(frame_2, info_l);
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
------------------------------------------------------------------------
......@@ -349,6 +351,7 @@ package body Arbitration_feature is
-- If error frame is transmitted and collision not have appeared
------------------------------------------------------------------------
if (unit_rec = 3 and exp_winner /= 2) then
-- LCOV_EXCL_START
report "Collision should have appeared" severity error;
report "Frame 1:";
......@@ -357,6 +360,7 @@ package body Arbitration_feature is
CAN_print_frame(frame_2, info_l);
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
wait for 100000 ns;
......
......@@ -79,10 +79,10 @@ package body byte_enable_feature is
signal bus_level : in std_logic
) is
variable data : std_logic_vector(31 downto 0) :=
(OTHERS => '0');
variable address : std_logic_vector(11 downto 0) :=
(OTHERS => '0');
variable ID : natural := 1;
(OTHERS => '0');
variable address : std_logic_vector(11 downto 0) :=
(OTHERS => '0');
variable ID : natural := 1;
begin
o.outcome := true;
......@@ -93,8 +93,10 @@ package body byte_enable_feature is
CAN_read(data, address, ID, mem_bus(1), BIT_32);
if (data /= x"DEADBEEF") then
-- LCOV_EXCL_START
o.outcome := false;
report "32 bit read error" severity error;
-- LCOV_EXCL_STOP
end if;
------------------------------------------------------------------------
......@@ -110,16 +112,20 @@ package body byte_enable_feature is
if (data(16 * i + 15 downto 16 * i) /=
YOLO_VAL_RSTVAL(16 * i + 15 downto 16 * i))
then
-- LCOV_EXCL_START
report "16 bit read error (valid byte), Index :" &
Integer'image(i) severity error;
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
-- Checking invalid 2 bytes are 0
if (data(16 * (1 - i) + 15 downto 16 * (1 - i)) /= x"0000") then
-- LCOV_EXCL_START
report "16 bit read error (empty byte), Index :" &
Integer'image(i) severity error;
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
end loop;
......@@ -136,39 +142,49 @@ package body byte_enable_feature is
if (data(8 * i + 7 downto 8 * i) /=
YOLO_VAL_RSTVAL(8 * i + 7 downto 8 * i))
then
-- LCOV_EXCL_START
o.outcome := false;
report "8 bit read error (valid byte), Index :" &
Integer'image(i) severity error;
Integer'image(i) severity error;
-- LCOV_EXCL_STOP
end if;
-- Checking if other bytes are 0
case i is
when 0 =>
if (data(31 downto 8) /= x"000000") then
-- LCOV_EXCL_START
o.outcome := false;
report "8 bit read error (Empty byte 0)" severity error;
-- LCOV_EXCL_STOP
end if;
when 1 =>
if (data(31 downto 16) /= x"0000" or
data(7 downto 0) /= x"00")
then
-- LCOV_EXCL_START
o.outcome := false;
report "8 bit read error (Empty byte 1)" severity error;
-- LCOV_EXCL_STOP
end if;
when 2 =>
if (data(31 downto 24) /= x"00" or
data(15 downto 0) /= x"0000")
then
-- LCOV_EXCL_START
o.outcome := false;
report "8 bit read error (Empty byte 2)" severity error;
-- LCOV_EXCL_STOP
end if;
when 3 =>
if (data(23 downto 0) /= x"000000") then
-- LCOV_EXCL_START
o.outcome := false;
report "8 bit read error (Empty byte 3)" severity error;
-- LCOV_EXCL_STOP
end if;
when others =>
report "Invalid byte index" severity error;
report "Invalid byte index" severity error; -- LCOV_EXCL_LINE
end case;
end loop;
......@@ -195,39 +211,49 @@ package body byte_enable_feature is
-- Checking if one written byte was written OK!
if (data(8 * i + 7 downto 8 * i) /= x"0A") then
-- LCOV_EXCL_START
o.outcome := false;
report "8 bit write error (valid byte), Index :" &
Integer'image(i) severity error;
Integer'image(i) severity error;
-- LCOV_EXCL_STOP
end if;
-- Checking if other bytes are 0
case i is
when 0 =>
if (data(31 downto 8) /= x"000000") then
-- LCOV_EXCL_START
o.outcome := false;
report "8 bit write error (Empty byte 0)" severity error;
-- LCOV_EXCL_STOP
end if;
when 1 =>
if (data(31 downto 16) /= x"0000" or
data(7 downto 0) /= x"00")
then
-- LCOV_EXCL_START
o.outcome := false;
report "8 bit write error (Empty byte 1)" severity error;
-- LCOV_EXCL_STOP
end if;
when 2 =>
if (data(31 downto 24) /= x"00" or
data(15 downto 0) /= x"0000")
then
-- LCOV_EXCL_START
o.outcome := false;
report "8 bit write error (Empty byte 2)" severity error;
-- LCOV_EXCL_STOP
end if;
when 3 =>
if (data(23 downto 0) /= x"000000") then
-- LCOV_EXCL_START
o.outcome := false;
report "8 bit write error (Empty byte 3)" severity error;
-- LCOV_EXCL_STOP
end if;
when others =>
report "Invalid byte index" severity error;
report "Invalid byte index" severity error; -- LCOV_EXCL_LINE
end case;
end loop;
......
......@@ -125,15 +125,20 @@ package body data_length_code_feature is
if (CAN_frame_2.rwcnt /= 5 or
CAN_frame_2.dlc /= CAN_frame.dlc)
then
-- LCOV_EXCL_START
o.outcome := false;
CAN_print_frame(CAN_frame_2, info_l);
report "Invalid DLC received!" severity error;
-- LCOV_EXCL_STOP
end if;
for i in 8 to 63 loop
if (CAN_frame_2.data(i) /= "00000000") then
-- LCOV_EXCL_START
o.outcome := false;
report "Byte index " & integer'image(i) & " not zero!"
severity error;
-- LCOV_EXCL_STOP
end if;
end loop;
......
......@@ -125,11 +125,19 @@ package body fault_confinement_feature is
get_fault_thresholds(fault_th_2, ID_1, mem_bus(1));
if (fault_th.ewl /= fault_th_2.ewl) then
-- LCOV_EXCL_START
o.outcome := false;
report "Error warning limit threshold was not set properly!"
severity error;
-- LCOV_EXCL_START
end if;
if (fault_th.erp /= fault_th_2.erp) then
-- LCOV_EXCL_START
o.outcome := false;
report "Error passive threshold was not set properly!"
severity error;
-- LCOV_EXCL_STOP
end if;
------------------------------------------------------------------------
......@@ -141,17 +149,29 @@ package body fault_confinement_feature is
err_counters.rx_counter > 255)
then
if (fault_state /= fc_bus_off) then
-- LCOV_EXCL_START
o.outcome := false;
report "Unit not Bus off as expected!"
severity error;
-- LCOV_EXCL_STOP
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
-- LCOV_EXCL_START
o.outcome := false;
report "Unit not Error Active as expected!"
severity error;
-- LCOV_EXCL_STOP
end if;
else
if (fault_state /= fc_error_passive) then
-- LCOV_EXCL_START
o.outcome := false;
report "Unit not Error Passive as expected!"
severity error;
-- LCOV_EXCL_STOP
end if;
end if;
......
......@@ -140,7 +140,10 @@ package body forbid_fd_feature is
-- Counter should be increased
if ((err_counters_1.rx_counter + 1 + 8) /= err_counters_2.rx_counter) then
-- LCOV_EXCL_START
o.outcome := false;
report "RX Error counter not incremented as expected!" severity error;
-- LCOV_EXCL_STOP
end if;
------------------------------------------------------------------------
......@@ -161,7 +164,10 @@ package body forbid_fd_feature is
-- detected the error!
------------------------------------------------------------------------
if ((err_counters_1.rx_counter + 8) /= err_counters_2.rx_counter) then
-- LCOV_EXCL_START
o.outcome := false;
report "RX Error counter not incremented as expected!" severity error;
-- LCOV_EXCL_STOP
end if;
------------------------------------------------------------------------
......@@ -188,7 +194,10 @@ package body forbid_fd_feature is
-- zeroes when counter cannnot already be lowered...
------------------------------------------------------------------------
if ((err_counters_1.rx_counter + 7) /= err_counters_2.rx_counter) then
-- LCOV_EXCL_START
o.outcome := false;
report "RX Error counter not decremented as expected!" severity error;
-- LCOV_EXCL_STOP
end if;
------------------------------------------------------------------------
......
......@@ -168,7 +168,10 @@ package body interrupt_feature is
------------------------------------------------------------------------
read_int_status(int_stat, ID_1, mem_bus(1));
if (not int_stat.receive_int) then
-- LCOV_EXCL_START
o.outcome := false;
report "RX Interrupt not present!" severity error;
-- LCOV_EXCL_STOP
end if;
clear_int_status(int_stat, ID_1, mem_bus(1));
......@@ -210,14 +213,19 @@ package body interrupt_feature is
------------------------------------------------------------------------
read_int_status(int_stat, ID_1, mem_bus(1));
if (not int_stat.bus_error_int) then
-- LCOV_EXCL_START
o.outcome := false;
report "Bus error Interrput not present (Node 1)" severity error;
-- LCOV_EXCL_STOP
end if;
clear_int_status(int_stat, ID_1, mem_bus(1));
read_int_status(int_stat, ID_2, mem_bus(2));
if (not int_stat.bus_error_int) then
report "FUCK" severity error;
-- LCOV_EXCL_START
report "Bus error Interrupt no present (Node 2)" severity error;
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
CAN_wait_frame_sent(ID_1, mem_bus(1));
clear_int_status(int_stat, ID_2, mem_bus(2));
......@@ -263,7 +271,11 @@ package body interrupt_feature is
-- fired and clear it!
if (i = (buf_info.rx_buff_size / 4)) then
if (iout(2).irq = '0') then
-- LCOV_EXCL_START
report "RX Buffer Full interrupt is not active!"
severity error;
o.outcome := false;
-- LCOV_EXCL_STOP
else
read_int_status(int_stat, ID_2, mem_bus(2));
clear_int_status(int_stat, ID_2, mem_bus(2));
......@@ -278,10 +290,17 @@ package body interrupt_feature is
read_int_status(int_stat, ID_2, mem_bus(2));
if (not int_stat.rx_buffer_full_int) then
-- LCOV_EXCL_START
o.outcome := false;
report "RX Buffer Full Interrupt not present!" severity error;
-- LCOV_EXCL_STOP
end if;
if (not int_stat.data_overrun_int) then
-- LCOV_EXCL_START
o.outcome := false;
report "Data overrun Interrupt not present!" severity error;
-- LCOV_EXCL_STOP
end if;
clear_int_status(int_stat, ID_2, mem_bus(2));
wait for 30000 ns;
......@@ -315,7 +334,10 @@ package body interrupt_feature is
------------------------------------------------------------------------
read_int_status(int_stat, ID_2, mem_bus(2));
if (not int_stat.bit_rate_shift_int) then
-- LCOV_EXCL_START
o.outcome := false;
report "Bit Rate shift interrupt not present" severity error;
-- LCOV_EXCL_STOP
end if;
CAN_wait_frame_sent(ID_2,mem_bus(2));
clear_int_status(int_stat, ID_2, mem_bus(2));
......@@ -348,7 +370,10 @@ package body interrupt_feature is
read_int_status(int_stat, ID_1, mem_bus(1));
if (not int_stat.arb_lost_int) then
-- LCOV_EXCL_START
o.outcome := false;
report "Arbitration Lost Interrupt not present!" severity error;
-- LCOV_EXCL_STOP
end if;
clear_int_status(int_stat, ID_1, mem_bus(1));
......
......@@ -115,7 +115,11 @@ package body invalid_configs_feature is
------------------------------------------------------------------------
CAN_read_frame(rx_frame, ID_2, mem_bus(2));
if (rx_frame.brs = BR_SHIFT or rx_frame.frame_format = FD_CAN) then
-- LCOV_EXCL_START
o.outcome := false;
report "Frame with BRS Bit or CAN FD Frame received!"
severity error;
-- LCOV_EXCL_STOP
end if;
......@@ -136,12 +140,18 @@ package body invalid_configs_feature is
CAN_send_frame(tx_frame, 1, ID_1, mem_bus(1), frame_sent);
CAN_wait_frame_sent(ID_1, mem_bus(1));
wait for 100 ns;
------------------------------------------------------------------------
-- Read frame. CAN FD Frame without RTR bit should be read
------------------------------------------------------------------------
CAN_read_frame(rx_frame, ID_2, mem_bus(2));
if (rx_frame.frame_format = NORMAL_CAN or rx_frame.rtr = RTR_FRAME) then
-- LCOV_EXCL_START
o.outcome := false;
report "CAN 2.0 Frame or RTR Flag Frame received!"
severity error;
-- LCOV_EXCL_STOP
end if;
end procedure;
......
......@@ -128,8 +128,10 @@ package body overload_feature is
iout(1).stat_bus(STAT_PC_STATE_HIGH downto STAT_PC_STATE_LOW)))) /=
overload)
then
report "Overload did not start";
-- LCOV_EXCL_START
report "Overload Frame did not start" severity error;
o.outcome:=false;
-- LCOV_EXCL_STOP
end if;
so.bl_inject <= RECESSIVE;
......
......@@ -138,14 +138,18 @@ package body retr_limit_feature is
get_tx_buf_state(1, buf_state, ID_1, mem_bus(1));
if (i /= retr_th) then
if (buf_state /= buf_ready) then
report "Buffer not ready";
-- LCOV_EXCL_START
report "TXT Buffer not ready" severity error;
o.outcome := false;
exit;
-- LCOV_EXCL_STOP
end if;
else
if (buf_state /= buf_failed) then
report "Buffer not failed";
-- LCOV_EXCL_START
report "TXT Buffer not failed" severity error;
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
end if;
end loop;
......@@ -156,9 +160,12 @@ package body retr_limit_feature is
------------------------------------------------------------------------
read_error_counters(err_counters, ID_1, mem_bus(1));
if (err_counters.tx_counter /= 8 * (retr_th + 1)) then
-- LCOV_EXCL_START
report "Counters exp: " & Integer'Image(err_counters.tx_counter) &
" coutners real: " & Integer'image(8 * (retr_th + 1));
" coutners real: " & Integer'image(8 * (retr_th + 1))
severity error;
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
------------------------------------------------------------------------
......
......@@ -138,7 +138,11 @@ package body rtr_pref_feature is
------------------------------------------------------------------------
CAN_send_frame(tx_frame, 1, ID_1, mem_bus(1), frame_sent);
if (not frame_sent) then
-- LCOV_EXCL_START
o.outcome := false;
report "Frame was not inserted for transmission properly!"
severity error;
-- LCOV_EXCL_STOP
end if;
CAN_wait_frame_sent(ID_2, mem_bus(2));
......@@ -147,7 +151,11 @@ package body rtr_pref_feature is
------------------------------------------------------------------------
CAN_read_frame(rx_frame, ID_2, mem_bus(2));
if (rx_frame.dlc /= x"0") then
-- LCOV_EXCL_START
o.outcome := false;
report "DLC of Received frame is not zero as expected"
severity error;
-- LCOV_EXCL_STOP
end if;
......@@ -173,7 +181,11 @@ package body rtr_pref_feature is
------------------------------------------------------------------------
CAN_send_frame(tx_frame, 1, ID_1, mem_bus(1), frame_sent);
if (not frame_sent) then
-- LCOV_EXCL_START
o.outcome := false;
report "Frame was not inserted for transmission properly!"
severity error;
-- LCOV_EXCL_STOP
end if;
CAN_wait_frame_sent(ID_2, mem_bus(2));
......@@ -182,7 +194,10 @@ package body rtr_pref_feature is
------------------------------------------------------------------------
CAN_read_frame(rx_frame, ID_2, mem_bus(2));
if (rx_frame.dlc /= tx_frame.dlc) then
-- LCOV_EXCL_START
o.outcome := false;
report "TX DLC is not equal to RX DLC" severity error;
-- LCOV_EXCL_STOP
end if;
end procedure;
......
......@@ -120,14 +120,22 @@ package body rx_status_feature is
-- Check that buffer is empty
------------------------------------------------------------------------
if (not buf_info.rx_empty) then