Skip to content

Commit

Permalink
Only check tdata when both tkeep and tstrb are high
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsAsplund committed Aug 7, 2024
1 parent a245b41 commit 2bf9abf
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 78 deletions.
22 changes: 13 additions & 9 deletions vunit/vhdl/verification_components/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,19 @@ def gen_avalon_master_tests(obj, *args):
for id_length in [0, 8]:
for dest_length in [0, 8]:
for user_length in [0, 8]:
for test in TB_AXI_STREAM.get_tests("*check"):
test.add_config(
name="id_l=%d dest_l=%d user_l=%d" % (id_length, dest_length, user_length),
generics=dict(
g_id_length=id_length,
g_dest_length=dest_length,
g_user_length=user_length,
),
)
for data_length in [8, 16]:
for test in TB_AXI_STREAM.get_tests("*check"):
test.add_config(
name=f"id_l={id_length} dest_l={dest_length} user_l={user_length} data_l={data_length}",
generics=dict(
g_data_length=data_length,
g_id_length=id_length,
g_dest_length=dest_length,
g_user_length=user_length,
),
)

TB_AXI_STREAM.test("test passing with no tkeep").set_generic("g_data_length", 16)

TB_AXI_STREAM_PROTOCOL_CHECKER = LIB.test_bench("tb_axi_stream_protocol_checker")

Expand Down
40 changes: 11 additions & 29 deletions vunit/vhdl/verification_components/src/axi_stream_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use work.checker_pkg.all;
use work.check_pkg.all;
use work.stream_master_pkg.stream_master_t;
use work.stream_slave_pkg.stream_slave_t;
use work.sync_pkg.sync_handle_t;
use work.sync_pkg.all;
use work.com_pkg.all;
use work.com_types_pkg.all;

Expand Down Expand Up @@ -736,35 +736,17 @@ package body axi_stream_pkg is
variable got_tuser : std_logic_vector(user_length(axi_stream)-1 downto 0);
variable check_msg : msg_t := new_msg(check_axi_stream_msg);
begin
push_string(check_msg, msg);
push_std_ulogic_vector(check_msg, expected);
push_std_ulogic_vector(check_msg, tkeep);
push_std_ulogic_vector(check_msg, tstrb);
push_std_ulogic(check_msg, tlast);
push_std_ulogic_vector(check_msg, tid);
push_std_ulogic_vector(check_msg, tdest);
push_std_ulogic_vector(check_msg, tuser);
send(net, axi_stream.p_actor, check_msg);
if blocking then
pop_axi_stream(net, axi_stream, got_tdata, got_tlast, got_tkeep, got_tstrb, got_tid, got_tdest, got_tuser);
check_equal(got_tdata, expected, "TDATA mismatch, " & msg);
check_equal(got_tlast, tlast, "TLAST mismatch, " & msg);
if tkeep'length > 0 then
check_equal(got_tkeep, tkeep, "TKEEP mismatch, " & msg);
end if;
if tstrb'length > 0 then
check_equal(got_tstrb, tstrb, "TSTRB mismatch, " & msg);
end if;
if tid'length > 0 then
check_equal(got_tid, tid, "TID mismatch, " & msg);
end if;
if tdest'length > 0 then
check_equal(got_tdest, tdest, "TDEST mismatch, " & msg);
end if;
if tuser'length > 0 then
check_equal(got_tuser, tuser, "TUSER mismatch, " & msg);
end if;
else
push_string(check_msg, msg);
push_std_ulogic_vector(check_msg, expected);
push_std_ulogic_vector(check_msg, tkeep);
push_std_ulogic_vector(check_msg, tstrb);
push_std_ulogic(check_msg, tlast);
push_std_ulogic_vector(check_msg, tid);
push_std_ulogic_vector(check_msg, tdest);
push_std_ulogic_vector(check_msg, tuser);
send(net, axi_stream.p_actor, check_msg);
wait_until_idle(net, as_sync(axi_stream));
end if;
end procedure;

Expand Down
17 changes: 15 additions & 2 deletions vunit/vhdl/verification_components/src/axi_stream_slave.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ architecture a of axi_stream_slave is
signal bus_process_done : event_t := new_event(bus_process_done_id);

begin

main : process
variable request_msg : msg_t;
variable notify_msg : msg_t;
Expand Down Expand Up @@ -97,6 +96,8 @@ begin
tuser(tuser'range)
);
variable rnd : RandomPType;
variable expected_tdata : std_logic_vector(tdata'range);
variable mismatch : boolean;
variable tstrb_resolved : std_logic_vector(tstrb'range);
begin
rnd.InitSeed(rnd'instance_name);
Expand Down Expand Up @@ -140,7 +141,19 @@ begin
reply(net, msg, reply_msg);
elsif msg_type = check_axi_stream_msg then
report_msg := new_string_ptr(pop_string(msg));
check_field(tdata, pop_std_ulogic_vector(msg), "TDATA mismatch, " & to_string(report_msg));

expected_tdata := pop_std_ulogic_vector(msg);
mismatch := false;
for idx in tkeep'range loop
if tkeep(idx) and tstrb_resolved(idx) then
mismatch := tdata(8 * idx + 7 downto 8 * idx) /= expected_tdata(8 * idx + 7 downto 8 * idx);
exit when mismatch;
end if;
end loop;
if mismatch then
check_field(tdata, expected_tdata, "TDATA mismatch, " & to_string(report_msg));
end if;

check_field(tkeep, pop_std_ulogic_vector(msg), "TKEEP mismatch, " & to_string(report_msg));
check_field(tstrb_resolved, pop_std_ulogic_vector(msg), "TSTRB mismatch, " & to_string(report_msg));
check_equal(tlast, pop_std_ulogic(msg), "TLAST mismatch, " & to_string(report_msg));
Expand Down
Loading

0 comments on commit 2bf9abf

Please sign in to comment.