| From a63f37595a06cb328c1e53b53989d61764d3fefe Mon Sep 17 00:00:00 2001 |
| From: Derek Chow <derekjchow@google.com> |
| Date: Thu, 27 Feb 2025 20:56:54 +0000 |
| Subject: [PATCH 2/2] Update cocotb script to support newer version. |
| |
| Target: ddb9634ec4fdd19f2464e5926252b262d0779fab |
| --- |
| cocotb/cocotb.bzl | 2 +- |
| cocotb/cocotb_wrapper.py | 20 +++++++++-- |
| ...-Remove-autodetect-of-VERILATOR_ROOT.patch | 34 +++++++++++++++++++ |
| .../verilator/verilator.BUILD.bazel | 8 +++-- |
| dependency_support/verilator/verilator.bzl | 10 ++++-- |
| 5 files changed, 66 insertions(+), 8 deletions(-) |
| create mode 100644 dependency_support/verilator/0001-Remove-autodetect-of-VERILATOR_ROOT.patch |
| |
| diff --git a/cocotb/cocotb.bzl b/cocotb/cocotb.bzl |
| index cde681b..a99e220 100644 |
| --- a/cocotb/cocotb.bzl |
| +++ b/cocotb/cocotb.bzl |
| @@ -170,7 +170,7 @@ def _cocotb_test_impl(ctx): |
| vhdl_files = _collect_vhdl_files(ctx).to_list() |
| |
| # create test script |
| - runner_script = ctx.actions.declare_file("cocotb_runner.sh") |
| + runner_script = ctx.actions.declare_file(ctx.attr.name + "_cocotb_runner.sh") |
| ctx.actions.write( |
| output = runner_script, |
| content = _get_test_command(ctx, verilog_files, vhdl_files), |
| diff --git a/cocotb/cocotb_wrapper.py b/cocotb/cocotb_wrapper.py |
| index 03d0dbc..d6829c6 100644 |
| --- a/cocotb/cocotb_wrapper.py |
| +++ b/cocotb/cocotb_wrapper.py |
| @@ -13,7 +13,7 @@ |
| # limitations under the License. |
| |
| import argparse |
| -from cocotb.runner import get_runner, check_results_file |
| +from cocotb_tools.runner import get_runner |
| |
| |
| cocotb_build_flags = [ |
| @@ -96,6 +96,12 @@ def cocotb_argument_parser(): |
| default=[], |
| help="Extra build arguments for the simulator", |
| ) |
| + parser.add_argument( |
| + "--test_args", |
| + nargs="*", |
| + default=[], |
| + help="Extra test arguments for the simulator", |
| + ) |
| parser.add_argument( |
| "--hdl_toplevel", default=None, help="Name of the HDL toplevel module" |
| ) |
| @@ -167,7 +173,17 @@ if __name__ == "__main__": |
| build_flags = filter_args(vars(args), cocotb_build_flags) |
| test_flags = filter_args(vars(args), cocotb_test_flags) |
| |
| + build_args = [] |
| + for build_arg in build_flags['build_args']: |
| + build_args += build_arg.split(" ") |
| + build_flags['build_args'] = build_args |
| + build_flags['always'] = True |
| + |
| + test_args = [] |
| + for test_arg in test_flags['test_args']: |
| + test_args += test_arg.split(" ") |
| + test_flags['test_args'] = test_args |
| + |
| runner = get_runner(args.sim) |
| runner.build(**build_flags) |
| results_xml = runner.test(**test_flags) |
| - check_results_file(results_xml) |
| diff --git a/dependency_support/verilator/0001-Remove-autodetect-of-VERILATOR_ROOT.patch b/dependency_support/verilator/0001-Remove-autodetect-of-VERILATOR_ROOT.patch |
| new file mode 100644 |
| index 0000000..9e08372 |
| --- /dev/null |
| +++ b/dependency_support/verilator/0001-Remove-autodetect-of-VERILATOR_ROOT.patch |
| @@ -0,0 +1,34 @@ |
| +From a5369fe645344bb80cad339fe0a77233b535e50c Mon Sep 17 00:00:00 2001 |
| +From: Alex Van Damme <atv@google.com> |
| +Date: Mon, 3 Mar 2025 14:59:47 -0800 |
| +Subject: [PATCH] Remove autodetect of VERILATOR_ROOT |
| + |
| +--- |
| + bin/verilator | 11 ----------- |
| + 1 file changed, 11 deletions(-) |
| + |
| +diff --git a/bin/verilator b/bin/verilator |
| +index 264f0d6c2..a2df113ba 100755 |
| +--- a/bin/verilator |
| ++++ b/bin/verilator |
| +@@ -69,17 +69,6 @@ if (! GetOptions( |
| + pod2usage(-exitstatus => 2, -verbose => 0); |
| + } |
| + |
| +-my $verilator_root = realpath("$RealBin/.."); |
| +-if (defined $ENV{VERILATOR_ROOT}) { |
| +- if ((!-d $ENV{VERILATOR_ROOT}) || $verilator_root ne realpath($ENV{VERILATOR_ROOT})) { |
| +- warn "%Error: verilator: VERILATOR_ROOT is set to inconsistent path. Suggest leaving it unset.\n"; |
| +- warn "%Error: VERILATOR_ROOT=$ENV{VERILATOR_ROOT}\n"; |
| +- exit 1; |
| +- } |
| +-} else { |
| +- print "export VERILATOR_ROOT='$verilator_root'\n" if $Debug; |
| +- $ENV{VERILATOR_ROOT} = $verilator_root; |
| +-} |
| + |
| + if ($opt_gdbbt && !gdb_works()) { |
| + warn "-Info: --gdbbt ignored: gdb doesn't seem to be working\n" if $Debug; |
| +-- |
| +2.48.1.711.g2feabab25a-goog |
| + |
| diff --git a/dependency_support/verilator/verilator.BUILD.bazel b/dependency_support/verilator/verilator.BUILD.bazel |
| index 3fadcca..b7322c2 100644 |
| --- a/dependency_support/verilator/verilator.BUILD.bazel |
| +++ b/dependency_support/verilator/verilator.BUILD.bazel |
| @@ -251,7 +251,10 @@ verilator_bisonpre( |
| |
| cc_library( |
| name = "verilatedos", |
| - hdrs = ["include/verilatedos.h"], |
| + hdrs = [ |
| + "include/verilatedos.h", |
| + "include/verilatedos_c.h", |
| + ], |
| strip_include_prefix = "include/", |
| ) |
| |
| @@ -362,7 +365,6 @@ cc_library( |
| "include/verilated_vcd_sc.h", |
| "include/verilated_vpi.h", |
| "include/verilated.h", |
| - "include/verilatedos.h", |
| ], |
| # TODO: Remove these once upstream fixes these warnings |
| copts = [ |
| @@ -390,6 +392,7 @@ cc_library( |
| "@accellera_systemc//:systemc", |
| "@net_zlib//:zlib", |
| ":vltstd", |
| + ":verilatedos", |
| ], |
| ) |
| |
| @@ -458,6 +461,7 @@ cc_binary( |
| "include/verilated_vpi.h", |
| "include/verilated.h", |
| "include/verilatedos.h", |
| + "include/verilatedos_c.h", |
| "include/vltstd/svdpi.h", |
| "include/vltstd/sv_vpi_user.h", |
| "include/vltstd/vpi_user.h", |
| diff --git a/dependency_support/verilator/verilator.bzl b/dependency_support/verilator/verilator.bzl |
| index 376a24f..e574271 100644 |
| --- a/dependency_support/verilator/verilator.bzl |
| +++ b/dependency_support/verilator/verilator.bzl |
| @@ -22,7 +22,11 @@ def verilator(): |
| http_archive, |
| name = "verilator", |
| build_file = Label("@rules_hdl//dependency_support/verilator:verilator.BUILD.bazel"), |
| - urls = ["https://github.com/verilator/verilator/archive/refs/tags/v5.022.tar.gz"], |
| - sha256 = "3c2f5338f4b6ce7e2f47a142401acdd18cbf4c5da06092618d6d036c0afef12d", |
| - strip_prefix = "verilator-5.022", |
| + urls = ["https://github.com/verilator/verilator/archive/refs/tags/v5.026.tar.gz"], |
| + sha256 = "87fdecf3967007d9ee8c30191ff2476f2a33635d0e0c6e3dbf345cc2f0c50b78", |
| + strip_prefix = "verilator-5.026", |
| + patch_args = ["-p1"], |
| + patches = [ |
| + Label("@rules_hdl//dependency_support/verilator:0001-Remove-autodetect-of-VERILATOR_ROOT.patch"), |
| + ], |
| ) |
| -- |
| 2.48.1.711.g2feabab25a-goog |
| |