Initial Commit - Forked from PeakRDL-regblock @ a440cc19769069be831d267505da4f3789a26695
This commit is contained in:
30
tests/lib/synthesizers/__init__.py
Normal file
30
tests/lib/synthesizers/__init__.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from typing import List, Optional, Type
|
||||
import functools
|
||||
|
||||
from .base import Synthesizer
|
||||
from .vivado import Vivado
|
||||
|
||||
ALL_SYNTHESIZERS: List[Synthesizer]
|
||||
ALL_SYNTHESIZERS = [
|
||||
Vivado,
|
||||
]
|
||||
|
||||
@functools.lru_cache()
|
||||
def get_synthesizer_cls(name: str) -> Optional[Type[Synthesizer]]:
|
||||
if name == "skip":
|
||||
return None
|
||||
|
||||
if name == "auto":
|
||||
# Find the first tool that is installed
|
||||
for synth_cls in ALL_SYNTHESIZERS:
|
||||
if synth_cls.is_installed():
|
||||
return synth_cls
|
||||
raise ValueError("Could not find any installed synthesis tools")
|
||||
|
||||
# Look up which explicit synth tool name was specified
|
||||
for synth_cls in ALL_SYNTHESIZERS:
|
||||
if synth_cls.name == name:
|
||||
if not synth_cls.is_installed():
|
||||
raise ValueError("Synthesis tool '%s' is not installed" % synth_cls.name)
|
||||
return synth_cls
|
||||
raise RuntimeError
|
||||
17
tests/lib/synthesizers/base.py
Normal file
17
tests/lib/synthesizers/base.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import TYPE_CHECKING, List
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..synth_testcase import SynthTestCase
|
||||
|
||||
class Synthesizer:
|
||||
name = ""
|
||||
|
||||
@classmethod
|
||||
def is_installed(cls) -> bool:
|
||||
raise NotImplementedError
|
||||
|
||||
def __init__(self, testcase: 'SynthTestCase' = None) -> None:
|
||||
self.testcase = testcase
|
||||
|
||||
def run(self) -> None:
|
||||
raise NotImplementedError
|
||||
29
tests/lib/synthesizers/vivado.py
Normal file
29
tests/lib/synthesizers/vivado.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
from .base import Synthesizer
|
||||
|
||||
class Vivado(Synthesizer):
|
||||
name = "vivado"
|
||||
|
||||
@classmethod
|
||||
def is_installed(cls) -> bool:
|
||||
return shutil.which("vivado") is not None
|
||||
|
||||
def run(self) -> None:
|
||||
script = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"vivado_scripts/run.tcl"
|
||||
)
|
||||
|
||||
cmd = [
|
||||
"vivado", "-nojournal", "-notrace",
|
||||
"-mode", "batch",
|
||||
"-log", "out.log",
|
||||
"-source", script,
|
||||
"-tclargs"
|
||||
]
|
||||
cmd.extend(self.testcase._get_synth_files())
|
||||
|
||||
subprocess.run(cmd, check=True)
|
||||
8
tests/lib/synthesizers/vivado_scripts/constr.xdc
Normal file
8
tests/lib/synthesizers/vivado_scripts/constr.xdc
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
create_clock -period 10.000 -name clk [get_ports clk]
|
||||
|
||||
set_input_delay -clock [get_clocks clk] -min -add_delay 0.000 [get_ports -filter {(DIRECTION == IN) && (NAME != clk)}]
|
||||
set_input_delay -clock [get_clocks clk] -max -add_delay 0.000 [get_ports -filter {(DIRECTION == IN) && (NAME != clk)}]
|
||||
|
||||
set_output_delay -clock [get_clocks clk] -min -add_delay 0.000 [get_ports -filter {DIRECTION == OUT}]
|
||||
set_output_delay -clock [get_clocks clk] -max -add_delay 0.000 [get_ports -filter {DIRECTION == OUT}]
|
||||
34
tests/lib/synthesizers/vivado_scripts/run.tcl
Normal file
34
tests/lib/synthesizers/vivado_scripts/run.tcl
Normal file
@@ -0,0 +1,34 @@
|
||||
set this_dir [file dirname [file normalize [info script]]]
|
||||
set files $argv
|
||||
|
||||
|
||||
# Multi-driven
|
||||
set_msg_config -id {[Synth 8-6858]} -new_severity "ERROR"
|
||||
set_msg_config -id {[Synth 8-6859]} -new_severity "ERROR"
|
||||
|
||||
# Implicit net
|
||||
set_msg_config -id {[Synth 8-992]} -new_severity "ERROR"
|
||||
|
||||
# Non-combo always_comb
|
||||
set_msg_config -id {[Synth 8-87]} -new_severity "ERROR"
|
||||
|
||||
# Latch
|
||||
set_msg_config -id {[Synth 8-327]} -new_severity "ERROR"
|
||||
|
||||
# Timing loop
|
||||
set_msg_config -id {[Synth 8-295]} -new_severity "ERROR"
|
||||
|
||||
# Promote all critical warnings to errors
|
||||
set_msg_config -severity {CRITICAL WARNING} -new_severity "ERROR"
|
||||
|
||||
|
||||
set_part [lindex [get_parts] 0]
|
||||
read_verilog -sv $files
|
||||
read_xdc $this_dir/constr.xdc
|
||||
synth_design -top regblock -mode out_of_context
|
||||
|
||||
#write_checkpoint -force synth.dcp
|
||||
|
||||
if {[get_msg_config -count -severity {CRITICAL WARNING}] || [get_msg_config -count -severity ERROR]} {
|
||||
error "Encountered errors"
|
||||
}
|
||||
Reference in New Issue
Block a user