Added the ability to specify a regex filter for the part-name on the synthesis tests. Implemented as --synth-part. Closes #179 (#180)
This commit is contained in:
@@ -46,3 +46,17 @@ def pytest_addoption(parser):
|
|||||||
auto: choose the best tool based on what is installed
|
auto: choose the best tool based on what is installed
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.addoption(
|
||||||
|
"--synth-part",
|
||||||
|
type=str,
|
||||||
|
default=".*",
|
||||||
|
help="""
|
||||||
|
A REGEX expression used to filter the part used for the synthesis test.
|
||||||
|
|
||||||
|
Useful when the default method for finding a part finds a part which you don't have a
|
||||||
|
license for.
|
||||||
|
|
||||||
|
Defaults to '.*'.
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
from typing import List
|
|
||||||
import os
|
import os
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from .base_testcase import BaseTestCase
|
from .base_testcase import BaseTestCase
|
||||||
from .synthesizers import get_synthesizer_cls
|
from .synthesizers import get_synthesizer_cls
|
||||||
|
|
||||||
|
|
||||||
class SynthTestCase(BaseTestCase):
|
class SynthTestCase(BaseTestCase):
|
||||||
|
|
||||||
def _get_synth_files(self) -> List[str]:
|
def _get_synth_files(self) -> List[str]:
|
||||||
@@ -26,7 +27,7 @@ class SynthTestCase(BaseTestCase):
|
|||||||
def run_synth(self) -> None:
|
def run_synth(self) -> None:
|
||||||
name = self.request.config.getoption("--synth-tool")
|
name = self.request.config.getoption("--synth-tool")
|
||||||
synth_cls = get_synthesizer_cls(name)
|
synth_cls = get_synthesizer_cls(name)
|
||||||
synth = synth_cls(self)
|
synth = synth_cls(self, request=self.request)
|
||||||
|
|
||||||
# cd into the build directory
|
# cd into the build directory
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
|
|||||||
@@ -1,17 +1,28 @@
|
|||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ..synth_testcase import SynthTestCase
|
from ..synth_testcase import SynthTestCase
|
||||||
|
|
||||||
class Synthesizer:
|
class Synthesizer:
|
||||||
name = ""
|
name = ""
|
||||||
|
|
||||||
|
#: this gets auto-loaded via the _load_request autouse fixture
|
||||||
|
request = None # type: pytest.FixtureRequest
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def _load_request(self, request):
|
||||||
|
self.request = request
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_installed(cls) -> bool:
|
def is_installed(cls) -> bool:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def __init__(self, testcase: 'SynthTestCase' = None) -> None:
|
def __init__(self, testcase: 'SynthTestCase' = None,
|
||||||
|
request: 'pytest.FixtureRequest' = None) -> None:
|
||||||
self.testcase = testcase
|
self.testcase = testcase
|
||||||
|
self.request = request
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from .base import Synthesizer
|
from .base import Synthesizer
|
||||||
|
|
||||||
|
|
||||||
class Vivado(Synthesizer):
|
class Vivado(Synthesizer):
|
||||||
name = "vivado"
|
name = "vivado"
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ class Vivado(Synthesizer):
|
|||||||
"-mode", "batch",
|
"-mode", "batch",
|
||||||
"-log", "out.log",
|
"-log", "out.log",
|
||||||
"-source", script,
|
"-source", script,
|
||||||
"-tclargs"
|
"-tclargs", self.request.config.getoption("--synth-part")
|
||||||
]
|
]
|
||||||
cmd.extend(self.testcase._get_synth_files())
|
cmd.extend(self.testcase._get_synth_files())
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
set this_dir [file dirname [file normalize [info script]]]
|
set this_dir [file dirname [file normalize [info script]]]
|
||||||
set files $argv
|
set files [lrange $argv 1 end]
|
||||||
|
|
||||||
|
set part_regex [lindex $argv 0]
|
||||||
|
|
||||||
|
|
||||||
# Multi-driven
|
# Multi-driven
|
||||||
@@ -22,7 +24,7 @@ set_msg_config -id {[Synth 8-295]} -new_severity "ERROR"
|
|||||||
set_msg_config -severity {CRITICAL WARNING} -new_severity "ERROR"
|
set_msg_config -severity {CRITICAL WARNING} -new_severity "ERROR"
|
||||||
|
|
||||||
|
|
||||||
set_part [lindex [get_parts] 0]
|
set_part [lindex [get_parts -regex $part_regex] 0]
|
||||||
read_verilog -sv $files
|
read_verilog -sv $files
|
||||||
read_xdc $this_dir/constr.xdc
|
read_xdc $this_dir/constr.xdc
|
||||||
synth_design -top regblock -mode out_of_context
|
synth_design -top regblock -mode out_of_context
|
||||||
|
|||||||
Reference in New Issue
Block a user