From 1aab608cffa19332dc5cf722def7413b16f5ee54 Mon Sep 17 00:00:00 2001 From: Rupert Swarbrick Date: Wed, 14 Jul 2021 17:27:13 +0100 Subject: [PATCH] Add a test for interfaces on modules loaded on-demand --- tests/svinterfaces/load_and_derive.sv | 20 ++++++++++++++++++++ tests/svinterfaces/load_and_derive.ys | 6 ++++++ tests/svinterfaces/ondemand.sv | 5 +++++ tests/svinterfaces/run-test.sh | 4 ++-- tests/svinterfaces/run_simple.sh | 15 +++++++++++++++ 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 tests/svinterfaces/load_and_derive.sv create mode 100644 tests/svinterfaces/load_and_derive.ys create mode 100644 tests/svinterfaces/ondemand.sv create mode 100755 tests/svinterfaces/run_simple.sh diff --git a/tests/svinterfaces/load_and_derive.sv b/tests/svinterfaces/load_and_derive.sv new file mode 100644 index 000000000..0de0de3b3 --- /dev/null +++ b/tests/svinterfaces/load_and_derive.sv @@ -0,0 +1,20 @@ +// This test checks that we correctly elaborate interfaces in modules, even if they are loaded on +// demand. The "ondemand" module is defined in ondemand.sv in this directory and will be read as +// part of the hierarchy pass. + +interface iface; + logic [7:0] x; + logic [7:0] y; +endinterface + +module dut (input logic [7:0] x, output logic [7:0] y); + iface intf(); + assign intf.x = x; + assign y = intf.y; + + ondemand u(.intf); +endmodule + +module ref (input logic [7:0] x, output logic [7:0] y); + assign y = ~x; +endmodule diff --git a/tests/svinterfaces/load_and_derive.ys b/tests/svinterfaces/load_and_derive.ys new file mode 100644 index 000000000..067235ec2 --- /dev/null +++ b/tests/svinterfaces/load_and_derive.ys @@ -0,0 +1,6 @@ +read_verilog -sv load_and_derive.sv +hierarchy -libdir . -check +flatten +equiv_make ref dut equiv +equiv_simple +equiv_status -assert diff --git a/tests/svinterfaces/ondemand.sv b/tests/svinterfaces/ondemand.sv new file mode 100644 index 000000000..70d6048f8 --- /dev/null +++ b/tests/svinterfaces/ondemand.sv @@ -0,0 +1,5 @@ +// This is used by the load_and_derive test. + +module ondemand (iface intf); + assign intf.y = ~intf.x; +endmodule diff --git a/tests/svinterfaces/run-test.sh b/tests/svinterfaces/run-test.sh index 86567d1c1..9ef53926c 100755 --- a/tests/svinterfaces/run-test.sh +++ b/tests/svinterfaces/run-test.sh @@ -1,6 +1,6 @@ #/bin/bash -e - - ./runone.sh svinterface1 ./runone.sh svinterface_at_top + +./run_simple.sh load_and_derive diff --git a/tests/svinterfaces/run_simple.sh b/tests/svinterfaces/run_simple.sh new file mode 100755 index 000000000..bce994443 --- /dev/null +++ b/tests/svinterfaces/run_simple.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Run a simple test with a .ys file + +if [ $# != 1 ]; then + echo >&2 "Expected 1 argument" + exit 1 +fi + +echo -n "Test: $1 ->" +../../yosys $1.ys >$1.log_stdout 2>$1.log_stderr || { + echo "ERROR!" + exit 1 +} +echo "ok" -- 2.30.2