mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Fix try_put method of unbounded mailbox (#4608)
This commit is contained in:
parent
33c5b5feb8
commit
774c10396c
@ -47,7 +47,7 @@ package std;
|
||||
endtask
|
||||
|
||||
function int try_put(T message);
|
||||
if (num() < m_bound) begin
|
||||
if (m_bound == 0 || num() < m_bound) begin
|
||||
m_queue.push_back(message);
|
||||
return 1;
|
||||
end
|
||||
|
23
test_regress/t/t_mailbox_unbounded.pl
Executable file
23
test_regress/t/t_mailbox_unbounded.pl
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2020 by Wilson Snyder. This program is free software; you
|
||||
# can redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
compile(
|
||||
verilator_flags2 => ["--exe --main --timing -Wall"],
|
||||
make_main => 0,
|
||||
);
|
||||
|
||||
execute(
|
||||
check_finished => 1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
30
test_regress/t/t_mailbox_unbounded.v
Normal file
30
test_regress/t/t_mailbox_unbounded.v
Normal file
@ -0,0 +1,30 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2023 by Antmicro Ltd.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
// verilator lint_off DECLFILENAME
|
||||
|
||||
module t(/*AUTOARG*/);
|
||||
mailbox #(int) m;
|
||||
int msg = 0;
|
||||
int out = 0;
|
||||
|
||||
initial begin
|
||||
m = new;
|
||||
fork
|
||||
begin
|
||||
#10; // So later then get() starts below
|
||||
msg = 1;
|
||||
if (m.try_put(msg) != 1) $stop;
|
||||
end
|
||||
begin
|
||||
m.get(out);
|
||||
if (out != 1) $stop;
|
||||
end
|
||||
join
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user