Skip to content

Commit

Permalink
Add an extension to allow X values in tdata for null bytes.
Browse files Browse the repository at this point in the history
Null bytes must be ignored by the slave and the interconnect is
allowed to remove these so checking that they contain valid data
is not necessary.
  • Loading branch information
bewimm committed Feb 28, 2022
1 parent cba2742 commit 97972c2
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 47 deletions.
98 changes: 52 additions & 46 deletions vunit/vhdl/verification_components/src/axi_stream_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,42 @@ package axi_stream_pkg is
type axi_stream_component_type_t is (null_component, default_component, custom_component);

type axi_stream_protocol_checker_t is record
p_type : axi_stream_component_type_t;
p_actor : actor_t;
p_data_length : natural;
p_id_length : natural;
p_dest_length : natural;
p_user_length : natural;
p_logger : logger_t;
p_max_waits : natural;
p_type : axi_stream_component_type_t;
p_actor : actor_t;
p_data_length : natural;
p_id_length : natural;
p_dest_length : natural;
p_user_length : natural;
p_logger : logger_t;
p_max_waits : natural;
p_allow_x_in_null_bytes : boolean;
end record;

constant null_axi_stream_protocol_checker : axi_stream_protocol_checker_t := (
p_type => null_component,
p_actor => null_actor,
p_data_length => 0,
p_id_length => 0,
p_dest_length => 0,
p_user_length => 0,
p_logger => null_logger,
p_max_waits => 0
p_type => null_component,
p_actor => null_actor,
p_data_length => 0,
p_id_length => 0,
p_dest_length => 0,
p_user_length => 0,
p_logger => null_logger,
p_max_waits => 0,
p_allow_x_in_null_bytes => false
);

-- The default protocol checker is used to specify that the checker
-- configuration is defined by the parent component into which the checker is
-- instantiated.
constant default_axi_stream_protocol_checker : axi_stream_protocol_checker_t := (
p_type => default_component,
p_actor => null_actor,
p_data_length => 0,
p_id_length => 0,
p_dest_length => 0,
p_user_length => 0,
p_logger => null_logger,
p_max_waits => 0
p_type => default_component,
p_actor => null_actor,
p_data_length => 0,
p_id_length => 0,
p_dest_length => 0,
p_user_length => 0,
p_logger => null_logger,
p_max_waits => 0,
p_allow_x_in_null_bytes => false
);

type axi_stream_monitor_t is record
Expand Down Expand Up @@ -191,13 +194,14 @@ package axi_stream_pkg is
) return axi_stream_monitor_t;

impure function new_axi_stream_protocol_checker(
data_length : natural;
id_length : natural := 0;
dest_length : natural := 0;
user_length : natural := 0;
logger : logger_t := axi_stream_logger;
actor : actor_t := null_actor;
max_waits : natural := 16
data_length : natural;
id_length : natural := 0;
dest_length : natural := 0;
user_length : natural := 0;
logger : logger_t := axi_stream_logger;
actor : actor_t := null_actor;
max_waits : natural := 16;
allow_x_in_null_bytes : boolean := false
) return axi_stream_protocol_checker_t;

impure function data_length(master : axi_stream_master_t) return natural;
Expand Down Expand Up @@ -469,24 +473,26 @@ package body axi_stream_pkg is
end;

impure function new_axi_stream_protocol_checker(
data_length : natural;
id_length : natural := 0;
dest_length : natural := 0;
user_length : natural := 0;
logger : logger_t := axi_stream_logger;
actor : actor_t := null_actor;
max_waits : natural := 16
data_length : natural;
id_length : natural := 0;
dest_length : natural := 0;
user_length : natural := 0;
logger : logger_t := axi_stream_logger;
actor : actor_t := null_actor;
max_waits : natural := 16;
allow_x_in_null_bytes : boolean := false
) return axi_stream_protocol_checker_t is
begin
return (
p_type => custom_component,
p_actor => actor,
p_data_length => data_length,
p_id_length => id_length,
p_dest_length => dest_length,
p_user_length => user_length,
p_logger => logger,
p_max_waits => max_waits);
p_type => custom_component,
p_actor => actor,
p_data_length => data_length,
p_id_length => id_length,
p_dest_length => dest_length,
p_user_length => user_length,
p_logger => logger,
p_max_waits => max_waits,
p_allow_x_in_null_bytes => allow_x_in_null_bytes);
end;

impure function data_length(master : axi_stream_master_t) return natural is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ architecture a of axi_stream_protocol_checker is
signal areset_n_d : std_logic := '0';
signal areset_rose : std_logic;
signal not_tvalid : std_logic;

signal tdata_normalized : std_logic_vector(tdata'range);

function normalize_tdata(data, strb, keep : std_logic_vector) return std_logic_vector is
variable ret : std_logic_vector(data'range);
begin
ret := data;
for i in keep'range loop
if keep(i) = '0' and strb(i) = '0' then
ret(i*8+7 downto i*8) := (others => '0');
end if;
end loop;
return ret;
end function;
begin
handshake_is_not_x <= '1' when not is_x(tvalid) and not is_x(tready) else '0';

Expand Down Expand Up @@ -112,7 +126,8 @@ begin

-- AXI4STREAM_ERRM_TDATA_X A value of X on TDATA is not permitted when TVALID
-- is HIGH
check_not_unknown(rule5_checker, aclk, tvalid, tdata, result("for tdata when tvalid is high"));
tdata_normalized <= normalize_tdata(tdata, tstrb, tkeep) when protocol_checker.p_allow_x_in_null_bytes else tdata;
check_not_unknown(rule5_checker, aclk, tvalid, tdata_normalized, result("for tdata when tvalid is high"));

-- AXI4STREAM_ERRM_TLAST_X A value of X on TLAST is not permitted when TVALID
-- is HIGH
Expand Down

0 comments on commit 97972c2

Please sign in to comment.