Commit 45cbe656 authored by Ille, Ondrej, Ing.'s avatar Ille, Ondrej, Ing.

test: VUnit use "check" library.

parent cd8426b6
......@@ -173,12 +173,7 @@ package body abort_transmittion_feature is
end loop;
get_controller_status(status, ID_1, mem_bus(1));
if (status.transmitter) then
-- LCOV_EXCL_START
o.outcome := false;
error("Unit did not abort the transmission!");
-- LCOV_EXCL_STOP
end if;
check_false(status.transmitter, "Unit did not abort the transmission!");
--------------------------------------------------------------------
-- Now wait until unit 2 starts transmitting error frame! Note that
......@@ -208,12 +203,7 @@ package body abort_transmittion_feature is
-- Check that unit is now idle since it is after transmittion already
--------------------------------------------------------------------
get_controller_status(status, ID_1, mem_bus(1));
if (not status.bus_status) then
-- LCOV_EXCL_START
error("Unit is not Idle!");
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
check(status.bus_status, "Unit is not Idle!");
end if;
......
......@@ -304,24 +304,22 @@ package body Arbitration_feature is
end if;
end loop;
------------------------------------------------------------------------
-- Print Frame info
------------------------------------------------------------------------
info("Frame 1:");
CAN_print_frame(frame_1, info_l);
info("Frame 2:");
CAN_print_frame(frame_2, info_l);
------------------------------------------------------------------------
-- Check whether expected winner is the unit which lost the arbitration
------------------------------------------------------------------------
if (unit_rec = 1 and exp_winner = 0) or
(unit_rec = 2 and exp_winner = 1)
then
-- LCOV_EXCL_START
info("Frame 1:");
CAN_print_frame(frame_1, info_l);
info("Frame 2:");
CAN_print_frame(frame_2, info_l);
error("Wrong unit lost arbitration. Expected: " &
integer'image(exp_winner) & " Real: " & integer'image(unit_rec));
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
check_false((unit_rec = 1 and exp_winner = 0) or
(unit_rec = 2 and exp_winner = 1),
"Wrong unit lost arbitration. Expected: " &
integer'image(exp_winner) &
" Real: " & integer'image(unit_rec));
------------------------------------------------------------------------
-- Send abort transmission to both frames so that no unit will
......@@ -342,20 +340,18 @@ package body Arbitration_feature is
end if;
------------------------------------------------------------------------
-- If error frame is transmitted and collision not have appeared
-- Print Frame info
------------------------------------------------------------------------
if (unit_rec = 3 and exp_winner /= 2) then
-- LCOV_EXCL_START
info("Frame 1:");
CAN_print_frame(frame_1, info_l);
info("Frame 2:");
CAN_print_frame(frame_2, info_l);
info("Frame 1:");
CAN_print_frame(frame_1, info_l);
info("Frame 2:");
CAN_print_frame(frame_2, info_l);
error("Collision should have appeared");
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
------------------------------------------------------------------------
-- If error frame is transmitted and collision not have appeared
------------------------------------------------------------------------
check_false(unit_rec = 3 and exp_winner /= 2,
"Collision should have appeared");
wait for 100000 ns;
end procedure;
......
......@@ -203,22 +203,14 @@ package body bus_start_feature is
get_rx_buf_state(rx_state, ID_1, mem_bus(1));
info("Read RX Buffer state");
if (rx_state.rx_empty) then
-- LCOV_EXCL_START
o.outcome := false;
error("RX Buffer is empty, but Frame should be received!");
-- LCOV_EXCL_STOP
end if;
check_false(rx_state.rx_empty,
"RX Buffer is empty, but Frame should be received!");
CAN_frame.identifier := 0;
CAN_read_frame(CAN_frame, ID_1, mem_bus(1));
if (CAN_frame.identifier /= 513) then
-- LCOV_EXCL_START
o.outcome := false;
error("Wrong Identifier received by Node 1. Expected: 513 , Real: " &
integer'image(CAN_frame.identifier));
-- LCOV_EXCL_STOP
end if;
check(CAN_frame.identifier = 513,
"Wrong Identifier received by Node 1! Expected: 513 , Real: " &
integer'image(CAN_frame.identifier));
------------------------------------------------------------------------
-- Now wait until Node 1 transmitts frame which lost the arbitration
......@@ -230,4 +222,4 @@ package body bus_start_feature is
end procedure;
end package body;
end package body;
\ No newline at end of file
......@@ -91,12 +91,7 @@ package body byte_enable_feature is
address := YOLO_REG_ADR;
CAN_read(data, address, ID, mem_bus(1), BIT_32);
if (data /= x"DEADBEEF") then
-- LCOV_EXCL_START
o.outcome := false;
error("32 bit read error");
-- LCOV_EXCL_STOP
end if;
check(data = x"DEADBEEF", "32 bit read error");
------------------------------------------------------------------------
-- Now read per half word (16 BIT)
......@@ -108,24 +103,13 @@ package body byte_enable_feature is
CAN_read(data, address, ID, mem_bus(1), BIT_16);
-- Checking if valid 2 bytes match register value
if (data(16 * i + 15 downto 16 * i) /=
YOLO_VAL_RSTVAL(16 * i + 15 downto 16 * i))
then
-- LCOV_EXCL_START
info("Read error - 16 bit access (valid byte), Index:");
error(integer'image(i));
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
check(data(16 * i + 15 downto 16 * i) =
YOLO_VAL_RSTVAL(16 * i + 15 downto 16 * i),
"Read error - 16 bit access (valid byte), Index:");
-- Checking invalid 2 bytes are 0
if (data(16 * (1 - i) + 15 downto 16 * (1 - i)) /= x"0000") then
-- LCOV_EXCL_START
info("Read error -16 bit access (empty byte), Index :");
error(integer'image(i));
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
check(data(16 * (1 - i) + 15 downto 16 * (1 - i)) = x"0000",
"Read error -16 bit access (empty byte), Index :");
end loop;
------------------------------------------------------------------------
......@@ -138,50 +122,27 @@ package body byte_enable_feature is
CAN_read(data, address, ID, mem_bus(1), BIT_8);
-- Checking if valid 1 byte matches register value
if (data(8 * i + 7 downto 8 * i) /=
YOLO_VAL_RSTVAL(8 * i + 7 downto 8 * i))
then
-- LCOV_EXCL_START
o.outcome := false;
info("Read error - 8 bit access (valid byte), Index :");
error(Integer'image(i));
-- LCOV_EXCL_STOP
end if;
check(data(8 * i + 7 downto 8 * i) =
YOLO_VAL_RSTVAL(8 * i + 7 downto 8 * i),
"Read error - 8 bit access (valid byte), Index :");
-- 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;
error("Read error - 8 bit (Empty byte 0)");
-- LCOV_EXCL_STOP
end if;
check(data(31 downto 8) = x"000000",
"Read error - 8 bit (Empty byte 0)");
when 1 =>
if (data(31 downto 16) /= x"0000" or
data(7 downto 0) /= x"00")
then
-- LCOV_EXCL_START
o.outcome := false;
error("Read error - 8 bit (Empty byte 1)");
-- LCOV_EXCL_STOP
end if;
check(data(31 downto 16) = x"0000" and
data(7 downto 0) = x"00",
"Read error - 8 bit (Empty byte 1)");
when 2 =>
if (data(31 downto 24) /= x"00" or
data(15 downto 0) /= x"0000")
then
-- LCOV_EXCL_START
o.outcome := false;
error("Read error - 8 bit (Empty byte 2)");
-- LCOV_EXCL_STOP
end if;
check(data(31 downto 24) = x"00" and
data(15 downto 0) = x"0000",
"Read error - 8 bit (Empty byte 2)");
when 3 =>
if (data(23 downto 0) /= x"000000") then
-- LCOV_EXCL_START
o.outcome := false;
error("Read error - 8 bit (Empty byte 3)");
-- LCOV_EXCL_STOP
end if;
check(data(23 downto 0) = x"000000",
"Read error - 8 bit (Empty byte 3)");
when others =>
error("Invalid byte index"); -- LCOV_EXCL_LINE
end case;
......@@ -209,48 +170,27 @@ package body byte_enable_feature is
CAN_read(data, address, ID, mem_bus(1), BIT_8);
-- 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;
info("Write error - 8 bit (valid byte), Index :");
error(Integer'image(i));
-- LCOV_EXCL_STOP
end if;
check(data(8 * i + 7 downto 8 * i) = x"0A",
"Write error - 8 bit (valid byte), Index :");
-- 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;
error("Write error - 8 bit (Empty byte 0)");
-- LCOV_EXCL_STOP
end if;
check(data(31 downto 8) = x"000000",
"Write error - 8 bit (Empty byte 0)");
when 1 =>
if (data(31 downto 16) /= x"0000" or
data(7 downto 0) /= x"00")
then
-- LCOV_EXCL_START
o.outcome := false;
error("Write error - 8 bit (Empty byte 1)");
-- LCOV_EXCL_STOP
end if;
check(data(31 downto 16) = x"0000" and
data(7 downto 0) = x"00",
"Write error - 8 bit (Empty byte 1)");
when 2 =>
if (data(31 downto 24) /= x"00" or
data(15 downto 0) /= x"0000")
then
-- LCOV_EXCL_START
o.outcome := false;
error("Write error - 8 bit (Empty byte 2)");
-- LCOV_EXCL_STOP
end if;
check(data(31 downto 24) = x"00" and
data(15 downto 0) = x"0000",
"Write error - 8 bit (Empty byte 2)");
when 3 =>
if (data(23 downto 0) /= x"000000") then
-- LCOV_EXCL_START
o.outcome := false;
error("Write error - 8 bit (Empty byte 3)");
-- LCOV_EXCL_STOP
end if;
check(data(23 downto 0) = x"000000",
"Write error - 8 bit (Empty byte 3)");
when others =>
error("Invalid byte index"); -- LCOV_EXCL_LINE
end case;
......@@ -258,4 +198,4 @@ package body byte_enable_feature is
end procedure;
end package body;
end package body;
\ No newline at end of file
......@@ -119,23 +119,12 @@ package body data_length_code_feature is
-- to 8!). Thus RWCNT field should be 5!
------------------------------------------------------------------------
CAN_read_frame(CAN_frame_2, ID_2, mem_bus(2));
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);
error("Invalid DLC received!");
-- LCOV_EXCL_STOP
end if;
check(CAN_frame_2.dlc = CAN_frame.dlc, "Invalid DLC received!");
check(CAN_frame_2.rwcnt = 5, "Invalid DLC received!");
for i in 8 to 63 loop
if (CAN_frame_2.data(i) /= "00000000") then
-- LCOV_EXCL_START
o.outcome := false;
error("Byte index " & integer'image(i) & " not zero!");
-- LCOV_EXCL_STOP
end if;
check(CAN_frame_2.data(i) = "00000000",
"Byte index " & integer'image(i) & " not zero!");
end loop;
end procedure;
......
......@@ -133,7 +133,7 @@ package body data_overrun_clear_feature is
CAN_wait_frame_sent(ID_1, mem_bus(1));
get_controller_status(status, ID_1, mem_bus(1));
if (status.data_overrun) then
error("Overrun Flag Detected!");
info("Overrun Flag Detected!");
exit;
end if;
end loop;
......@@ -142,9 +142,8 @@ package body data_overrun_clear_feature is
-- Check Interrupt Status on Data Overrun!
------------------------------------------------------------------------
read_int_status(interrupts, ID_1, mem_bus(1));
if (not interrupts.data_overrun_int) then
error("Data overrun Interrupt not captured as expected!");
end if;
check(interrupts.data_overrun_int,
"Data overrun Interrupt not captured as expected!");
------------------------------------------------------------------------
-- Clear data overrun flag and clear data overrun interrupt!
......@@ -158,9 +157,8 @@ package body data_overrun_clear_feature is
-- Read interrupt status and check data overrun was cleared!
------------------------------------------------------------------------
read_int_status(interrupts, ID_1, mem_bus(1));
if (interrupts.data_overrun_int) then
error("Data overrun Interrupt was not cleared!");
end if;
check_false(interrupts.data_overrun_int,
"Data overrun Interrupt was not cleared!");
end procedure;
......
......@@ -122,19 +122,11 @@ 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;
error("Error warning limit threshold was not set properly!");
-- LCOV_EXCL_START
end if;
check(fault_th.ewl = fault_th_2.ewl,
"Error warning limit threshold was not set properly!");
if (fault_th.erp /= fault_th_2.erp) then
-- LCOV_EXCL_START
o.outcome := false;
error("Error passive threshold was not set properly!");
-- LCOV_EXCL_STOP
end if;
check(fault_th.erp = fault_th_2.erp,
"Error passive threshold was not set properly!");
------------------------------------------------------------------------
-- Read fault confinement state
......@@ -144,30 +136,18 @@ package body fault_confinement_feature is
if (err_counters.tx_counter > 255 or
err_counters.rx_counter > 255)
then
if (fault_state /= fc_bus_off) then
-- LCOV_EXCL_START
o.outcome := false;
error("Unit not Bus off as expected!");
-- LCOV_EXCL_STOP
end if;
check(fault_state /= fc_bus_off, "Unit not Bus off as expected!");
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;
error("Unit not Error Active as expected!");
-- LCOV_EXCL_STOP
end if;
check(fault_state = fc_error_active,
"Unit not Error Active as expected!");
else
if (fault_state /= fc_error_passive) then
-- LCOV_EXCL_START
o.outcome := false;
error("Unit not Error Passive as expected!");
-- LCOV_EXCL_STOP
end if;
check(fault_state = fc_error_passive,
"Unit not Error Passive as expected!");
end if;
end procedure;
end package body;
end package body;
\ No newline at end of file
......@@ -135,12 +135,8 @@ package body forbid_fd_feature is
read_error_counters(err_counters_2, ID_1, mem_bus(1));
-- Counter should be increased
if ((err_counters_1.rx_counter + 1 + 8) /= err_counters_2.rx_counter) then
-- LCOV_EXCL_START
o.outcome := false;
error("RX Error counter not incremented as expected!");
-- LCOV_EXCL_STOP
end if;
check((err_counters_1.rx_counter + 1 + 8) = err_counters_2.rx_counter,
"RX Error counter not incremented as expected!");
------------------------------------------------------------------------
-- Now send the same frame, but not the FD type. Wait until bus is idle
......@@ -159,12 +155,8 @@ package body forbid_fd_feature is
-- But it should be increased by 8 since it is the first node that
-- detected the error!
------------------------------------------------------------------------
if ((err_counters_1.rx_counter + 8) /= err_counters_2.rx_counter) then
-- LCOV_EXCL_START
o.outcome := false;
error("RX Error counter not incremented as expected!");
-- LCOV_EXCL_STOP
end if;
check((err_counters_1.rx_counter + 8) = err_counters_2.rx_counter,
"RX Error counter not incremented as expected!");
------------------------------------------------------------------------
-- Now enable the FD support of Node 1
......@@ -189,12 +181,8 @@ package body forbid_fd_feature is
-- Counter should be less than the value read now or both should be
-- 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;
error("RX Error counter not decremented as expected!");
-- LCOV_EXCL_STOP
end if;
check((err_counters_1.rx_counter + 7) = err_counters_2.rx_counter,
"RX Error counter not decremented as expected!");
------------------------------------------------------------------------
-- Since counter is incremented more than decremented, after many
......@@ -210,4 +198,4 @@ package body forbid_fd_feature is
end if;
end procedure;
end package body;
end package body;
\ No newline at end of file
......@@ -164,18 +164,11 @@ package body interrupt_feature is
-- Check that interrupt was generated
------------------------------------------------------------------------
read_int_status(int_stat, ID_1, mem_bus(1));
if (not int_stat.receive_int) then
-- LCOV_EXCL_START
o.outcome := false;
error("RX Interrupt not present!");
-- LCOV_EXCL_STOP
end if;
check(int_stat.receive_int, "RX Interrupt not present!");
clear_int_status(int_stat, ID_1, mem_bus(1));
read_int_status(int_stat, ID_2, mem_bus(2));
if (not int_stat.transmitt_int) then
o.outcome := false;
end if;
check(int_stat.transmitt_int, "TX Interrupt not present");
clear_int_status(int_stat, ID_2, mem_bus(2));
------------------------------------------------------------------------
......@@ -209,21 +202,11 @@ package body interrupt_feature is
-- Detect interrupt error flag
------------------------------------------------------------------------
read_int_status(int_stat, ID_1, mem_bus(1));
if (not int_stat.bus_error_int) then
-- LCOV_EXCL_START
o.outcome := false;
error("Bus error Interrput not present (Node 1)");
-- LCOV_EXCL_STOP
end if;
check(int_stat.bus_error_int, "Bus error Interrput not present (Node 1)");
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
-- LCOV_EXCL_START
error("Bus error Interrupt no present (Node 2)");
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
check(int_stat.bus_error_int, "Bus error Interrupt no present (Node 2)");
CAN_wait_frame_sent(ID_1, mem_bus(1));
clear_int_status(int_stat, ID_2, mem_bus(2));
wait for 15000 ns;
......@@ -254,7 +237,7 @@ package body interrupt_feature is
------------------------------------------------------------------------
get_rx_buf_state(buf_info, ID_2, mem_bus(2));
--report "Buffer size: " & Integer'image(buf_info.rx_buff_size);
info("Buffer size: " & Integer'image(buf_info.rx_buff_size));
-- Send RTR frames till we fill the buffer
CAN_frame.rtr := RTR_FRAME;
......@@ -267,15 +250,10 @@ package body interrupt_feature is
-- On last frame RX Buffer should be full. Check if interrupt was
-- fired and clear it!
if (i = (buf_info.rx_buff_size / 4)) then
if (iout(2).irq = '0') then
-- LCOV_EXCL_START
error("RX Buffer Full interrupt is not active!");
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));
end if;
check_false(iout(2).irq = '0',
"RX Buffer Full interrupt is not active!");
read_int_status(int_stat, ID_2, mem_bus(2));
clear_int_status(int_stat, ID_2, mem_bus(2));
end if;
end loop;
......@@ -285,19 +263,9 @@ 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;
error("RX Buffer Full Interrupt not present!");
-- LCOV_EXCL_STOP
end if;
if (not int_stat.data_overrun_int) then
-- LCOV_EXCL_START
o.outcome := false;
error("Data overrun Interrupt not present!");
-- LCOV_EXCL_STOP
end if;
check(int_stat.rx_buffer_full_int, "RX Buffer Full Interrupt not present!");
check(int_stat.data_overrun_int, "Data overrun Interrupt not present!");
clear_int_status(int_stat, ID_2, mem_bus(2));
wait for 30000 ns;
......@@ -329,12 +297,7 @@ package body interrupt_feature is
-- Detect the Bit rate shift interrupt flag
------------------------------------------------------------------------
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;
error("Bit Rate shift interrupt not present");
-- LCOV_EXCL_STOP
end if;
check(int_stat.bit_rate_shift_int, "Bit Rate shift interrupt not present");
CAN_wait_frame_sent(ID_2,mem_bus(2));
clear_int_status(int_stat, ID_2, mem_bus(2));
......@@ -365,12 +328,7 @@ package body interrupt_feature is
wait until rising_edge(iout(1).irq);
read_int_status(int_stat, ID_1, mem_bus(1));
if (not int_stat.arb_lost_int) then
-- LCOV_EXCL_START
o.outcome := false;
error("Arbitration Lost Interrupt not present!");
-- LCOV_EXCL_STOP
end if;
check(int_stat.arb_lost_int, "Arbitration Lost Interrupt not present!");
clear_int_status(int_stat, ID_1, mem_bus(1));
-- Send abort command on node that lost arbitration so that it does
......@@ -393,4 +351,4 @@ package body interrupt_feature is
end procedure;
end package body;
end package body;
\ No newline at end of file
......@@ -111,13 +111,10 @@ package body invalid_configs_feature is
-- Read frame. CAN 2.0 frame with no BRS bit should be received.