Skip to content

Commit 5f92e23

Browse files
committed
add support for sync interface
1 parent bac463b commit 5f92e23

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

vunit/vhdl/verification_components/src/apb_master.vhd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ begin
7171
wait until is_idle and queues_empty and rising_edge(clk);
7272
end if;
7373
handle_wait_until_idle(net, msg_type, request_msg);
74+
elsif msg_type = wait_for_time_msg then
75+
push(message_queue, request_msg);
7476
else
7577
unexpected_msg_type(msg_type);
7678
end if;
@@ -144,6 +146,11 @@ begin
144146
reply_msg := new_msg;
145147
push_std_ulogic_vector(reply_msg, prdata_i);
146148
reply(net, request_msg, reply_msg);
149+
150+
elsif msg_type = wait_for_time_msg then
151+
handle_wait_for_time(net, msg_type, request_msg);
152+
-- Re-align with the clock when a wait for time message was handled, because this breaks edge alignment.
153+
wait until rising_edge(clk);
147154
end if;
148155

149156
idle_bus <= true;

vunit/vhdl/verification_components/src/apb_master_pkg.vhd

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use work.bus_master_pkg.all;
1212
use work.com_pkg.all;
1313
use work.com_types_pkg.all;
1414
use work.logger_pkg.all;
15+
use work.sync_pkg.all;
1516
use work.memory_pkg.memory_t;
1617
use work.memory_pkg.to_vc_interface;
1718

@@ -49,9 +50,6 @@ package apb_master_pkg is
4950
-- default byte enable is all bytes
5051
constant byte_enable : std_logic_vector := "");
5152

52-
procedure wait_until_idle(signal net : inout network_t;
53-
bus_handle : apb_master_t);
54-
5553
-- Non blocking: Read the bus returning a reference to the future reply
5654
procedure read_bus(signal net : inout network_t;
5755
constant bus_handle : apb_master_t;
@@ -107,6 +105,14 @@ package apb_master_pkg is
107105
value : std_logic;
108106
timeout : delay_length := delay_length'high;
109107
msg : string := "");
108+
109+
procedure wait_until_idle(signal net : inout network_t;
110+
handle : apb_master_t;
111+
timeout : delay_length := max_timeout);
112+
113+
procedure wait_for_time(signal net : inout network_t;
114+
handle : apb_master_t;
115+
delay : delay_length);
110116
end package;
111117

112118
package body apb_master_pkg is
@@ -168,12 +174,6 @@ package body apb_master_pkg is
168174
write_bus(net, bus_handle.p_bus_handle, address, data, byte_enable);
169175
end procedure;
170176

171-
procedure wait_until_idle(signal net : inout network_t;
172-
bus_handle : apb_master_t) is
173-
begin
174-
wait_until_idle(net, bus_handle.P_bus_handle);
175-
end procedure;
176-
177177
-- Blocking: read bus with immediate reply
178178
procedure read_bus(signal net : inout network_t;
179179
constant bus_handle : apb_master_t;
@@ -252,4 +252,18 @@ package body apb_master_pkg is
252252
begin
253253
wait_until_read_bit_equals(net, bus_handle.p_bus_handle, addr, idx, value, timeout, msg);
254254
end procedure;
255+
256+
procedure wait_until_idle(signal net : inout network_t;
257+
handle : apb_master_t;
258+
timeout : delay_length := max_timeout) is
259+
begin
260+
wait_until_idle(net, handle.p_bus_handle.p_actor, timeout);
261+
end procedure;
262+
263+
procedure wait_for_time(signal net : inout network_t;
264+
handle : apb_master_t;
265+
delay : delay_length) is
266+
begin
267+
wait_for_time(net, handle.p_bus_handle.p_actor, delay);
268+
end procedure;
255269
end package body;

vunit/vhdl/verification_components/test/tb_apb_master.vhd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ begin
116116
wait_until_idle(net, bus_handle);
117117
check_expected_was_written(memory);
118118

119+
elsif run("wait_between_writes") then
120+
buf := allocate(memory => memory, num_bytes => 4, permissions => write_only);
121+
set_expected_word(memory, base_address(buf), x"1234");
122+
set_expected_word(memory, base_address(buf)+2, x"5678");
123+
write_bus(net, bus_handle, base_address(buf), x"1234");
124+
wait_for_time(net, bus_handle, 500 ns);
125+
write_bus(net, bus_handle, base_address(buf)+2, x"5678");
126+
wait_until_idle(net, bus_handle);
127+
check_expected_was_written(memory);
128+
119129
end if;
120130

121131
wait for 100 ns;

0 commit comments

Comments
 (0)