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 ...@@ -4930,8 +4930,8 @@ ILBP Internal loop-back option (recommended only for testing). If internal loop
\end_layout \end_layout
\begin_layout Description \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 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 0b0 - CTU_CAN_DISABLED - The CAN Core is disabled.\begin_inset Newline newline\end_inset
0b1 - ENABLED - The CAN Core is enabled. 0b1 - CTU_CAN_ENABLED - The CAN Core is enabled.
\end_layout \end_layout
\begin_layout Description \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 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) ...@@ -142,7 +142,7 @@ void ctu_can_fd_enable(struct ctucanfd_priv *priv, bool enable)
union ctu_can_fd_mode_command_status_settings reg; union ctu_can_fd_mode_command_status_settings reg;
reg.u32 = priv->read_reg(priv, CTU_CAN_FD_MODE); 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); 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) ...@@ -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; union ctu_can_fd_mode_command_status_settings reg;
reg.u32 = priv->read_reg(priv, CTU_CAN_FD_MODE); 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 { ...@@ -250,8 +250,8 @@ enum ctu_can_fd_settings_ilbp {
}; };
enum ctu_can_fd_settings_ena { enum ctu_can_fd_settings_ena {
DISABLED = 0x0, CTU_CAN_DISABLED = 0x0,
ENABLED = 0x1, CTU_CAN_ENABLED = 0x1,
}; };
enum ctu_can_fd_settings_nisofd { enum ctu_can_fd_settings_nisofd {
......
...@@ -532,14 +532,14 @@ ...@@ -532,14 +532,14 @@
<ipxact:bitWidth>1</ipxact:bitWidth> <ipxact:bitWidth>1</ipxact:bitWidth>
<ipxact:enumeratedValues> <ipxact:enumeratedValues>
<ipxact:enumeratedValue> <ipxact:enumeratedValue>
<ipxact:name>ENABLED</ipxact:name> <ipxact:name>CTU_CAN_ENABLED</ipxact:name>
<ipxact:displayName>ENABLED</ipxact:displayName> <ipxact:displayName>CTU_CAN_ENABLED</ipxact:displayName>
<ipxact:description>The CAN Core is enabled.</ipxact:description> <ipxact:description>The CAN Core is enabled.</ipxact:description>
<ipxact:value>1</ipxact:value> <ipxact:value>1</ipxact:value>
</ipxact:enumeratedValue> </ipxact:enumeratedValue>
<ipxact:enumeratedValue> <ipxact:enumeratedValue>
<ipxact:name>DISABLED</ipxact:name> <ipxact:name>CTU_CAN_DISABLED</ipxact:name>
<ipxact:displayName>DISABLED</ipxact:displayName> <ipxact:displayName>CTU_CAN_DISABLED</ipxact:displayName>
<ipxact:description>The CAN Core is disabled.</ipxact:description> <ipxact:description>The CAN Core is disabled.</ipxact:description>
<ipxact:value>0</ipxact:value> <ipxact:value>0</ipxact:value>
</ipxact:enumeratedValue> </ipxact:enumeratedValue>
......
...@@ -548,7 +548,7 @@ begin ...@@ -548,7 +548,7 @@ begin
elsif rising_edge(clk_sys) then elsif rising_edge(clk_sys) then
if (drv_ena = ENABLED) then if (drv_ena = CTU_CAN_ENABLED) then
case sp_control is case sp_control is
---------------------------------------------------------------- ----------------------------------------------------------------
...@@ -599,7 +599,7 @@ begin ...@@ -599,7 +599,7 @@ begin
elsif rising_edge(clk_sys) then 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 case sp_control is
---------------------------------------------------------------- ----------------------------------------------------------------
......
...@@ -142,7 +142,7 @@ begin ...@@ -142,7 +142,7 @@ begin
unknown_OP_state <= '0'; unknown_OP_state <= '0';
if (drv_ena /= ENABLED) then if (drv_ena /= CTU_CAN_ENABLED) then
OP_State_r <= integrating; OP_State_r <= integrating;
elsif (set_transciever = '1') then elsif (set_transciever = '1') then
OP_State_r <= transciever; OP_State_r <= transciever;
...@@ -156,7 +156,7 @@ begin ...@@ -156,7 +156,7 @@ begin
-- Waiting for 11 consecutive recessive bits -- Waiting for 11 consecutive recessive bits
---------------------------------------------------------------- ----------------------------------------------------------------
when integrating => when integrating =>
if (drv_ena = ENABLED) then if (drv_ena = CTU_CAN_ENABLED) then
if (rec_trig = '1') then if (rec_trig = '1') then
-- Counting up the integration period -- Counting up the integration period
if (integ_counter = INTEGRATING_DURATION) then if (integ_counter = INTEGRATING_DURATION) then
...@@ -214,4 +214,4 @@ begin ...@@ -214,4 +214,4 @@ begin
end if; end if;
end process; end process;
end architecture; end architecture;
\ No newline at end of file
...@@ -3214,7 +3214,7 @@ begin ...@@ -3214,7 +3214,7 @@ begin
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
when off => when off =>
if (drv_ena = ENABLED) then if (drv_ena = CTU_CAN_ENABLED) then
if (error_state /= bus_off and OP_State /= integrating) then if (error_state /= bus_off and OP_State /= integrating) then
-- Note that here we don't want to execute FSM_Preset! We want -- Note that here we don't want to execute FSM_Preset! We want
......
...@@ -312,8 +312,8 @@ package can_fd_register_map is ...@@ -312,8 +312,8 @@ package can_fd_register_map is
constant INT_LOOP_ENABLED : std_logic := '1'; constant INT_LOOP_ENABLED : std_logic := '1';
-- "ENA" field enumerated values -- "ENA" field enumerated values
constant DISABLED : std_logic := '0'; constant CTU_CAN_DISABLED : std_logic := '0';
constant ENABLED : std_logic := '1'; constant CTU_CAN_ENABLED : std_logic := '1';
-- "NISOFD" field enumerated values -- "NISOFD" field enumerated values
constant ISO_FD : std_logic := '0'; constant ISO_FD : std_logic := '0';
......
...@@ -147,7 +147,7 @@ package body abort_transmittion_feature is ...@@ -147,7 +147,7 @@ package body abort_transmittion_feature is
PC_State := protocol_type'VAL(to_integer(unsigned( PC_State := protocol_type'VAL(to_integer(unsigned(
iout(1).stat_bus(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); info("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
PC_State = data or PC_State = crc) PC_State = data or PC_State = crc)
then then
...@@ -155,7 +155,7 @@ package body abort_transmittion_feature is ...@@ -155,7 +155,7 @@ package body abort_transmittion_feature is
else else
still_tx := false; still_tx := false;
end if; end if;
report "Wait end"; info("Wait end");
if still_tx then if still_tx then
...@@ -173,12 +173,7 @@ package body abort_transmittion_feature is ...@@ -173,12 +173,7 @@ package body abort_transmittion_feature is
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 check_false(status.transmitter, "Unit did not abort the transmission!");
-- LCOV_EXCL_START
o.outcome := false;
report "Unit did not abort the transmission!" severity error;
-- LCOV_EXCL_STOP
end if;
-------------------------------------------------------------------- --------------------------------------------------------------------
-- Now wait until unit 2 starts transmitting error frame! Note that -- Now wait until unit 2 starts transmitting error frame! Note that
...@@ -208,12 +203,7 @@ package body abort_transmittion_feature is ...@@ -208,12 +203,7 @@ package body abort_transmittion_feature is
-- 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 check(status.bus_status, "Unit is not Idle!");
-- LCOV_EXCL_START
report "Unit is not Idle!" severity error;
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
end if; end if;
......
...@@ -197,37 +197,37 @@ package body Arbitration_feature is ...@@ -197,37 +197,37 @@ package body Arbitration_feature is
frame_1.ident_type = frame_2.ident_type) frame_1.ident_type = frame_2.ident_type)
then then
exp_winner := 2; exp_winner := 2;
report "Expecting collision"; info("Expecting collision");
-- CAN 2.0 and CAN FD frames with matching ID will cause collision! -- CAN 2.0 and CAN FD frames with matching ID will cause collision!
elsif (frame_1.frame_format /= frame_2.frame_format) then elsif (frame_1.frame_format /= frame_2.frame_format) then
exp_winner := 2; exp_winner := 2;
report "Expecting collision"; info("Expecting collision");
-- Same RTR, but different ident type, IDENT type selects winner! -- Same RTR, but different ident type, IDENT type selects winner!
elsif (frame_1.ident_type = BASE and elsif (frame_1.ident_type = BASE and
frame_2.ident_type = EXTENDED) frame_2.ident_type = EXTENDED)
then then
report "Testing victory of BASE against EXTENDED"; info("Testing victory of BASE against EXTENDED");
exp_winner := 0; exp_winner := 0;
elsif (frame_1.ident_type = EXTENDED and elsif (frame_1.ident_type = EXTENDED and
frame_2.ident_type = BASE) frame_2.ident_type = BASE)
then then
report "Testing victory of BASE against EXTENDED"; info("Testing victory of BASE against EXTENDED");
exp_winner := 1; exp_winner := 1;
-- Same identifiers, different RTRs, RTR always selects winner! -- Same identifiers, different RTRs, RTR always selects winner!
elsif (frame_1.rtr = NO_RTR_FRAME and elsif (frame_1.rtr = NO_RTR_FRAME and
frame_2.rtr = RTR_FRAME) frame_2.rtr = RTR_FRAME)
then then
report "Testing victory of non RTR against RTR"; info("Testing victory of non RTR against RTR");
exp_winner := 0; exp_winner := 0;
elsif (frame_1.rtr = RTR_FRAME and elsif (frame_1.rtr = RTR_FRAME and
frame_2.rtr = NO_RTR_FRAME) frame_2.rtr = NO_RTR_FRAME)
then then
report "Testing victory of non RTR against RTR"; info("Testing victory of non RTR against RTR");
exp_winner := 1; exp_winner := 1;
end if; end if;
...@@ -304,25 +304,22 @@ package body Arbitration_feature is ...@@ -304,25 +304,22 @@ package body Arbitration_feature is
end if; end if;
end loop; 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 -- Check whether expected winner is the unit which lost the arbitration
------------------------------------------------------------------------ ------------------------------------------------------------------------
if (unit_rec = 1 and exp_winner = 0) or check_false((unit_rec = 1 and exp_winner = 0) or
(unit_rec = 2 and exp_winner = 1) (unit_rec = 2 and exp_winner = 1),
then "Wrong unit lost arbitration. Expected: " &
-- LCOV_EXCL_START integer'image(exp_winner) &
report "Wrong unit lost arbitration. Expected: " & " Real: " & integer'image(unit_rec));
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;
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Send abort transmission to both frames so that no unit will -- Send abort transmission to both frames so that no unit will
...@@ -343,20 +340,18 @@ package body Arbitration_feature is ...@@ -343,20 +340,18 @@ package body Arbitration_feature is
end if; end if;
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- If error frame is transmitted and collision not have appeared -- Print Frame info
------------------------------------------------------------------------ ------------------------------------------------------------------------
if (unit_rec = 3 and exp_winner /= 2) then info("Frame 1:");
-- LCOV_EXCL_START CAN_print_frame(frame_1);
report "Collision should have appeared" severity error; info("Frame 2:");
CAN_print_frame(frame_2);
report "Frame 1:"; ------------------------------------------------------------------------
CAN_print_frame(frame_1, info_l); -- If error frame is transmitted and collision not have appeared
report "Frame 2:"; ------------------------------------------------------------------------
CAN_print_frame(frame_2, info_l); check_false(unit_rec = 3 and exp_winner /= 2,
"Collision should have appeared");
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
wait for 100000 ns; wait for 100000 ns;
end procedure; end procedure;
......
...@@ -127,7 +127,7 @@ package body bus_start_feature is ...@@ -127,7 +127,7 @@ package body bus_start_feature is
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Turn on Node 1, Wait until it starts transmitting -- 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)); CAN_turn_controller(true, ID_1, mem_bus(1));
while (protocol_type'VAL(to_integer(unsigned( while (protocol_type'VAL(to_integer(unsigned(
iout(1).stat_bus(STAT_PC_STATE_HIGH downto STAT_PC_STATE_LOW)))) iout(1).stat_bus(STAT_PC_STATE_HIGH downto STAT_PC_STATE_LOW))))
...@@ -140,7 +140,7 @@ package body bus_start_feature is ...@@ -140,7 +140,7 @@ package body bus_start_feature is
-- Modify frame to have ID 513, and insert it to Node 2 for transmission. -- Modify frame to have ID 513, and insert it to Node 2 for transmission.
-- Enable Node 2, so that it may start integration. -- 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); wait_rand_cycles(rand_ctr, mem_bus(1).clk_sys, 10, 11);
CAN_frame.identifier := 513; CAN_frame.identifier := 513;
CAN_send_frame(CAN_frame, 1, ID_2, mem_bus(2), frame_sent); CAN_send_frame(CAN_frame, 1, ID_2, mem_bus(2), frame_sent);
...@@ -159,9 +159,9 @@ package body bus_start_feature is ...@@ -159,9 +159,9 @@ package body bus_start_feature is
-- Assuming default timing configuration -> 200 cycles per Bit -- Assuming default timing configuration -> 200 cycles per Bit
-- Wait through CRC Delimiter + little 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); wait_rand_cycles(rand_ctr, mem_bus(1).clk_sys, 209, 210);
report "Forcing ACK"; info("Forcing ACK");
so.bl_inject <= DOMINANT; so.bl_inject <= DOMINANT;
so.bl_force <= true; so.bl_force <= true;
wait_rand_cycles(rand_ctr, mem_bus(1).clk_sys, 200, 201); wait_rand_cycles(rand_ctr, mem_bus(1).clk_sys, 200, 201);
...@@ -172,14 +172,14 @@ package body bus_start_feature is ...@@ -172,14 +172,14 @@ package body bus_start_feature is
-- Wait until bus is idle. -- Wait until bus is idle.
------------------------------------------------------------------------ ------------------------------------------------------------------------
CAN_wait_bus_idle(ID_1, mem_bus(1)); 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 -- Now wait until another frame is transmitted. This one should be
-- arbitrated, and Node 2 should have won. -- arbitrated, and Node 2 should have won.
------------------------------------------------------------------------ ------------------------------------------------------------------------
CAN_wait_frame_sent(ID_1, mem_bus(1)); 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 -- Read status of RX Buffer in Node 1! It should have sent ACK and
...@@ -201,25 +201,16 @@ package body bus_start_feature is ...@@ -201,25 +201,16 @@ package body bus_start_feature is
-- in special feature test! -- in special feature test!
------------------------------------------------------------------------ ------------------------------------------------------------------------
get_rx_buf_state(rx_state, ID_1, mem_bus(1)); 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 check_false(rx_state.rx_empty,
-- LCOV_EXCL_START "RX Buffer is empty, but Frame should be received!");
o.outcome := false;
report "RX Buffer is empty, but Frame should be received!"
severity error;
-- LCOV_EXCL_STOP
end if;
CAN_frame.identifier := 0; CAN_frame.identifier := 0;
CAN_read_frame(CAN_frame, ID_1, mem_bus(1)); CAN_read_frame(CAN_frame, ID_1, mem_bus(1));
if (CAN_frame.identifier /= 513) then check(CAN_frame.identifier = 513,
-- LCOV_EXCL_START "Wrong Identifier received by Node 1! Expected: 513 , Real: " &
o.outcome := false; integer'image(CAN_frame.identifier));
report "Wrong Identifier received by Node 1. Expected: 513 , Real: " &
integer'image(CAN_frame.identifier) severity error;
-- LCOV_EXCL_STOP
end if;
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Now wait until Node 1 transmitts frame which lost the arbitration -- Now wait until Node 1 transmitts frame which lost the arbitration
...@@ -227,8 +218,8 @@ package body bus_start_feature is ...@@ -227,8 +218,8 @@ package body bus_start_feature is
-- Buffers. -- Buffers.
------------------------------------------------------------------------ ------------------------------------------------------------------------
CAN_wait_bus_idle(ID_1, mem_bus(1)); CAN_wait_bus_idle(ID_1, mem_bus(1));
report "Last frame was sent!"; info("Last frame was sent!");
end procedure; end procedure;
end package body; end package body;
\ No newline at end of file
...@@ -81,6 +81,7 @@ package body byte_enable_feature is ...@@ -81,6 +81,7 @@ package body byte_enable_feature is
variable address : std_logic_vector(11 downto 0) := variable address : std_logic_vector(11 downto 0) :=
(OTHERS => '0'); (OTHERS => '0');
variable ID : natural := 1; variable ID : natural := 1;
variable errmsg : line;
begin begin
o.outcome := true; o.outcome := true;
...@@ -90,12 +91,7 @@ package body byte_enable_feature is ...@@ -90,12 +91,7 @@ package body byte_enable_feature is
address := YOLO_REG_ADR; address := YOLO_REG_ADR;
CAN_read(data, address, ID, mem_bus(1), BIT_32); CAN_read(data, address, ID, mem_bus(1), BIT_32);
if (data /= x"DEADBEEF") then check(data = x"DEADBEEF", "32 bit read error");
-- LCOV_EXCL_START
o.outcome := false;
report "32 bit read error" severity error;
-- LCOV_EXCL_STOP
end if;
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Now read per half word (16 BIT) -- Now read per half word (16 BIT)
...@@ -107,24 +103,13 @@ package body byte_enable_feature is ...@@ -107,24 +103,13 @@ package body byte_enable_feature is
CAN_read(data, address, ID, mem_bus(1), BIT_16); CAN_read(data, address, ID, mem_bus(1), BIT_16);
-- Checking if valid 2 bytes match register value -- Checking if valid 2 bytes match register value
if (data(16 * i + 15 downto 16 * i) /= check(data(16 * i + 15 downto 16 * i) =
YOLO_VAL_RSTVAL(16 * i + 15 downto 16 * i)) YOLO_VAL_RSTVAL(16 * i + 15 downto 16 * i),
then "Read error - 16 bit access (valid byte), Index:");
-- 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 -- Checking invalid 2 bytes are 0
if (data(16 * (1 - i) + 15 downto 16 * (1 - i)) /= x"0000") then check(data(16 * (1 - i) + 15 downto 16 * (1 - i)) = x"0000",
-- LCOV_EXCL_START "Read error -16 bit access (empty byte), Index :");
report "16 bit read error (empty byte), Index :" &
Integer'image(i) severity error;
o.outcome := false;
-- LCOV_EXCL_STOP
end if;
end loop; end loop;