Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions edalize/apicula.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

from __future__ import annotations

import os.path

from edalize.edam import ToolDoc
from edalize.edatool import Edatool
from edalize.utils import EdaCommands
from edalize.nextpnr import Nextpnr
Expand All @@ -15,9 +18,11 @@ class Apicula(Edatool):
argtypes = ["vlogdefine", "vlogparam"]

@classmethod
def get_doc(cls, api_ver):
def get_doc(cls, api_ver: int) -> ToolDoc | None:
if api_ver == 0:
options = {
options: ToolDoc = {
# Placeholder; the return statement below sets the final description.
"description": "",
"lists": [],
"members": [
{
Expand All @@ -36,8 +41,9 @@ def get_doc(cls, api_ver):
"members": options["members"],
"lists": options["lists"],
}
return None

def configure_main(self):
def configure_main(self) -> None:
# Pass apicula tool options to yosys and nextpnr
self.edam["tool_options"] = {
"yosys": {
Expand Down
8 changes: 6 additions & 2 deletions edalize/ascentlint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

from __future__ import annotations

import logging
import re
import os
from collections import OrderedDict

from edalize.edam import ToolDoc
from edalize.edatool import Edatool

logger = logging.getLogger(__name__)
Expand All @@ -17,7 +20,7 @@ class Ascentlint(Edatool):
argtypes = ["vlogdefine", "vlogparam"]

@classmethod
def get_doc(cls, api_ver):
def get_doc(cls, api_ver: int) -> ToolDoc | None:
if api_ver == 0:
return {
"description": """ Real Intent Ascent Lint backend
Expand All @@ -33,8 +36,9 @@ def get_doc(cls, api_ver):
}
],
}
return None

def configure_main(self):
def configure_main(self) -> None:
(src_files, incdirs) = self._get_fileset_files(force_slash=True)

self._write_fileset_to_f_file(
Expand Down
14 changes: 8 additions & 6 deletions edalize/build_runners/make.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from typing import List
from __future__ import annotations

from pathlib import Path
from typing import Any

from edalize.utils import EdaCommands


class Make(object):
def __init__(self, flow_options):
self.build_options = flow_options.get("flow_make_options", [])
def __init__(self, flow_options: dict[str, Any]) -> None:
self.build_options: list[str] = flow_options.get("flow_make_options", [])

def get_build_command(self):
def get_build_command(self) -> tuple[str, list[str]]:
return ("make", self.build_options)

def write(self, commands: EdaCommands, work_root: Path):
outfile = work_root / Path("Makefile")
def write(self, commands: EdaCommands, work_root: str | Path) -> None:
outfile = Path(work_root) / "Makefile"
with open(outfile, "w") as f:
f.write("#Auto generated by Edalize\n\n")
for v in commands.variables:
Expand Down
17 changes: 11 additions & 6 deletions edalize/design_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

from __future__ import annotations

import logging
import os.path
import platform
import re
import subprocess
from typing import Any

from edalize.edam import ToolDoc
from edalize.edatool import Edatool
from edalize.utils import get_file_type
from edalize.yosys import Yosys
Expand All @@ -30,7 +34,7 @@ class Design_compiler(Edatool):
argtypes = ["vlogdefine", "vlogparam", "generic"]

@classmethod
def get_doc(cls, api_ver):
def get_doc(cls, api_ver: int) -> ToolDoc | None:
if api_ver == 0:
return {
"description": "The design_compiler backend executes Synopsys design_copiler to build a gate-level netlist",
Expand Down Expand Up @@ -67,15 +71,16 @@ def get_doc(cls, api_ver):
},
],
}
return None

""" Configuration is the first phase of the build
This writes the project TCL files and Makefile. It first collects all
sources, IPs and constraints and then writes them to the TCL file along
with the build steps.
"""

def configure_main(self):
def make_list(opt):
def configure_main(self) -> None:
def make_list(opt: Any) -> Any:
if opt:
opt = (
((opt.replace("[", "")).replace("]", "")).replace(",", "")
Expand Down Expand Up @@ -134,7 +139,7 @@ def make_list(opt):
template_vars,
)

def src_file_filter(self, f):
def src_file_filter(self, f: Any) -> str:
file_types = {
"verilogSource": "analyze -format verilog",
"systemVerilogSource": "analyze -format sverilog",
Expand Down Expand Up @@ -171,10 +176,10 @@ def src_file_filter(self, f):
logger.warning(_s.format(f.name, f.file_type))
return "add_files -norecurse" + " " + f.name

def build_main(self):
def build_main(self, target: str | None = None) -> None:
logger.info("Building")
logger.info(
"(running make, which runs dc_shell which has an unbelievably long lag before printing. be patient)"
)
args = []
args: list[str] = []
self._run_tool("make", args, quiet=True)
15 changes: 10 additions & 5 deletions edalize/diamond.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

from __future__ import annotations

import logging
import os.path
import sys
from typing import Any

from edalize.edam import ToolDoc
from edalize.edatool import Edatool
from edalize.utils import get_file_type

Expand All @@ -16,7 +20,7 @@ class Diamond(Edatool):
argtypes = ["generic", "vlogdefine", "vlogparam"]

@classmethod
def get_doc(cls, api_ver):
def get_doc(cls, api_ver: int) -> ToolDoc | None:
if api_ver == 0:
return {
"description": "Backend for Lattice Diamond",
Expand All @@ -28,8 +32,9 @@ def get_doc(cls, api_ver):
},
],
}
return None

def configure_main(self):
def configure_main(self) -> None:
part = self.tool_options.get("part")
if not part:
raise RuntimeError("Missing required option 'part' for diamond backend")
Expand Down Expand Up @@ -115,7 +120,7 @@ def configure_main(self):
)
)

def src_file_filter(self, f):
def src_file_filter(self, f: Any) -> str:
def _vhdl_source(f):
s = "VHDL"
if f.logical_name:
Expand All @@ -139,7 +144,7 @@ def _vhdl_source(f):
logger.warning(_s.format(f.name, f.file_type))
return ""

def build_main(self):
def build_main(self, target: str | None = None) -> None:
if sys.platform == "win32":
tcl = "pnmainc"
else:
Expand All @@ -148,5 +153,5 @@ def build_main(self):
self._run_tool(tcl, [self.name + ".tcl"], quiet=True)
self._run_tool(tcl, [self.name + "_run.tcl"], quiet=True)

def run_main(self):
def run_main(self) -> None:
pass
Loading