* Added rtps_builting_endpoint_test7

- Compiling and Passing
This commit is contained in:
Greek 2020-12-06 23:55:28 +01:00
parent b40b4a7ea1
commit 1ef70e7204
6 changed files with 439 additions and 4 deletions

View File

@ -0,0 +1,71 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate -divider SYSTEM
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/clk
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/reset
add wave -noupdate -divider INPUT
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/empty
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/rd
add wave -noupdate -radix hexadecimal /L0_rtps_builtin_endpoint_test7/uut/data_in
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/last_word_in
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/last_word_in_latch
add wave -noupdate -radix hexadecimal /L0_rtps_builtin_endpoint_test7/uut/time
add wave -noupdate -divider OUTPUT
add wave -noupdate -radix hexadecimal /L0_rtps_builtin_endpoint_test7/uut/data_out
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/endpoint_wr
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/last_word_out
add wave -noupdate -divider TESTBENCH
add wave -noupdate /L0_rtps_builtin_endpoint_test7/start
add wave -noupdate /L0_rtps_builtin_endpoint_test7/stim_stage
add wave -noupdate /L0_rtps_builtin_endpoint_test7/stimulus.length
add wave -noupdate /L0_rtps_builtin_endpoint_test7/cnt_stim
add wave -noupdate /L0_rtps_builtin_endpoint_test7/packet_sent
add wave -noupdate -divider {MAIN FSM}
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/stage
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/stage_next
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/cnt
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/endpoint_mask
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/participant_match
add wave -noupdate -radix hexadecimal /L0_rtps_builtin_endpoint_test7/uut/lease_duration
add wave -noupdate -radix hexadecimal /L0_rtps_builtin_endpoint_test7/uut/deadline
add wave -noupdate -divider {MEM FSM}
add wave -noupdate -expand -group MEM_FSM /L0_rtps_builtin_endpoint_test7/uut/mem_opcode
add wave -noupdate -expand -group MEM_FSM /L0_rtps_builtin_endpoint_test7/uut/mem_op_start
add wave -noupdate -expand -group MEM_FSM /L0_rtps_builtin_endpoint_test7/uut/mem_op_done
add wave -noupdate -expand -group MEM_FSM /L0_rtps_builtin_endpoint_test7/uut/mem_stage
add wave -noupdate -expand -group MEM_FSM /L0_rtps_builtin_endpoint_test7/uut/mem_stage_next
add wave -noupdate -expand -group MEM_FSM /L0_rtps_builtin_endpoint_test7/uut/mem_cnt
add wave -noupdate -expand -group MEM_FSM -radix unsigned /L0_rtps_builtin_endpoint_test7/uut/mem_addr_base
add wave -noupdate -expand -group MEM_FSM -radix unsigned /L0_rtps_builtin_endpoint_test7/uut/addr_res
add wave -noupdate -divider GUARD
add wave -noupdate -radix unsigned /L0_rtps_builtin_endpoint_test7/uut/read_cnt
add wave -noupdate -radix unsigned /L0_rtps_builtin_endpoint_test7/uut/parameter_end
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/parse_prc/rd_guard
add wave -noupdate -divider MEMORY
add wave -noupdate -expand -group MEMORY -radix unsigned /L0_rtps_builtin_endpoint_test7/uut/ram_inst/addr
add wave -noupdate -expand -group MEMORY /L0_rtps_builtin_endpoint_test7/uut/ram_inst/wen
add wave -noupdate -expand -group MEMORY /L0_rtps_builtin_endpoint_test7/uut/ram_inst/ren
add wave -noupdate -expand -group MEMORY -radix hexadecimal /L0_rtps_builtin_endpoint_test7/uut/ram_inst/wr_data
add wave -noupdate -expand -group MEMORY -radix hexadecimal /L0_rtps_builtin_endpoint_test7/uut/ram_inst/rd_data
add wave -noupdate -divider MISC
add wave -noupdate /L0_rtps_builtin_endpoint_test7/uut/update_participant_flags
add wave -noupdate -radix unsigned /L0_rtps_builtin_endpoint_test7/uut/mem_seq_nr
add wave -noupdate -radix unsigned /L0_rtps_builtin_endpoint_test7/uut/seq_nr
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {Begin {31125000 ps} 1} {Error {45825000 ps} 1} {Cursor {31192063 ps} 0}
quietly wave cursor active 3
configure wave -namecolwidth 149
configure wave -valuecolwidth 144
configure wave -justifyvalue left
configure wave -signalnamewidth 1
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ns
update
WaveRestoreZoom {30675309 ps} {31823651 ps}

