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

Merge branch '206-create-basic-test-library' into 'master'

Resolve "Create basic test library"

Closes #206

See merge request !205
parents fe7d39a9 70e30da2
Pipeline #5975 failed with stages
in 59 minutes and 8 seconds
......@@ -4930,8 +4930,8 @@ ILBP Internal loop-back option (recommended only for testing). If internal loop
\end_layout
\begin_layout Description
ENA Enable bit for the whole CAN FD Controller. When disabled, IP Core acts as if not connected to the CAN Bus.\begin_inset Newline newline\end_inset
0b0 - DISABLED - The CAN Core is disabled.\begin_inset Newline newline\end_inset
0b1 - ENABLED - The CAN Core is enabled.
0b0 - CTU_CAN_DISABLED - The CAN Core is disabled.\begin_inset Newline newline\end_inset
0b1 - CTU_CAN_ENABLED - The CAN Core is enabled.
\end_layout
\begin_layout Description
NISOFD Selection between two possible CAN FD specifications. This bit should be modified only when SETTINGS[ENA]=0.\begin_inset Newline newline\end_inset
......
......@@ -142,7 +142,7 @@ void ctu_can_fd_enable(struct ctucanfd_priv *priv, bool enable)
union ctu_can_fd_mode_command_status_settings reg;
reg.u32 = priv->read_reg(priv, CTU_CAN_FD_MODE);
reg.s.ena = enable ? ENABLED : DISABLED;
reg.s.ena = enable ? CTU_CAN_ENABLED : CTU_CAN_DISABLED;
priv->write_reg(priv, CTU_CAN_FD_MODE, reg.u32);
}
......
......@@ -316,7 +316,7 @@ static inline bool ctu_can_fd_is_enabled(struct ctucanfd_priv *priv)
union ctu_can_fd_mode_command_status_settings reg;
reg.u32 = priv->read_reg(priv, CTU_CAN_FD_MODE);
return reg.s.ena == ENABLED;
return reg.s.ena == CTU_CAN_ENABLED;
}
......
......@@ -250,8 +250,8 @@ enum ctu_can_fd_settings_ilbp {
};
enum ctu_can_fd_settings_ena {
DISABLED = 0x0,
ENABLED = 0x1,
CTU_CAN_DISABLED = 0x0,
CTU_CAN_ENABLED = 0x1,
};
enum ctu_can_fd_settings_nisofd {
......
......@@ -532,14 +532,14 @@
<ipxact:bitWidth>1</ipxact:bitWidth>
<ipxact:enumeratedValues>
<ipxact:enumeratedValue>
<ipxact:name>ENABLED</ipxact:name>
<ipxact:displayName>ENABLED</ipxact:displayName>
<ipxact:name>CTU_CAN_ENABLED</ipxact:name>
<ipxact:displayName>CTU_CAN_ENABLED</ipxact:displayName>
<ipxact:description>The CAN Core is enabled.</ipxact:description>
<ipxact:value>1</ipxact:value>
</ipxact:enumeratedValue>
<ipxact:enumeratedValue>
<ipxact:name>DISABLED</ipxact:name>
<ipxact:displayName>DISABLED</ipxact:displayName>
<ipxact:name>CTU_CAN_DISABLED</ipxact:name>
<ipxact:displayName>CTU_CAN_DISABLED</ipxact:displayName>
<ipxact:description>The CAN Core is disabled.</ipxact:description>
<ipxact:value>0</ipxact:value>
</ipxact:enumeratedValue>
......
......@@ -548,7 +548,7 @@ begin
elsif rising_edge(clk_sys) then
if (drv_ena = ENABLED) then
if (drv_ena = CTU_CAN_ENABLED) then
case sp_control is
----------------------------------------------------------------
......@@ -599,7 +599,7 @@ begin
elsif rising_edge(clk_sys) then
if (drv_ena = ENABLED and bit_err_enable = '1') then
if (drv_ena = CTU_CAN_ENABLED and bit_err_enable = '1') then
case sp_control is
----------------------------------------------------------------
......
......@@ -142,7 +142,7 @@ begin
unknown_OP_state <= '0';
if (drv_ena /= ENABLED) then
if (drv_ena /= CTU_CAN_ENABLED) then
OP_State_r <= integrating;
elsif (set_transciever = '1') then
OP_State_r <= transciever;
......@@ -156,7 +156,7 @@ begin
-- Waiting for 11 consecutive recessive bits
----------------------------------------------------------------
when integrating =>
if (drv_ena = ENABLED) then
if (drv_ena = CTU_CAN_ENABLED) then
if (rec_trig = '1') then
-- Counting up the integration period
if (integ_counter = INTEGRATING_DURATION) then
......
......@@ -3214,7 +3214,7 @@ begin
----------------------------------------------------------------------------
----------------------------------------------------------------------------
when off =>
if (drv_ena = ENABLED) then
if (drv_ena = CTU_CAN_ENABLED) then
if (error_state /= bus_off and OP_State /= integrating) then
-- Note that here we don't want to execute FSM_Preset! We want
......
......@@ -312,8 +312,8 @@ package can_fd_register_map is
constant INT_LOOP_ENABLED : std_logic := '1';
-- "ENA" field enumerated values
constant DISABLED : std_logic := '0';
constant ENABLED : std_logic := '1';
constant CTU_CAN_DISABLED : std_logic := '0';
constant CTU_CAN_ENABLED : std_logic := '1';
-- "NISOFD" field enumerated values
constant ISO_FD : std_logic := '0';
......
......@@ -147,7 +147,7 @@ package body abort_transmittion_feature is
PC_State := protocol_type'VAL(to_integer(unsigned(
iout(1).stat_bus(STAT_PC_STATE_HIGH downto STAT_PC_STATE_LOW))));
report "PC State: " & protocol_type'Image(PC_State);
info("PC State: " & protocol_type'Image(PC_State));
if (PC_State = sof or PC_State = arbitration or PC_State = control or
PC_State = data or PC_State = crc)
then
......@@ -155,7 +155,7 @@ package body abort_transmittion_feature is
else
still_tx := false;
end if;
report "Wait end";
info("Wait end");
if still_tx then
......@@ -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;
report "Unit did not abort the transmission!" severity error;
-- 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
report "Unit is not Idle!" severity error;
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
check(status.bus_status, "Unit is not Idle!");
end if;
......
......@@ -197,37 +197,37 @@ package body Arbitration_feature is
frame_1.ident_type = frame_2.ident_type)
then
exp_winner := 2;
report "Expecting collision";
info("Expecting collision");
-- CAN 2.0 and CAN FD frames with matching ID will cause collision!
elsif (frame_1.frame_format /= frame_2.frame_format) then
exp_winner := 2;
report "Expecting collision";
info("Expecting collision");
-- Same RTR, but different ident type, IDENT type selects winner!
elsif (frame_1.ident_type = BASE and
frame_2.ident_type = EXTENDED)
then
report "Testing victory of BASE against EXTENDED";
info("Testing victory of BASE against EXTENDED");
exp_winner := 0;
elsif (frame_1.ident_type = EXTENDED and
frame_2.ident_type = BASE)
then
report "Testing victory of BASE against EXTENDED";
info("Testing victory of BASE against EXTENDED");
exp_winner := 1;
-- Same identifiers, different RTRs, RTR always selects winner!
elsif (frame_1.rtr = NO_RTR_FRAME and
frame_2.rtr = RTR_FRAME)
then
report "Testing victory of non RTR against RTR";
info("Testing victory of non RTR against RTR");
exp_winner := 0;
elsif (frame_1.rtr = RTR_FRAME and
frame_2.rtr = NO_RTR_FRAME)
then
report "Testing victory of non RTR against RTR";
info("Testing victory of non RTR against RTR");
exp_winner := 1;
end if;
......@@ -304,25 +304,22 @@ package body Arbitration_feature is
end if;
end loop;
------------------------------------------------------------------------
-- Print Frame info
------------------------------------------------------------------------
info("Frame 1:");
CAN_print_frame(frame_1);
info("Frame 2:");
CAN_print_frame(frame_2);
------------------------------------------------------------------------
-- 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
report "Wrong unit lost arbitration. Expected: " &
integer'image(exp_winner) & " Real: " & integer'image(unit_rec)
severity error;
report "Frame 1:";
CAN_print_frame(frame_1, info_l);
report "Frame 2:";
CAN_print_frame(frame_2, info_l);
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
......@@ -343,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
report "Collision should have appeared" severity error;
info("Frame 1:");
CAN_print_frame(frame_1);
info("Frame 2:");
CAN_print_frame(frame_2);
report "Frame 1:";
CAN_print_frame(frame_1, info_l);
report "Frame 2:";
CAN_print_frame(frame_2, info_l);
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;
......
......@@ -127,7 +127,7 @@ package body bus_start_feature is
------------------------------------------------------------------------
-- Turn on Node 1, Wait until it starts transmitting
------------------------------------------------------------------------
report "Turning ON Node 1.";
info("Turning ON Node 1.");
CAN_turn_controller(true, ID_1, mem_bus(1));
while (protocol_type'VAL(to_integer(unsigned(
iout(1).stat_bus(STAT_PC_STATE_HIGH downto STAT_PC_STATE_LOW))))
......@@ -140,7 +140,7 @@ package body bus_start_feature is
-- Modify frame to have ID 513, and insert it to Node 2 for transmission.
-- Enable Node 2, so that it may start integration.
------------------------------------------------------------------------
report "Turning ON Node 2.";
info("Turning ON Node 2.");
wait_rand_cycles(rand_ctr, mem_bus(1).clk_sys, 10, 11);
CAN_frame.identifier := 513;
CAN_send_frame(CAN_frame, 1, ID_2, mem_bus(2), frame_sent);
......@@ -159,9 +159,9 @@ package body bus_start_feature is
-- Assuming default timing configuration -> 200 cycles per Bit
-- Wait through CRC Delimiter + little bit
report "Started delim_ack";
info("Started delim_ack");
wait_rand_cycles(rand_ctr, mem_bus(1).clk_sys, 209, 210);
report "Forcing ACK";
info("Forcing ACK");
so.bl_inject <= DOMINANT;
so.bl_force <= true;
wait_rand_cycles(rand_ctr, mem_bus(1).clk_sys, 200, 201);
......@@ -172,14 +172,14 @@ package body bus_start_feature is
-- Wait until bus is idle.
------------------------------------------------------------------------
CAN_wait_bus_idle(ID_1, mem_bus(1));
report "Bus is idle";
info("Bus is idle");
------------------------------------------------------------------------
-- Now wait until another frame is transmitted. This one should be
-- arbitrated, and Node 2 should have won.
------------------------------------------------------------------------
CAN_wait_frame_sent(ID_1, mem_bus(1));
report "Second frame was sent!";
info("Second frame was sent!");
------------------------------------------------------------------------
-- Read status of RX Buffer in Node 1! It should have sent ACK and
......@@ -201,25 +201,16 @@ package body bus_start_feature is
-- in special feature test!
------------------------------------------------------------------------
get_rx_buf_state(rx_state, ID_1, mem_bus(1));
report "Read RX Buffer state";
info("Read RX Buffer state");
if (rx_state.rx_empty) then
-- LCOV_EXCL_START
o.outcome := false;
report "RX Buffer is empty, but Frame should be received!"
severity error;
-- 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;
report "Wrong Identifier received by Node 1. Expected: 513 , Real: " &
integer'image(CAN_frame.identifier) severity error;
-- 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
......@@ -227,7 +218,7 @@ package body bus_start_feature is
-- Buffers.
------------------------------------------------------------------------
CAN_wait_bus_idle(ID_1, mem_bus(1));
report "Last frame was sent!";
info("Last frame was sent!");
end procedure;
......
......@@ -81,6 +81,7 @@ package body byte_enable_feature is
variable address : std_logic_vector(11 downto 0) :=
(OTHERS => '0');
variable ID : natural := 1;
variable errmsg : line;
begin
o.outcome := true;
......@@ -90,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;
report "32 bit read error" severity error;
-- LCOV_EXCL_STOP
end if;
check(data = x"DEADBEEF", "32 bit read error");
------------------------------------------------------------------------
-- Now read per half word (16 BIT)
......@@ -107,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
report "16 bit read error (valid byte), Index :" &
Integer'image(i) severity error;
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
report "16 bit read error (empty byte), Index :" &
Integer'image(i) severity error;
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;
------------------------------------------------------------------------
......@@ -137,52 +122,29 @@ 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;
report "8 bit read error (valid byte), Index :" &
Integer'image(i) severity error;
-- 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;
report "8 bit read error (Empty byte 0)" severity error;
-- 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;
report "8 bit read error (Empty byte 1)" severity error;
-- 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;
report "8 bit read error (Empty byte 2)" severity error;
-- 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;
report "8 bit read error (Empty byte 3)" severity error;
-- LCOV_EXCL_STOP
end if;
check(data(23 downto 0) = x"000000",
"Read error - 8 bit (Empty byte 3)");
when others =>
report "Invalid byte index" severity error; -- LCOV_EXCL_LINE
error("Invalid byte index"); -- LCOV_EXCL_LINE
end case;
end loop;
......@@ -208,50 +170,29 @@ 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;
report "8 bit write error (valid byte), Index :" &
Integer'image(i) severity error;
-- 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;
report "8 bit write error (Empty byte 0)" severity error;
-- 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;
report "8 bit write error (Empty byte 1)" severity error;
-- 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;
report "8 bit write error (Empty byte 2)" severity error;
-- 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;
report "8 bit write error (Empty byte 3)" severity error;
-- LCOV_EXCL_STOP
end if;
check(data(23 downto 0) = x"000000",
"Write error - 8 bit (Empty byte 3)");
when others =>
report "Invalid byte index" severity error; -- LCOV_EXCL_LINE
error("Invalid byte index"); -- LCOV_EXCL_LINE
end case;
end loop;
......
......@@ -119,24 +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);
report "Invalid DLC received!" severity error;
-- 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;
report "Byte index " & integer'image(i) & " not zero!"
severity error;
-- 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));