nested interface tests
This commit is contained in:
parent
96d2b15deb
commit
fd60e349ee
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env python3
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2025 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
|
||||
|
||||
import vltest_bootstrap
|
||||
|
||||
test.scenarios('simulator')
|
||||
|
||||
test.compile(verilator_flags2=["--binary"])
|
||||
|
||||
test.execute()
|
||||
|
||||
test.passes()
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
// nested interface test - direct assignment + nested interface task call in same always_comb
|
||||
|
||||
// verilog_format: off
|
||||
`define stop $stop
|
||||
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d (%s !== %s)\n", `__FILE__,`__LINE__, (gotv), (expv), `"gotv`", `"expv`"); `stop; end while(0);
|
||||
// verilog_format: on
|
||||
|
||||
interface leaf_if;
|
||||
logic l0;
|
||||
task set1(); l0 = 1'b1; endtask
|
||||
endinterface
|
||||
|
||||
interface top_if;
|
||||
leaf_if sub();
|
||||
endinterface
|
||||
|
||||
module mod #()(
|
||||
input logic sel
|
||||
,output logic val
|
||||
);
|
||||
|
||||
top_if if0();
|
||||
|
||||
always_comb begin
|
||||
if0.sub.l0 = 1'b0;
|
||||
if (sel) begin
|
||||
if0.sub.set1();
|
||||
end
|
||||
end
|
||||
|
||||
assign val = if0.sub.l0;
|
||||
|
||||
endmodule
|
||||
|
||||
module m_tb#()();
|
||||
|
||||
logic sel, val;
|
||||
|
||||
mod m(
|
||||
.sel(sel)
|
||||
,.val(val)
|
||||
);
|
||||
|
||||
initial begin
|
||||
#1;
|
||||
sel = 'b0;
|
||||
`checkd(val, 1'b0);
|
||||
#1;
|
||||
sel = 'b1;
|
||||
`checkd(val, 1'b1);
|
||||
#1;
|
||||
sel = 'b0;
|
||||
`checkd(val, 1'b0);
|
||||
#1;
|
||||
end
|
||||
|
||||
initial begin
|
||||
#5;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env python3
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2025 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
|
||||
|
||||
import vltest_bootstrap
|
||||
|
||||
test.scenarios('simulator')
|
||||
|
||||
test.compile(verilator_flags2=["--binary"])
|
||||
|
||||
test.execute()
|
||||
|
||||
test.passes()
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
// nested interface aggregator - two nested interfaces, only one driven
|
||||
|
||||
// verilog_format: off
|
||||
`define stop $stop
|
||||
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d (%s !== %s)\n", `__FILE__,`__LINE__, (gotv), (expv), `"gotv`", `"expv`"); `stop; end while(0);
|
||||
// verilog_format: on
|
||||
|
||||
interface chan_if;
|
||||
logic b0;
|
||||
task set1(); b0 = 1'b1; endtask
|
||||
endinterface
|
||||
|
||||
interface agg_if;
|
||||
chan_if tlb();
|
||||
chan_if ic();
|
||||
endinterface
|
||||
|
||||
module mod #()(
|
||||
input logic sel
|
||||
,output logic val
|
||||
);
|
||||
|
||||
agg_if a();
|
||||
|
||||
always_comb begin
|
||||
a.tlb.b0 = 1'b0;
|
||||
if (sel) a.tlb.set1();
|
||||
end
|
||||
|
||||
assign val = a.tlb.b0;
|
||||
|
||||
endmodule
|
||||
|
||||
module m_tb#()();
|
||||
|
||||
logic sel, val;
|
||||
|
||||
mod m(
|
||||
.sel(sel)
|
||||
,.val(val)
|
||||
);
|
||||
|
||||
initial begin
|
||||
#1;
|
||||
sel = 'b0;
|
||||
`checkd(val, 1'b0);
|
||||
#1;
|
||||
sel = 'b1;
|
||||
`checkd(val, 1'b1);
|
||||
#1;
|
||||
sel = 'b0;
|
||||
`checkd(val, 1'b0);
|
||||
#1;
|
||||
end
|
||||
|
||||
initial begin
|
||||
#5;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
||||
Loading…
Reference in New Issue