View File

@ -0,0 +1,345 @@
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library osvvm; -- Utility Library
context osvvm.OsvvmContext;
use work.rtps_package.all;
use work.user_config.all;
use work.rtps_config_package.all;
use work.rtps_test_package.all;
-- This testbench tests the handling of remote Liveliness Assertions
-- The testbench matches 2 remote Participants, P0 and P1. P0 sends an automatic liveliness assertion, while P1 sends a manual liveliness assertion.
-- P0 also sends a manual liveliness assertion with extra Bytes.
entity L0_rtps_builtin_endpoint_test7 is
end entity;
architecture testbench of L0_rtps_builtin_endpoint_test7 is
-- *TYPE DECLARATION*
type TEST_STAGE_TYPE is (IDLE, BUSY);
-- *SIGNAL DECLARATION*
signal clk, in_empty, rd_sig, last_word_in, last_word_out: std_logic := '0';
signal reset : std_logic := '1';
signal endpoint_wr, endpoint_full : std_logic_vector(0 to NUM_ENDPOINTS-1) := (others => '0');
signal data_in, data_out : std_logic_vector(WORD_WIDTH-1 downto 0) := (others => '0');
signal stim_stage : TEST_STAGE_TYPE := IDLE;
shared variable stimulus, reference : TEST_PACKET_TYPE := EMPTY_TEST_PACKET;
signal packet_sent : std_logic := '0';
signal cnt_stim : natural := 0;
signal start : std_logic := '0';
shared variable SB_out : work.ScoreBoardPkg_builtin_endpoint.ScoreBoardPType;
signal stim_done, check_done, mem_check : std_logic := '0';
-- *FUNCTION DECLARATION*
procedure wait_on_complete is
begin
wait until rising_edge(packet_sent);
end procedure;
function gen_sn(input : natural) return SEQUENCENUMBER_TYPE is
variable ret : SEQUENCENUMBER_TYPE;
begin
ret(0) := (others => '0');
ret(1) := unsigned(int(input, WORD_WIDTH));
return ret;
end function;
begin
-- Unit Under Test
uut : entity work.rtps_builtin_endpoint(arch)
port map (
clk => clk,
reset => reset,
empty => in_empty or packet_sent,
rd => rd_sig,
data_in => data_in,
data_out => data_out,
last_word_in => last_word_in,
time => TIME_ZERO,
endpoint_full => endpoint_full,
endpoint_wr => endpoint_wr,
rtps_wr => open,
rtps_full => '0',
last_word_out => last_word_out,
alive => (others => '0')
);
stimulus_prc : process
variable sub : RTPS_SUBMESSAGE_TYPE := DEFAULT_RTPS_SUBMESSAGE;
variable RV : RandomPType;
variable p0, p1, participant: PARTICIPANT_DATA_TYPE := DEFAULT_PARTICIPANT_DATA;
variable wr_sig : std_logic_vector(0 to NUM_ENDPOINTS-1) := (others => '0');
variable rand_data : TEST_PACKET_TYPE := EMPTY_TEST_PACKET;
-- Wrapper to use procedure as function
impure function gen_rand_loc_2 return LOCATOR_TYPE is
variable ret : LOCATOR_TYPE := EMPTY_LOCATOR;
begin
gen_rand_loc(RV, ret);
return ret;
end function;
impure function gen_rand_guid_prefix return GUIDPREFIX_TYPE is
variable ret : GUIDPREFIX_TYPE;
begin
ret := (0 => RV.RandSlv(WORD_WIDTH), 1 => RV.RandSlv(WORD_WIDTH), 2 => RV.RandSlv(WORD_WIDTH));
return ret;
end function;
procedure push_reference is
begin
for i in 0 to reference.length-1 loop
SB_out.Push(wr_sig & reference.last(i) & reference.data(i));
end loop;
end procedure;
procedure start_test is
begin
start <= '1';
wait until rising_edge(clk);
start <= '0';
wait until rising_edge(clk);
end procedure;
begin
assert (TEST_STRING = "TEST_CONFIG_1") report "user_config incompatible with testbench." severity FAILURE;
SetAlertLogName("rtps_builtin_endpoint - Level 0 - Remote Liveliness Assertion Handling");
SetAlertEnable(FAILURE, TRUE);
SetAlertEnable(ERROR, TRUE);
SetAlertEnable(WARNING, TRUE);
SetLogEnable(DEBUG, FALSE);
SetLogEnable(PASSED, FALSE);
SetLogEnable(INFO, TRUE);
RV.InitSeed(RV'instance_name);
-- Participant RTPS Submessage
sub := DEFAULT_RTPS_SUBMESSAGE;
sub.submessageID := SID_DATA;
sub.writerId := ENTITYID_SPDP_BUILTIN_PARTICIPANT_ANNOUNCER;
sub.readerId := ENTITYID_SPDP_BUILTIN_PARTICIPANT_DETECTOR;
sub.flags(SUBMESSAGE_DATA_FLAG_POS) := '1';
-- Participant 0
p0.guidPrefix := gen_rand_guid_prefix;
p0.nr := 0;
p0.defaultUnicastLocatorList := (numLocators => int(1,CDR_LONG_WIDTH), locator => (0 => gen_rand_loc_2, others => EMPTY_LOCATOR));
p0.availableBuiltinEndpoints(DISC_BUILTIN_ENDPOINT_SUBSCRIPTIONS_DETECTOR) := '1';
p0.availableBuiltinEndpoints(DISC_BUILTIN_ENDPOINT_SUBSCRIPTIONS_ANNOUNCER):= '1';
p0.availableBuiltinEndpoints(DISC_BUILTIN_ENDPOINT_PUBLICATIONS_DETECTOR) := '1';
p0.availableBuiltinEndpoints(DISC_BUILTIN_ENDPOINT_PUBLICATIONS_ANNOUNCER) := '1';
-- Participant 1
p1.guidPrefix := gen_rand_guid_prefix;
p1.nr := 1;
p1.defaultUnicastLocatorList := (numLocators => int(1,CDR_LONG_WIDTH), locator => (0 => gen_rand_loc_2, others => EMPTY_LOCATOR));
p1.availableBuiltinEndpoints(DISC_BUILTIN_ENDPOINT_SUBSCRIPTIONS_DETECTOR) := '1';
p1.availableBuiltinEndpoints(DISC_BUILTIN_ENDPOINT_SUBSCRIPTIONS_ANNOUNCER):= '1';
p1.availableBuiltinEndpoints(DISC_BUILTIN_ENDPOINT_PUBLICATIONS_DETECTOR) := '1';
p1.availableBuiltinEndpoints(DISC_BUILTIN_ENDPOINT_PUBLICATIONS_ANNOUNCER) := '1';
for i in 0 to RV.RandInt(1,10) loop
rand_data.data(i) := RV.RandSlv(WORD_WIDTH);
rand_data.length := rand_data.length + 1;
end loop;
Log("Initiating Test", INFO);
stim_done <= '0';
start <= '0';
reset <= '1';
wait until rising_edge(clk);
wait until rising_edge(clk);
reset <= '0';
-- *PARTICIPANT*
Log("Current Time: 0s", INFO);
Log("Match Participant 0", INFO);
sub := DEFAULT_RTPS_SUBMESSAGE;
sub.submessageID := SID_DATA;
sub.writerId := ENTITYID_SPDP_BUILTIN_PARTICIPANT_ANNOUNCER;
sub.readerId := ENTITYID_SPDP_BUILTIN_PARTICIPANT_DETECTOR;
sub.writerSN := gen_sn(1);
sub.flags(SUBMESSAGE_DATA_FLAG_POS) := '1';
participant := p0;
gen_participant_data(participant, sub.data);
gen_sentinel(sub.data);
gen_rtps_handler_out(sub, participant, stimulus);
start_test;
wait_on_complete;
stimulus := EMPTY_TEST_PACKET;
reference := EMPTY_TEST_PACKET;
Log("Match Participant 1", INFO);
sub := DEFAULT_RTPS_SUBMESSAGE;
sub.submessageID := SID_DATA;
sub.writerId := ENTITYID_SPDP_BUILTIN_PARTICIPANT_ANNOUNCER;
sub.readerId := ENTITYID_SPDP_BUILTIN_PARTICIPANT_DETECTOR;
sub.writerSN := gen_sn(1);
sub.flags(SUBMESSAGE_DATA_FLAG_POS) := '1';
participant := p1;
gen_participant_data(participant, sub.data);
gen_sentinel(sub.data);
gen_rtps_handler_out(sub, participant, stimulus);
start_test;
wait_on_complete;
stimulus := EMPTY_TEST_PACKET;
reference := EMPTY_TEST_PACKET;
Log("Participant 0 Automatic Liveliness Assertion", INFO);
sub := DEFAULT_RTPS_SUBMESSAGE;
sub.submessageID := SID_DATA;
sub.writerId := ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER;
sub.readerId := ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_READER;
sub.writerSN := gen_sn(1);
sub.flags(SUBMESSAGE_DATA_FLAG_POS) := '1';
participant := p0;
gen_liveliness_assertion(p0, FALSE, sub.data);
gen_rtps_handler_out(sub, participant, stimulus);
gen_liveliness_update_frame(p0, reference);
wr_sig := AUTOMATIC_LIVELINESS_READERS;
push_reference;
start_test;
wait_on_complete;
stimulus := EMPTY_TEST_PACKET;
reference := EMPTY_TEST_PACKET;
Log("Participant 1 Manual Liveliness Assertion", INFO);
sub := DEFAULT_RTPS_SUBMESSAGE;
sub.submessageID := SID_DATA;
sub.writerId := ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER;
sub.readerId := ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_READER;
sub.writerSN := gen_sn(1);
sub.flags(SUBMESSAGE_DATA_FLAG_POS) := '1';
participant := p1;
gen_liveliness_assertion(p1, TRUE, sub.data);
gen_rtps_handler_out(sub, participant, stimulus);
gen_liveliness_update_frame(p1, reference);
wr_sig := MANUAL_BY_PARTICIPANT_LIVELINESS_READERS;
push_reference;
start_test;
wait_on_complete;
stimulus := EMPTY_TEST_PACKET;
reference := EMPTY_TEST_PACKET;
Log("Participant 0 Manual Liveliness Assertion [+DATA Bytes]", INFO);
sub := DEFAULT_RTPS_SUBMESSAGE;
sub.submessageID := SID_DATA;
sub.writerId := ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER;
sub.readerId := ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_READER;
sub.writerSN := gen_sn(2);
sub.flags(SUBMESSAGE_DATA_FLAG_POS) := '1';
participant := p0;
gen_liveliness_assertion(p0, TRUE, rand_data, sub.data);
gen_rtps_handler_out(sub, participant, stimulus);
gen_liveliness_update_frame(p0, reference);
wr_sig := MANUAL_BY_PARTICIPANT_LIVELINESS_READERS;
push_reference;
start_test;
wait_on_complete;
stimulus := EMPTY_TEST_PACKET;
reference := EMPTY_TEST_PACKET;
TranscriptOpen(RESULTS_FILE, APPEND_MODE);
SetTranscriptMirror;
stim_done <= '1';
wait until check_done = '1';
AlertIf(not SB_out.empty, "Incomplete test run");
ReportAlerts;
TranscriptClose;
std.env.stop;
wait;
end process;
clock_prc : process
begin
clk <= '0';
wait for 25 ns;
clk <= '1';
wait for 25 ns;
end process;
in_empty_prc : process
begin
in_empty <= '0';
wait until rd_sig = '1';
wait until rising_edge(clk);
in_empty <= '1';
wait until rising_edge(clk);
end process;
endpoint_full_prc : process
begin
endpoint_full <= (others => '0');
wait until (or endpoint_wr) = '1';
wait until rising_edge(clk);
endpoint_full <= (others => '1');
wait until rising_edge(clk);
end process;
alert_prc : process(all)
begin
if rising_edge(clk) then
alertif(in_empty = '1' and rd_sig = '1', "Input FIFO read signal high while empty signal high", ERROR);
alertif(endpoint_full /= (0 to NUM_ENDPOINTS-1 => '0') and (endpoint_wr /= (0 to NUM_ENDPOINTS-1 => '0')), "Endpoint FIFO write signal high while full signal high", ERROR);
end if;
end process;
input_prc : process(all)
begin
data_in <= stimulus.data(cnt_stim);
last_word_in <= stimulus.last(cnt_stim);
if rising_edge(clk) then
if (reset = '1') then
cnt_stim <= 0;
stim_stage <= IDLE;
packet_sent <= '1';
else
case (stim_stage) is
when IDLE =>
if (start = '1' and stimulus.length /= 0) then
stim_stage <= BUSY;
cnt_stim <= 0;
packet_sent <= '0';
end if;
when BUSY =>
if (rd_sig = '1') then
if (cnt_stim = stimulus.length-1) then
stim_stage <= IDLE;
packet_sent <= '1';
else
cnt_stim <= cnt_stim + 1;
end if;
end if;
end case;
end if;
end if;
end process;
output_check_prc : process(all)
begin
check_done <= '0';
if rising_edge(clk) then
if (endpoint_wr /= (0 to NUM_ENDPOINTS-1 => '0')) then
SB_out.Check(endpoint_wr & last_word_out & data_out);
end if;
if (stim_done = '1' and SB_out.empty) then
check_done <= '1';
end if;
end if;
end process;
watchdog : process
begin
wait for 1 ms;
Alert("Test timeout", FAILURE);
std.env.stop;
end process;
end architecture;

View File

@ -964,7 +964,6 @@ begin
in_empty_prc : process
begin
in_empty <= '0';
wait; -- TODO: Remove
wait until rd_sig = '1';
wait until rising_edge(clk);
in_empty <= '1';
@ -974,7 +973,6 @@ begin
endpoint_full_prc : process
begin
full <= '0';
wait; -- TODO: Remove
wait until wr_sig = '1';
wait until rising_edge(clk);
full <= '1';

View File

@ -23,6 +23,7 @@ analyze Level_0/L0_rtps_builtin_endpoint_test3.vhd
analyze Level_0/L0_rtps_builtin_endpoint_test4.vhd
analyze Level_0/L0_rtps_builtin_endpoint_test5.vhd
analyze Level_0/L0_rtps_builtin_endpoint_test6.vhd
analyze Level_0/L0_rtps_builtin_endpoint_test7.vhd
analyze Level_0/L0_rtps_out_test1.vhd
analyze Level_1/L1_rtps_builtin_endpoint_test1.vhd
@ -34,5 +35,6 @@ analyze Level_1/L1_rtps_builtin_endpoint_test1.vhd
#simulate L0_rtps_builtin_endpoint_test4
#simulate L0_rtps_builtin_endpoint_test5
#simulate L0_rtps_builtin_endpoint_test6
simulate L0_rtps_builtin_endpoint_test7
#simulate L0_rtps_out_test1
simulate L1_rtps_builtin_endpoint_test1
#simulate L1_rtps_builtin_endpoint_test1

View File

@ -1107,6 +1107,7 @@ begin
-- GUID Prefix 3/3
when 3 =>
data_out <= guid(2);
last_word_out <= '1';
-- DONE
stage_next <= SKIP_PACKET;

View File

@ -225,6 +225,7 @@ package rtps_test_package is
procedure gen_endpoint_data( ref : in ENDPOINT_DATA_TYPE; output : inout TEST_PACKET_TYPE; pid : in std_logic_vector(PARAMETER_ID_WIDTH-1 downto 0); offset : in integer);
procedure gen_endpoint_match_frame( ref : in ENDPOINT_DATA_TYPE; output : inout TEST_PACKET_TYPE);
procedure gen_participant_match_frame( ref : in PARTICIPANT_DATA_TYPE; output : inout TEST_PACKET_TYPE);
procedure gen_liveliness_update_frame( ref : in PARTICIPANT_DATA_TYPE; output : inout TEST_PACKET_TYPE);
function gen_endpoint_array(readers : boolean) return ENDPOINT_DATA_ARRAY_TYPE;
procedure gen_liveliness_assertion(participant : in PARTICIPANT_DATA_TYPE; manual : in boolean; extra_data : in TEST_PACKET_TYPE; output : inout TEST_PACKET_TYPE);
@ -1377,6 +1378,23 @@ package body rtps_test_package is
output.last(output.length-1) := '1';
end procedure;
procedure gen_liveliness_update_frame( ref : in PARTICIPANT_DATA_TYPE; output : inout TEST_PACKET_TYPE) is
begin
-- OPCODE
output.data(output.length) := OPCODE_LIVELINESS_UPDATE;
output.length := output.length + 1;
-- GUID Prefix
output.data(output.length) := ref.guidPrefix(0);
output.length := output.length + 1;
output.data(output.length) := ref.guidPrefix(1);
output.length := output.length + 1;
output.data(output.length) := ref.guidPrefix(2);
output.length := output.length + 1;
-- Mark Last Word
output.last(output.length-1) := '1';
end procedure;
-- The Arguments "pid" and "offset" can be used to modify the parameter generation. More specifically, the length of the parameter denoted by "pid" is modified by "offset" 4-Byte words.
-- Also setting "pid" forces the respective parameter to be writen out even if it is equal to the default value.
procedure gen_endpoint_data( ref : in ENDPOINT_DATA_TYPE; output : inout TEST_PACKET_TYPE; pid : in std_logic_vector(PARAMETER_ID_WIDTH-1 downto 0); offset : in integer) is