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

Updated RTR preffered behaviour feature test.

parent 9983cf73
......@@ -35,24 +35,33 @@
--
--------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Purpose:
--
-- Feature test for RTR preferred behaviour of CTU CAN FD. RTR preffered
-- behaviour determines whether inserted DLC will be sent as part of RTR frame
-- or all zeroes will be sent in RTR Frame.
--
-- Test sequence is like so:
-- 1.
-- 2.
-- 3.
-- 4.
-- 5.
-- 6.
-- 1. Part 1:
-- 1.1 Generate frame with arbitrary DLC and force RTR flag
-- 1.2 Configure RTR behaviour to send all zeroes.
-- 1.3 Send frame by Node 1.
-- 1.4 Wait until Node 2 receives the frame. Read frame from Node 2
-- 1.5 Check if received DLC is 0.
-- 2. Part 2:
-- 2.1 Configure RTR behaviour to send the original value
-- 2.2 Send frame by Node 1.
-- 2.3 Wait until Node 2 receives the frame. Read frame from Node 2
-- 2.4 Check if received DLC is matching transmitted DLC.
--
-----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Revision History:
--
-- 23.6.2016 Created file
-- 06.02.2018 Modified to work with the IP-XACT generated memory map
-----------------------------------------------------------------------------------------------------------------
-- 12.6.2018 Updated to use CAN Test library functions instead of direct
-- register access.
--------------------------------------------------------------------------------
Library ieee;
USE IEEE.std_logic_1164.all;
......@@ -67,126 +76,120 @@ use work.CAN_FD_frame_format.all;
package rtr_pref_feature is
procedure rtr_pref_feature_exec(
variable outcome : inout boolean;
signal rand_ctr :inout natural range 0 to RAND_POOL_SIZE;
signal mem_bus_1 :inout Avalon_mem_type;
signal mem_bus_2 :inout Avalon_mem_type;
--Additional signals for tests
--Pretty much everything can be read out of stat bus...
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)
);
procedure rtr_pref_feature_exec(
variable outcome : inout boolean;
signal rand_ctr : inout natural range 0 to RAND_POOL_SIZE;
signal mem_bus_1 : inout Avalon_mem_type;
signal mem_bus_2 : inout Avalon_mem_type;
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;
package body rtr_pref_feature is
procedure rtr_pref_feature_exec(
variable outcome : inout boolean;
signal rand_ctr :inout natural range 0 to RAND_POOL_SIZE;
signal mem_bus_1 :inout Avalon_mem_type;
signal mem_bus_2 :inout Avalon_mem_type;
--Additional signals for tests
--Pretty much everything can be read out of stat bus...
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
variable r_data : std_logic_vector(31 downto 0):=(OTHERS => '0');
variable w_data : std_logic_vector(31 downto 0):=(OTHERS => '0');
variable ID_1 : natural:=1;
variable ID_2 : natural:=2;
variable CAN_frame : SW_CAN_frame_type;
variable frame_sent : boolean:=false;
begin
outcome:=true;
-----------
--Part 1
-----------
----------------------------------------------
--Generate CAN frame
----------------------------------------------
CAN_generate_frame(rand_ctr,CAN_frame);
CAN_frame.rtr:=RTR_FRAME;
CAN_frame.frame_format:=NORMAL_CAN;
----------------------------------------------
-- Set the RTR preferred behaviour to
-- send the DLC all zeroes..
---------------------------------------------
CAN_read(r_data,MODE_ADR,ID_1,mem_bus_1);
r_data(RTR_PREF_IND) := '1'; --RTR preffered bit
CAN_write(r_data,MODE_ADR,ID_1,mem_bus_1);
---------------------------------------------
--Restart the content of the Node 2 RX Buffer
---------------------------------------------
CAN_read(r_data,MODE_ADR,ID_2,mem_bus_2);
r_data(RRB_IND) := '1'; --Release recieve buffer bit
CAN_write(r_data,MODE_ADR,ID_2,mem_bus_2);
----------------------------------------------
--Insert the frame for transmittion
-- and wait until recieved
----------------------------------------------
CAN_send_frame(CAN_frame,1,ID_1,mem_bus_1,frame_sent);
if(frame_sent=false)then
outcome:=false;
end if;
CAN_wait_frame_sent(ID_2,mem_bus_2);
---------------------------------------------
--Check that recieved DLC is zero
---------------------------------------------
CAN_read(r_data,RX_DATA_ADR,ID_2,mem_bus_2);
if(r_data(DLC_H downto DLC_L) /= x"0")then
outcome:=false;
end if;
-----------
--Part 2
-----------
----------------------------------------------
-- Set the RTR preferred behaviour to
-- send the original DLC
---------------------------------------------
CAN_read(r_data,MODE_ADR,ID_1,mem_bus_1);
r_data(RTR_PREF_IND) := '0'; --RTR preffered bit
CAN_write(r_data,MODE_ADR,ID_1,mem_bus_1);
---------------------------------------------
--Restart the content of the Node 2 RX Buffer
---------------------------------------------
CAN_read(r_data,MODE_ADR,ID_2,mem_bus_2);
r_data(RRB_IND) := '1'; --Release recieve buffer bit
CAN_write(r_data,MODE_ADR,ID_2,mem_bus_2);
----------------------------------------------
--Insert the frame for transmittion
-- and wait until recieved
----------------------------------------------
CAN_send_frame(CAN_frame,1,ID_1,mem_bus_1,frame_sent);
if(frame_sent=false)then
outcome:=false;
end if;
CAN_wait_frame_sent(ID_2,mem_bus_2);
---------------------------------------------
--Check that recieved DLC is matching transc.
---------------------------------------------
CAN_read(r_data,RX_DATA_ADR,ID_2,mem_bus_2);
if(r_data(DLC_H downto DLC_L) /= CAN_frame.dlc)then
outcome:=false;
end if;
procedure rtr_pref_feature_exec(
variable outcome : inout boolean;
signal rand_ctr : inout natural range 0 to RAND_POOL_SIZE;
signal mem_bus_1 : inout Avalon_mem_type;
signal mem_bus_2 : inout Avalon_mem_type;
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
variable ID_1 : natural := 1;
variable ID_2 : natural := 2;
variable tx_frame : SW_CAN_frame_type;
variable rx_frame : SW_CAN_frame_type;
variable frame_sent : boolean := false;
variable command : SW_command := (false, false, false);
variable status : SW_status;
variable mode : SW_mode;
begin
outcome := true;
------------------------------------------------------------------------
-- Part 1
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Generate CAN frame with arbitrary DLC and force RTR after.
------------------------------------------------------------------------
CAN_generate_frame(rand_ctr, tx_frame);
tx_frame.rtr := RTR_FRAME;
tx_frame.frame_format := NORMAL_CAN;
------------------------------------------------------------------------
-- Set the RTR preferred behaviour to send the DLC all zeroes..
------------------------------------------------------------------------
mode.rtr_pref := true;
set_core_mode(mode, ID_2, mem_bus_2);
set_core_mode(mode, ID_1, mem_bus_1);
------------------------------------------------------------------------
-- Restart the content of the Node 2 RX Buffer
------------------------------------------------------------------------
command.release_rec_buffer := true;
give_controller_command(command, ID_2, mem_bus_2);
command.release_rec_buffer := false;
------------------------------------------------------------------------
-- Insert the frame for transmittion and wait until it was sent
------------------------------------------------------------------------
CAN_send_frame(tx_frame, 1, ID_1, mem_bus_1, frame_sent);
if (not frame_sent) then
outcome := false;
end if;
CAN_wait_frame_sent(ID_2, mem_bus_2);
------------------------------------------------------------------------
-- Check that recieved DLC is zero
------------------------------------------------------------------------
CAN_read_frame(rx_frame, ID_2, mem_bus_2);
if (rx_frame.dlc /= x"0") then
outcome := false;
end if;
------------------------------------------------------------------------
-- Part 2
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Set the RTR preferred behaviour to send the original DLC
------------------------------------------------------------------------
mode.rtr_pref := false;
set_core_mode(mode, ID_2, mem_bus_2);
set_core_mode(mode, ID_1, mem_bus_1);
------------------------------------------------------------------------
-- Restart the content of the Node 2 RX Buffer
------------------------------------------------------------------------
command.release_rec_buffer := true;
give_controller_command(command, ID_2, mem_bus_2);
command.release_rec_buffer := false;
------------------------------------------------------------------------
-- Insert the frame for transmittion and wait until recieved
------------------------------------------------------------------------
CAN_send_frame(tx_frame, 1, ID_1, mem_bus_1, frame_sent);
if (not frame_sent) then
outcome := false;
end if;
CAN_wait_frame_sent(ID_2, mem_bus_2);
------------------------------------------------------------------------
-- Check that recieved DLC is matching transmitted DLC
------------------------------------------------------------------------
CAN_read_frame(rx_frame, ID_2, mem_bus_2);
if (rx_frame.dlc /= tx_frame.dlc) then
outcome := false;
end if;
end procedure;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment