Skip to content

Commit 9e1adc3

Browse files
committed
Refactor and comment
1 parent 1de3375 commit 9e1adc3

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

vunit/vhdl/verification_components/src/axi_stream_master.vhd

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,30 @@ begin
114114

115115
procedure drive_policy(signal s : out std_logic_vector; policy : inactive_bus_policy_t) is
116116
begin
117-
if policy = 'X' then
118-
s <= (s'range => 'X');
119-
elsif policy = '0' then
120-
s <= (s'range => '0');
121-
elsif policy = '1' then
122-
s <= (s'range => '1');
123-
end if;
117+
case policy is
118+
when 'X' =>
119+
s <= (s'range => 'X');
120+
when '0' =>
121+
s <= (s'range => '0');
122+
when '1' =>
123+
s <= (s'range => '1');
124+
when hold =>
125+
null;
126+
end case;
124127
end;
125128

126129
procedure drive_policy(signal s : out std_logic; policy : inactive_bus_policy_t) is
127130
begin
128-
if policy = 'X' then
129-
s <= 'X';
130-
elsif policy = '0' then
131-
s <= '0';
132-
elsif policy = '1' then
133-
s <= '1';
134-
end if;
131+
case policy is
132+
when 'X' =>
133+
s <= 'X';
134+
when '0' =>
135+
s <= '0';
136+
when '1' =>
137+
s <= '1';
138+
when hold =>
139+
null;
140+
end case;
135141
end;
136142

137143
begin

vunit/vhdl/verification_components/src/axi_stream_pkg.vhd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ package axi_stream_pkg is
3636
type axi_stream_signal_t is (tdata, tlast, tkeep, tstrb, tid, tdest, tuser, all_signals);
3737
type inactive_axi_stream_policy_t is array (tdata to tuser) of inactive_bus_policy_t;
3838

39+
-- The standard protocol checker requires tuser to be a known value when the reset is released
3940
constant default_axi_stream_policy : inactive_axi_stream_policy_t := (tuser => '0', others => 'X');
4041
constant all_0_policy : inactive_axi_stream_policy_t := (others => '0');
4142
constant all_1_policy : inactive_axi_stream_policy_t := (others => '1');
@@ -464,6 +465,8 @@ package body axi_stream_pkg is
464465
impure function to_integer_vector_ptr(stall_config : stall_config_t) return integer_vector_ptr_t is
465466
variable result : integer_vector_ptr_t := new_integer_vector_ptr(3);
466467
begin
468+
-- Since values are in the 0 - 1 range, we can have the full resolution of the mantissa fit within
469+
-- an integer if reals are implemented as single-precision floats.
467470
set(result, 0, integer(stall_config.stall_probability * (2.0 ** 23)));
468471
set(result, 1, stall_config.min_stall_cycles);
469472
set(result, 2, stall_config.max_stall_cycles);

0 commit comments

Comments
 (0)