Skip to content

Commit b15d822

Browse files
committed
implement wait states
1 parent 3ddb987 commit b15d822

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

vunit/vhdl/verification_components/src/apb_slave.vhd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ library ieee;
88
use ieee.std_logic_1164.all;
99
use ieee.numeric_std.all;
1010

11+
library osvvm;
12+
use osvvm.RandomPkg.RandomPType;
13+
1114
use work.memory_pkg.all;
1215
use work.apb_pkg.all;
1316
use work.logger_pkg.all;
@@ -45,6 +48,7 @@ begin
4548
end procedure;
4649

4750
variable addr : integer;
51+
variable rnd : RandomPType;
4852
begin
4953
drive_outputs_invalid;
5054
wait until rising_edge(clk);
@@ -56,6 +60,11 @@ begin
5660
wait until psel_i = '1' and rising_edge(clk);
5761
-- ACCESS state
5862

63+
while rnd.Uniform(0.0, 1.0) > bus_handle.ready_high_probability loop
64+
pready_o <= '0';
65+
wait until rising_edge(clk);
66+
end loop;
67+
5968
pready_o <= '1';
6069

6170
addr := to_integer(unsigned(paddr_i));

vunit/vhdl/verification_components/test/tb_apb_master.vhd

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ architecture a of tb_apb_master is
4343
address_length => paddr'length);
4444
constant memory : memory_t := new_memory;
4545
constant slave_handle : apb_slave_t := new_apb_slave(memory => memory,
46-
logger => get_logger("apb slave"));
46+
logger => get_logger("apb slave"),
47+
ready_high_probability => 0.5);
4748

4849
signal start : boolean := false;
4950
begin
5051

5152
main_stim : process
5253
variable buf : buffer_t;
53-
variable data : std_logic_vector(prdata'range);
54+
variable data, data2 : std_logic_vector(prdata'range);
5455
variable bus_ref1, bus_ref2 : bus_reference_t;
5556
begin
5657
show(get_logger("apb slave"), display_handler, debug);
@@ -95,6 +96,25 @@ begin
9596
wait_until_idle(net, bus_handle);
9697
check_expected_was_written(memory);
9798

99+
elsif run("many_reads") then
100+
for i in 1 to 100 loop
101+
buf := allocate(memory => memory, num_bytes => 2, permissions => read_only);
102+
data := std_logic_vector(to_unsigned(i, BUS_DATA_WIDTH));
103+
write_word(memory, base_address(buf), data);
104+
read_bus(net, bus_handle, base_address(buf), data2);
105+
check_equal(data2, data, "Check read data.");
106+
end loop;
107+
108+
elsif run("many_writes") then
109+
for i in 1 to 100 loop
110+
buf := allocate(memory => memory, num_bytes => 2, permissions => write_only);
111+
data := std_logic_vector(to_unsigned(i, BUS_DATA_WIDTH));
112+
set_expected_word(memory, base_address(buf), data);
113+
write_bus(net, bus_handle, base_address(buf), data);
114+
end loop;
115+
wait_until_idle(net, bus_handle);
116+
check_expected_was_written(memory);
117+
98118
end if;
99119

100120
wait for 100 ns;

0 commit comments

Comments
 (0)