Add Test 5 of DDS Writer

Test Lifespan Handling of DDS Writer.
This commit is contained in:
Greek 2021-03-29 17:55:11 +02:00
parent 501f67a67f
commit 4a67a18df2
4 changed files with 893 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,731 @@
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;
entity L0_dds_writer_test5_afk is
end entity;
architecture testbench of L0_dds_writer_test5_afk is
-- *CONSTANT DECLARATION*
constant MAX_REMOTE_ENDPOINTS : natural := 3;
-- *TYPE DECLARATION*
type STIM_STAGE_TYPE is (IDLE, START, PUSH, DONE, CHECK);
type REF_STAGE_TYPE is (IDLE, START, DONE, CHECK);
type KH_STAGE_TYPE is (IDLE, READ_DATA, PUSH_KEY_HASH);
type RTPS_TEST_TYPE is record
opcode : HISTORY_CACHE_OPCODE_TYPE;
cc : CACHE_CHANGE_TYPE;
ret_code : HISTORY_CACHE_RESPONSE_TYPE;
end record;
constant DEFAULT_RTPS_TEST : RTPS_TEST_TYPE := (
opcode => NOP,
cc => DEFAULT_CACHE_CHANGE,
ret_code => OK
);
type DDS_TEST_TYPE is record
opcode : DDS_WRITER_OPCODE_TYPE;
cc : CACHE_CHANGE_TYPE;
ret_code : std_logic_vector(RETURN_CODE_WIDTH-1 downto 0);
end record;
constant DEFAULT_DDS_TEST : DDS_TEST_TYPE := (
opcode => NOP,
cc => DEFAULT_CACHE_CHANGE,
ret_code => RETCODE_OK
);
-- *SIGNAL DECLARATION*
signal clk : std_logic := '0';
signal reset : std_logic := '1';
signal check_time : TIME_TYPE := TIME_ZERO;
signal start_rtps, start_dds, start_kh, ack_rtps, ack_dds, ack_kh, done_rtps, done_dds : std_logic := '0';
signal opcode_rtps : HISTORY_CACHE_OPCODE_TYPE := NOP;
signal opcode_dds : DDS_WRITER_OPCODE_TYPE := NOP;
signal opcode_kh : KEY_HOLDER_OPCODE_TYPE := NOP;
signal ret_rtps : HISTORY_CACHE_RESPONSE_TYPE := ERROR;
signal seq_nr_rtps, cc_seq_nr : SEQUENCENUMBER_TYPE := SEQUENCENUMBER_UNKNOWN;
signal ready_out_rtps, valid_out_rtps, last_word_out_rtps : std_logic := '0';
signal ready_in_dds, ready_out_dds, valid_in_dds, valid_out_dds, last_word_in_dds, last_word_out_dds : std_logic := '0';
signal ready_in_kh, ready_out_kh, valid_in_kh, valid_out_kh, last_word_in_kh, last_word_out_kh : std_logic := '0';
signal data_out_rtps, data_in_dds, data_out_dds, data_in_kh, data_out_kh : std_logic_vector(WORD_WIDTH-1 downto 0) := (others => '0');
signal get_data_rtps, liveliness_assertion, data_available, abort_kh : std_logic := '0';
signal cc_source_timestamp, source_ts_dds : TIME_TYPE := TIME_INVALID;
signal cc_kind : CACHE_CHANGE_KIND_TYPE := ALIVE;
signal cc_instance_handle, instance_handle_dds : INSTANCE_HANDLE_TYPE := HANDLE_NIL;
signal max_wait_dds : DURATION_TYPE := DURATION_INFINITE;
signal return_code_dds : std_logic_vector(RETURN_CODE_WIDTH-1 downto 0) := (others => '0');
signal status : std_logic_vector(STATUS_KIND_WIDTH-1 downto 0) := (others => '0');
signal stim_start, stim_done, ref_start, ref_done : std_logic := '0';
signal stim_cnt, ref_cnt, kh_cnt : natural := 0;
signal stim_stage : STIM_STAGE_TYPE := IDLE;
signal ref_stage : REF_STAGE_TYPE := IDLE;
signal kh_stage : KH_STAGE_TYPE := IDLE;
signal kh_data : TEST_PACKET_TYPE := EMPTY_TEST_PACKET;
shared variable stimulus : DDS_TEST_TYPE := DEFAULT_DDS_TEST;
shared variable reference : RTPS_TEST_TYPE := DEFAULT_RTPS_TEST;
signal inst_id, kind_id, sn_id, ts_id, data_id, ret_id, status_id, assert_id : AlertLogIDType;
-- *FUNCTION DECLARATION*
function extract_key_hash (payload : TEST_PACKET_TYPE) return INSTANCE_HANDLE_TYPE is
variable ret : INSTANCE_HANDLE_TYPE := HANDLE_NIL;
begin
for i in 0 to 3 loop
ret(i) := not payload.data(i);
end loop;
return ret;
end function;
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.dds_writer(arch)
generic map(
HISTORY_QOS => KEEP_ALL_HISTORY_QOS,
DEADLINE_QOS => DURATION_INFINITE,
LIFESPAN_QOS => gen_duration(2,0),
LEASE_DURATION => DURATION_INFINITE,
WITH_KEY => TRUE,
MAX_SAMPLES => std_logic_vector(to_unsigned(4,CDR_LONG_WIDTH)),
MAX_INSTANCES => std_logic_vector(to_unsigned(2,CDR_LONG_WIDTH)),
MAX_SAMPLES_PER_INSTANCE => std_logic_vector(to_unsigned(2,CDR_LONG_WIDTH)),
PAYLOAD_FRAME_SIZE => 11
)
port map (
clk => clk,
reset => reset,
time => check_time,
start_rtps => start_rtps,
opcode_rtps => opcode_rtps,
ack_rtps => ack_rtps,
done_rtps => done_rtps,
ret_rtps => ret_rtps,
seq_nr_rtps => seq_nr_rtps,
get_data_rtps => get_data_rtps,
data_out_rtps => data_out_rtps,
valid_out_rtps => valid_out_rtps,
ready_out_rtps => ready_out_rtps,
last_word_out_rtps => last_word_out_rtps,
liveliness_assertion => liveliness_assertion,
data_available => data_available,
cc_instance_handle => cc_instance_handle,
cc_kind => cc_kind,
cc_source_timestamp => cc_source_timestamp,
cc_seq_nr => cc_seq_nr,
start_kh => start_kh,
opcode_kh => opcode_kh,
ack_kh => ack_kh,
data_in_kh => data_in_kh,
valid_in_kh => valid_in_kh,
ready_in_kh => ready_in_kh,
last_word_in_kh => last_word_in_kh,
data_out_kh => data_out_kh,
valid_out_kh => valid_out_kh,
ready_out_kh => ready_out_kh,
last_word_out_kh => last_word_out_kh,
abort_kh => abort_kh,
start_dds => start_dds,
ack_dds => ack_dds,
opcode_dds => opcode_dds,
instance_handle_dds => instance_handle_dds,
source_ts_dds => source_ts_dds,
max_wait_dds => max_wait_dds,
done_dds => done_dds,
return_code_dds => return_code_dds,
ready_in_dds => ready_in_dds,
valid_in_dds => valid_in_dds,
data_in_dds => data_in_dds,
last_word_in_dds => last_word_in_dds,
ready_out_dds => ready_out_dds,
valid_out_dds => valid_out_dds,
data_out_dds => data_out_dds,
last_word_out_dds => last_word_out_dds,
status => status
);
stimulus_prc : process
variable RV : RandomPType;
variable kh1, kh2, kh3, kh4 : INSTANCE_HANDLE_TYPE := HANDLE_NIL;
variable cc1, cc2, cc3, cc4, cc : CACHE_CHANGE_TYPE := DEFAULT_CACHE_CHANGE;
alias idle_sig is <<signal uut.idle_sig : std_logic>>;
impure function gen_payload(key_hash : INSTANCE_HANDLE_TYPE; len : natural) return TEST_PACKET_TYPE is
variable ret : TEST_PACKET_TYPE := EMPTY_TEST_PACKET;
begin
assert (len >= 4) report "Payload length has to be at least 16 Bytes long" severity FAILURE;
for i in 0 to len-1 loop
if (i < 4) then
-- NOTE: Beginning of payload is negated key to allow deterministic Key Hash generation from the kh_prc
ret.data(ret.length) := not key_hash(i);
else
ret.data(ret.length) := RV.RandSlv(WORD_WIDTH);
end if;
ret.length := ret.length + 1;
end loop;
ret.last(ret.length-1) := '1';
return ret;
end function;
impure function gen_key_hash return KEY_HASH_TYPE is
variable ret : KEY_HASH_TYPE := (others => (others => '0'));
begin
for i in 0 to KEY_HASH_TYPE'length-1 loop
ret(i) := RV.RandSlv(WORD_WIDTH);
end loop;
return ret;
end function;
procedure start_stim is
begin
stim_start <= '1';
wait until rising_edge(clk);
stim_start <= '0';
wait until rising_edge(clk);
end procedure;
procedure start_ref is
begin
ref_start <= '1';
wait until rising_edge(clk);
ref_start <= '0';
wait until rising_edge(clk);
end procedure;
procedure wait_on_stim is
begin
if (stim_done /= '1') then
wait until stim_done = '1';
end if;
end procedure;
procedure wait_on_ref is
begin
if (ref_done /= '1') then
wait until ref_done = '1';
end if;
end procedure;
procedure wait_on_completion is
begin
if (ref_done /= '1' or stim_done /= '1') then
wait until ref_done = '1' and stim_done = '1';
end if;
end procedure;
-- NOTE: This procedure waits until the idle_sig is high for at least
-- two consecutive clock cycles.
procedure wait_on_idle is
begin
loop
if (idle_sig /= '1') then
wait until idle_sig = '1';
else
exit;
end if;
wait until rising_edge(clk);
wait until rising_edge(clk);
end loop;
end procedure;
begin
SetAlertLogName("dds_writer - (KEEP ALL, Infinite Lifespan, Keyed) - Level 0 - Lifespan Handling");
SetAlertEnable(FAILURE, TRUE);
SetAlertEnable(ERROR, TRUE);
SetAlertEnable(WARNING, TRUE);
SetLogEnable(DEBUG, FALSE);
SetLogEnable(PASSED, FALSE);
SetLogEnable(INFO, TRUE);
RV.InitSeed(RV'instance_name);
inst_id <= GetAlertLogID("Instance", ALERTLOG_BASE_ID);
kind_id <= GetAlertLogID("Cache Change Kind", ALERTLOG_BASE_ID);
sn_id <= GetAlertLogID("SequenceNumber", ALERTLOG_BASE_ID);
ts_id <= GetAlertLogID("TimeStamp", ALERTLOG_BASE_ID);
data_id <= GetAlertLogID("Data Out", ALERTLOG_BASE_ID);
ret_id <= GetAlertLogID("Return Code", ALERTLOG_BASE_ID);
status_id <= GetAlertLogID("Communication Status", ALERTLOG_BASE_ID);
assert_id <= GetAlertLogID("Assertion Propagation", ALERTLOG_BASE_ID);
-- Key Hashes
kh1 := gen_key_hash;
kh2 := gen_key_hash;
kh3 := gen_key_hash;
kh4 := gen_key_hash;
Log("Initiating Test", INFO);
Log("Current Time: 0s", INFO);
check_time <= TIME_ZERO;
reset <= '1';
wait until rising_edge(clk);
wait until rising_edge(clk);
reset <= '0';
wait_on_idle;
-- Stored CC: 0, 0, 0, 0
cc.serialized_key := FALSE;
cc.kind := ALIVE;
cc.instance := kh1;
cc.payload := gen_payload(kh1,10);
cc.seq_nr := gen_sn(1);
Log("DDS Operation WRITE [Instance 1, HANDLE_NIL, Aligned Payload] (ACCEPTED)", INFO);
stimulus := DEFAULT_DDS_TEST;
stimulus.opcode := WRITE;
stimulus.cc := cc;
stimulus.cc.instance:= HANDLE_NIL;
stimulus.ret_code := RETCODE_OK;
start_stim;
wait_on_stim;
cc1 := cc;
-- Stored CC: I1S1, 0, 0, 0
cc.serialized_key := FALSE;
cc.kind := ALIVE;
cc.instance := kh2;
cc.payload := gen_payload(kh2,10);
cc.seq_nr := gen_sn(2);
Log("DDS Operation WRITE [Instance 2, HANDLE_NIL, Aligned Payload] (ACCEPTED)", INFO);
stimulus := DEFAULT_DDS_TEST;
stimulus.opcode := WRITE;
stimulus.cc := cc;
stimulus.cc.instance:= HANDLE_NIL;
stimulus.ret_code := RETCODE_OK;
start_stim;
wait_on_stim;
cc2 := cc;
-- Stored CC: I1S1, I2S2, 0, 0
Log("Current Time: 1s", INFO);
check_time <= gen_duration(1,0);
wait until rising_edge(clk);
wait until rising_edge(clk);
wait_on_idle;
cc.serialized_key := FALSE;
cc.kind := ALIVE;
cc.instance := kh1;
cc.payload := gen_payload(kh1,10);
cc.seq_nr := gen_sn(3);
Log("DDS Operation WRITE [Instance 1, HANDLE_NIL, Aligned Payload] (ACCEPTED)", INFO);
stimulus := DEFAULT_DDS_TEST;
stimulus.opcode := WRITE;
stimulus.cc := cc;
stimulus.cc.instance:= HANDLE_NIL;
stimulus.ret_code := RETCODE_OK;
start_stim;
wait_on_stim;
cc3 := cc;
-- Stored CC: I1S1, I2S2, I1S3, 0
cc.serialized_key := FALSE;
cc.kind := ALIVE;
cc.instance := kh1;
cc.payload := gen_payload(kh1,10);
cc.seq_nr := gen_sn(4);
Log("DDS Operation WRITE [Instance 1, HANDLE_NIL, Aligned Payload] (REJECTED: MAX_SAMPLES_PER_INSTANCE exceeded)", INFO);
stimulus := DEFAULT_DDS_TEST;
stimulus.opcode := WRITE;
stimulus.cc := cc;
stimulus.cc.instance:= HANDLE_NIL;
stimulus.ret_code := RETCODE_OUT_OF_RESOURCES;
start_stim;
wait_on_stim;
cc.serialized_key := TRUE;
cc.kind := NOT_ALIVE_UNREGISTERED;
cc.instance := kh2;
cc.payload := gen_payload(kh2,5);
cc.seq_nr := gen_sn(4);
Log("DDS Operation UNREGISTER_INSTANCE [Instance 2] (ACCEPTED)", INFO);
stimulus := DEFAULT_DDS_TEST;
stimulus.opcode := UNREGISTER_INSTANCE;
stimulus.cc := cc;
stimulus.ret_code := RETCODE_OK;
start_stim;
wait_on_stim;
cc4 := cc;
-- Stored CC: I1S1, I2S2, I1S3, I2S4
Log("Current Time: 2s", INFO);
check_time <= gen_duration(2,0);
wait until rising_edge(clk);
wait until rising_edge(clk);
wait_on_idle;
-- Stored CC: 0, 0, I1S3, I2S4
-- VALIDATE STATE
Log("RTPS Operation GET_MIN_SN (Expected SN 3)", INFO);
reference := DEFAULT_RTPS_TEST;
reference.opcode := GET_MIN_SN;
reference.cc.seq_nr := gen_sn(3);
start_ref;
wait_on_ref;
Log("RTPS Operation GET_MAX_SN (Expected SN 4)", INFO);
reference := DEFAULT_RTPS_TEST;
reference.opcode := GET_MAX_SN;
reference.cc.seq_nr := gen_sn(4);
start_ref;
wait_on_ref;
cc.serialized_key := FALSE;
cc.kind := ALIVE;
cc.instance := kh1;
cc.payload := gen_payload(kh1,10);
cc.seq_nr := gen_sn(5);
Log("DDS Operation WRITE [Instance 1, HANDLE_NIL, Aligned Payload] (ACCEPTED)", INFO);
stimulus := DEFAULT_DDS_TEST;
stimulus.opcode := WRITE;
stimulus.cc := cc;
stimulus.cc.instance:= HANDLE_NIL;
stimulus.ret_code := RETCODE_OK;
start_stim;
wait_on_stim;
cc1 := cc;
-- Stored CC: I1S5, 0, I1S3, I2S4
cc.serialized_key := FALSE;
cc.kind := ALIVE;
cc.instance := kh3;
cc.payload := gen_payload(kh3,10);
cc.seq_nr := gen_sn(6);
Log("DDS Operation WRITE [Instance 3, HANDLE_NIL, Aligned Payload] (REJECTED: MAX_INSTANCES exceeded)", INFO);
stimulus := DEFAULT_DDS_TEST;
stimulus.opcode := WRITE;
stimulus.cc := cc;
stimulus.cc.instance:= HANDLE_NIL;
stimulus.ret_code := RETCODE_OUT_OF_RESOURCES;
start_stim;
wait_on_stim;
Log("Current Time: 3s", INFO);
check_time <= gen_duration(3,0);
wait until rising_edge(clk);
wait until rising_edge(clk);
wait_on_idle;
-- Stored CC: I1S5, 0, 0, 0
-- VALIDATE STATE
Log("RTPS Operation GET_MIN_SN (Expected SN 5)", INFO);
reference := DEFAULT_RTPS_TEST;
reference.opcode := GET_MIN_SN;
reference.cc.seq_nr := gen_sn(5);
start_ref;
wait_on_ref;
Log("RTPS Operation GET_MAX_SN (Expected SN 5)", INFO);
reference := DEFAULT_RTPS_TEST;
reference.opcode := GET_MAX_SN;
reference.cc.seq_nr := gen_sn(5);
start_ref;
wait_on_ref;
cc.serialized_key := FALSE;
cc.kind := ALIVE;
cc.instance := kh3;
cc.payload := gen_payload(kh3,10);
cc.seq_nr := gen_sn(6);
Log("DDS Operation WRITE [Instance 3, HANDLE_NIL, Aligned Payload] (ACCEPTED)", INFO);
stimulus := DEFAULT_DDS_TEST;
stimulus.opcode := WRITE;
stimulus.cc := cc;
stimulus.cc.instance:= HANDLE_NIL;
stimulus.ret_code := RETCODE_OK;
start_stim;
wait_on_stim;
cc2 := cc;
-- Stored CC: I1S5, I3S6, 0, 0
wait_on_completion;
TranscriptOpen(RESULTS_FILE, APPEND_MODE);
SetTranscriptMirror;
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;
alert_prc : process(all)
begin
if rising_edge(clk) then
-- TODO
end if;
end process;
stim_prc : process(all)
begin
if rising_edge(clk) then
stim_done <= '0';
case (stim_stage) is
when IDLE =>
if (stim_start = '1') then
stim_stage <= START;
else
stim_done <= '1';
end if;
when START =>
if (ack_dds = '1') then
case (stimulus.opcode) is
when others =>
stim_stage <= PUSH;
stim_cnt <= 0;
end case;
end if;
when PUSH =>
if (ready_in_dds = '1') then
stim_cnt <= stim_cnt + 1;
if (stim_cnt = stimulus.cc.payload.length-1) then
-- DEFAULT
stim_stage <= DONE;
case (stimulus.opcode) is
when REGISTER_INSTANCE =>
stim_stage <= CHECK;
stim_cnt <= 0;
when LOOKUP_INSTANCE =>
stim_stage <= CHECK;
stim_cnt <= 0;
when others =>
null;
end case;
end if;
end if;
when DONE =>
if (done_dds = '1') then
AffirmIfEqual(ret_id, return_code_dds, stimulus.ret_code);
case (stimulus.opcode) is
when others =>
stim_stage <= IDLE;
end case;
end if;
when CHECK =>
if (valid_out_dds = '1') then
AffirmIfEqual(data_id, data_out_dds, stimulus.cc.instance(stim_cnt));
stim_cnt <= stim_cnt + 1;
if (stim_cnt = 3) then
AlertIf(data_id, last_word_out_dds /= '1', "Last Word Signal not pulled High", ERROR);
stim_stage <= IDLE;
end if;
end if;
end case;
end if;
-- DEFAULT
start_dds <= '0';
valid_in_dds <= '0';
last_word_in_dds <= '0';
data_in_dds <= (others => '0');
instance_handle_dds <= HANDLE_NIL;
source_ts_dds <= TIME_INVALID;
ready_out_dds <= '0';
case (stim_stage) is
when START =>
start_dds <= '1';
opcode_dds <= stimulus.opcode;
instance_handle_dds <= stimulus.cc.instance;
source_ts_dds <= stimulus.cc.src_timestamp;
when PUSH =>
valid_in_dds <= '1';
data_in_dds <= stimulus.cc.payload.data(stim_cnt);
last_word_in_dds <= stimulus.cc.payload.last(stim_cnt);
when CHECK =>
ready_out_dds <= '1';
when others =>
null;
end case;
end process;
ref_prc : process(all)
begin
if rising_edge(clk) then
ref_done <= '0';
case (ref_stage) is
when IDLE =>
if (ref_start = '1') then
ref_stage <= START;
else
ref_done <= '1';
end if;
when START =>
if (ack_rtps = '1') then
ref_stage <= DONE;
end if;
when DONE =>
if (done_rtps = '1') then
-- DEFAULT
ref_stage <= IDLE;
AffirmIfEqual(ret_id, HISTORY_CACHE_RESPONSE_TYPE'pos(ret_rtps), HISTORY_CACHE_RESPONSE_TYPE'pos(reference.ret_code));
case (reference.opcode) is
when GET_CACHE_CHANGE =>
if (reference.ret_code = OK) then
AffirmIfEqual(inst_id, cc_instance_handle(0), reference.cc.instance(0));
AffirmIfEqual(inst_id, cc_instance_handle(1), reference.cc.instance(1));
AffirmIfEqual(inst_id, cc_instance_handle(2), reference.cc.instance(2));
AffirmIfEqual(inst_id, cc_instance_handle(3), reference.cc.instance(3));
AffirmIfEqual(kind_id, CACHE_CHANGE_KIND_TYPE'pos(cc_kind), CACHE_CHANGE_KIND_TYPE'pos(reference.cc.kind));
AffirmIfEqual(sn_id, convert_from_double_word(cc_seq_nr), convert_from_double_word(reference.cc.seq_nr));
AffirmIfEqual(ts_id, convert_from_double_word(cc_source_timestamp), convert_from_double_word(reference.cc.src_timestamp));
ref_stage <= CHECK;
ref_cnt <= 0;
end if;
when GET_MIN_SN =>
AffirmIfEqual(sn_id, convert_from_double_word(cc_seq_nr), convert_from_double_word(reference.cc.seq_nr));
when GET_MAX_SN =>
AffirmIfEqual(sn_id, convert_from_double_word(cc_seq_nr), convert_from_double_word(reference.cc.seq_nr));
when others =>
null;
end case;
end if;
when CHECK =>
if (valid_out_rtps = '1') then
AffirmIfEqual(data_id, last_word_out_rtps & data_out_rtps, reference.cc.payload.last(ref_cnt) & reference.cc.payload.data(ref_cnt));
ref_cnt <= ref_cnt + 1;
if (ref_cnt = reference.cc.payload.length-1) then
ref_stage <= IDLE;
end if;
end if;
end case;
end if;
-- DEFAULT
start_rtps <= '0';
get_data_rtps <= '0';
ready_out_rtps <= '0';
case (ref_stage) is
when START =>
start_rtps <= '1';
opcode_rtps <= reference.opcode;
seq_nr_rtps <= reference.cc.seq_nr;
when DONE =>
if (done_rtps = '1') then
case (reference.opcode) is
when GET_CACHE_CHANGE =>
get_data_rtps <= '1';
when others =>
null;
end case;
end if;
when CHECK =>
ready_out_rtps <= '1';
when others =>
null;
end case;
end process;
kh_prc : process (all)
variable tmp_key_hash : INSTANCE_HANDLE_TYPE := HANDLE_NIL;
begin
if rising_edge(clk) then
case (kh_stage) is
when IDLE =>
if (start_kh = '1') then
case (opcode_kh) is
when PUSH_DATA =>
kh_stage <= READ_DATA;
kh_cnt <= 0;
kh_data <= EMPTY_TEST_PACKET;
when PUSH_SERIALIZED_KEY =>
kh_stage <= READ_DATA;
kh_cnt <= 0;
kh_data <= EMPTY_TEST_PACKET;
when READ_KEY_HASH =>
kh_stage <= PUSH_KEY_HASH;
kh_cnt <= 0;
when others =>
Alert("Unexpected Key Holder Operation", FAILURE);
end case;
end if;
when READ_DATA =>
if (valid_out_kh = '1') then
kh_data.data(kh_cnt) <= data_out_kh;
kh_data.last(kh_cnt) <= last_word_out_kh;
kh_data.length <= kh_data.length + 1;
kh_cnt <= kh_cnt + 1;
if (last_word_out_kh = '1') then
kh_stage <= IDLE;
end if;
end if;
when PUSH_KEY_HASH =>
if (ready_in_kh = '1') then
kh_cnt <= kh_cnt + 1;
if (kh_cnt = INSTANCE_HANDLE_TYPE'length-1) then
kh_stage <= IDLE;
end if;
end if;
end case;
end if;
-- DEFAULT
ack_kh <= '0';
ready_out_kh <= '0';
valid_in_kh <= '0';
data_in_kh <= (others => '0');
last_word_in_kh <= '0';
case (kh_stage) is
when IDLE =>
if (start_kh = '1') then
ack_kh <= '1';
end if;
when READ_DATA =>
ready_out_kh <= '1';
when PUSH_KEY_HASH =>
valid_in_kh <= '1';
tmp_key_hash := extract_key_hash(kh_data);
data_in_kh <= tmp_key_hash(kh_cnt);
if (kh_cnt = INSTANCE_HANDLE_TYPE'length-1) then
last_word_in_kh <= '1';
end if;
end case;
end process;
watchdog : process
begin
wait for 1 ms;
Alert("Test timeout", FAILURE);
std.env.stop;
end process;
end architecture;

View File

@ -61,7 +61,8 @@ analyze ../dds_writer.vhd
#analyze Level_0/L0_dds_writer_test2_aik.vhd
#analyze Level_0/L0_dds_writer_test3_aik.vhd
#analyze Level_0/L0_dds_writer_test3_ain.vhd
analyze Level_0/L0_dds_writer_test4_aik.vhd
#analyze Level_0/L0_dds_writer_test4_aik.vhd
analyze Level_0/L0_dds_writer_test5_afk.vhd
#simulate L0_rtps_handler_test1
#simulate L0_rtps_handler_test2
@ -105,4 +106,5 @@ analyze Level_0/L0_dds_writer_test4_aik.vhd
#simulate L0_dds_writer_test2_aik
#simulate L0_dds_writer_test3_aik
#simulate L0_dds_writer_test3_ain
simulate L0_dds_writer_test4_aik
#simulate L0_dds_writer_test4_aik
simulate L0_dds_writer_test5_afk

View File

@ -742,6 +742,7 @@ begin
-- Samples Available
if (oldest_sample /= SAMPLE_MEMORY_MAX_ADDRESS) then
is_lifespan_check_next <= '1';
cur_sample_next <= oldest_sample;
stage_next <= CHECK_LIFESPAN;
cnt_next <= 0;
@ -1181,7 +1182,7 @@ begin
-- Synthesis Guard
if (LIFESPAN_QOS /= DURATION_INFINITE) then
sample_valid_in <= '1';
sample_addr <= cur_sample + SMF_LIFESPAN_DEADLINE_OFFSET;
sample_addr <= cur_sample + SMF_LIFESPAN_DEADLINE_OFFSET + 1;
sample_write_data <= std_logic_vector(lifespan(1));
-- Memory Flow Control Guard
if (sample_ready_in = '1') then
@ -1964,7 +1965,7 @@ begin
-- Update Lifespan Check Time
if (LIFESPAN_QOS /= DURATION_INFINITE and lifespan < lifespan_time) then
lifespan_next <= lifespan;
lifespan_time_next <= lifespan;
end if;
if (remove_oldest_inst_sample = '1' or (remove_oldest_sample = '1' and remove_ack_sample = '1')) then
@ -4389,7 +4390,7 @@ begin
deadline_miss_last_inst <= HANDLE_NIL;
key_hash <= HANDLE_NIL;
deadline_time <= time + DEADLINE_QOS;
lifespan_time <= TIME_INVALID;
lifespan_time <= TIME_INFINITE;
source_ts <= TIME_INVALID;
timeout_time <= TIME_INVALID;
lease_deadline <= time + LEASE_DURATION;