Skip to content

Commit 603e34b

Browse files
committed
config_mk_parser_test: cover VERILOG_FILES_BLACKBOX local-helper use
Two unit tests for the local-helper pattern that orfs_design()'s new local_arguments= parameter targets: - VERILOG_FILES_BLACKBOX routes to sources (not arguments), so the parser classifies it correctly as a SOURCE_VAR. - $(VERILOG_FILES_BLACKBOX) inside VERILOG_FILES is resolved during parsing, so a single helper assignment can contribute files to the top-level verilog_files list. These are the parser-side invariants that local_arguments= relies on when it later drops the helper from arguments/sources before orfs_flow. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent a816102 commit 603e34b

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

config_mk_parser_test.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,44 @@ def test_synth_hierarchical_is_argument(self):
586586
result = self.parser.parse(config)
587587
self.assertIn("SYNTH_HIERARCHICAL", result.arguments)
588588

589+
def test_verilog_files_blackbox_is_source(self):
590+
"""VERILOG_FILES_BLACKBOX is a SOURCE_VAR — routes to sources, not arguments.
591+
592+
Callers can declare it in config.mk and pass it through to
593+
orfs_design()'s local_arguments= to drop it before orfs_flow().
594+
"""
595+
config, _ = _write_config(
596+
"""\
597+
export PLATFORM = asap7
598+
export DESIGN_NAME = gcd
599+
export VERILOG_FILES_BLACKBOX = $(DESIGN_HOME)/src/gcd/bbox.v
600+
"""
601+
)
602+
result = self.parser.parse(config)
603+
self.assertIn("VERILOG_FILES_BLACKBOX", result.sources)
604+
self.assertNotIn("VERILOG_FILES_BLACKBOX", result.arguments)
605+
labels = result.sources["VERILOG_FILES_BLACKBOX"]
606+
self.assertTrue(any("bbox.v" in lbl for lbl in labels))
607+
608+
def test_verilog_files_blackbox_expands_in_verilog_files(self):
609+
"""$(VERILOG_FILES_BLACKBOX) inside VERILOG_FILES is resolved.
610+
611+
This is the local-helper use case: declare a file list once and
612+
reference it via $(VAR) expansion within the same config.mk.
613+
"""
614+
config, _ = _write_config(
615+
"""\
616+
export PLATFORM = asap7
617+
export DESIGN_NAME = gcd
618+
export VERILOG_FILES_BLACKBOX = $(DESIGN_HOME)/src/gcd/bbox.v
619+
export VERILOG_FILES = $(DESIGN_HOME)/src/gcd/top.v $(VERILOG_FILES_BLACKBOX)
620+
"""
621+
)
622+
result = self.parser.parse(config)
623+
joined = " ".join(result.verilog_files)
624+
self.assertIn("top.v", joined)
625+
self.assertIn("bbox.v", joined)
626+
589627

590628
class TestConditionalParsing(unittest.TestCase):
591629
"""Test parsing of conditional blocks (ifeq, ifdef, etc.)."""

0 commit comments

Comments
 (0)