Skip to content

Commit

Permalink
Merge pull request #528 from zapta/develop
Browse files Browse the repository at this point in the history
Assorted changes.
  • Loading branch information
cavearr authored Jan 10, 2025
2 parents 1bb5828 + 4f02dae commit 54bbe92
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 30 deletions.
29 changes: 29 additions & 0 deletions apio/managers/scons_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ def classify_line(self, pipe_id: PipeId, line: str) -> RangeEvents:
return None


class IVerilogRangeDetector(RangeDetector):
"""Implements a RangeDetector for the iverolog command output."""

def classify_line(self, pipe_id: PipeId, line: str) -> RangeEvents:
# -- Range start: an iverolog command on stdout.
if pipe_id == PipeId.STDOUT and line.startswith("iverilog"):
return RangeEvents.START_AFTER

# Range end: The end message of nextnpr.
if pipe_id == PipeId.STDOUT and line.startswith("gtkwave"):
return RangeEvents.END_BEFORE

return None


class IceProgRangeDetector(RangeDetector):
"""Implements a RangeDetector for the iceprog command output."""

Expand Down Expand Up @@ -142,6 +157,7 @@ class SconsFilter:
def __init__(self, colors_enabled: bool):
self.colors_enabled = colors_enabled
self._pnr_detector = PnrRangeDetector()
self._iverilog_detector = IVerilogRangeDetector()
self._iceprog_detector = IceProgRangeDetector()

def on_stdout_line(self, line: str) -> None:
Expand Down Expand Up @@ -190,6 +206,7 @@ def _assign_line_color(
return color
return default_color

# pylint: disable=too-many-return-statements
def on_line(self, pipe_id: PipeId, line: str) -> None:
"""A shared handler for stdout/err lines from the scons sub process.
The handler writes both stdout and stderr lines to stdout, possibly
Expand All @@ -204,6 +221,7 @@ def on_line(self, pipe_id: PipeId, line: str) -> None:

# -- Update the range detectors.
in_pnr_verbose_range = self._pnr_detector.update(pipe_id, line)
in_iverolog_range = self._iverilog_detector.update(pipe_id, line)
in_iceprog_range = self._iceprog_detector.update(pipe_id, line)

# -- Handle the line while in the nextpnr verbose log range.
Expand All @@ -225,6 +243,17 @@ def on_line(self, pipe_id: PipeId, line: str) -> None:
self.emit_line(line, fg=line_color)
return

# -- Special handling of iverilog lines. We drop warning line spam
# -- per Per https://github.com/FPGAwars/apio/issues/530
if (
in_iverolog_range
and pipe_id == PipeId.STDERR
and "cells_sim.v" in line
and "Timing checks are not supported" in line
):
# -- Drop the line.
return

# -- Special handling for iceprog line range.
if pipe_id == PipeId.STDERR and in_iceprog_range:
# -- Iceprog prints blank likes that are used as line erasers.
Expand Down
2 changes: 1 addition & 1 deletion apio/resources/distribution.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"remote-config": "https://github.com/zapta/apio_dev/raw/develop/remote-config/apio-%V.json",
"remote-config": "https://github.com/FPGAwars/apio/raw/develop/remote-config/apio-%V.json",

"pip_packages": {
"blackiceprog": ">=2.0.0,<3.0.0",
Expand Down
4 changes: 3 additions & 1 deletion apio/scons/plugin_ecp5.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, apio_env: ApioEnv):
apio_env.args.TRELLIS_PATH, "database"
)
self.yosys_lib_dir = apio_env.args.YOSYS_PATH + "/ecp5"
self.constrain_file_extension = ".lpf"
self.yosys_lib_file = self.yosys_lib_dir + "/cells_sim.v"

def plugin_info(self) -> ArchPluginInfo:
"""Return plugin specific parameters."""
Expand Down Expand Up @@ -145,6 +145,7 @@ def action_generator(source, target, env, for_signature):
vcd_output_name=testbench_name,
is_interactive=apio_env.targeting("sim"),
lib_dirs=[self.yosys_lib_dir],
lib_files=[self.yosys_lib_file],
),
]
return action
Expand Down Expand Up @@ -189,6 +190,7 @@ def lint_builder(self) -> BuilderBase:
warns=args.VERILATOR_WARNS,
top_module=args.TOP_MODULE,
lib_dirs=[self.yosys_lib_dir],
lib_files=[self.yosys_lib_file],
),
src_suffix=SRC_SUFFIXES,
source_scanner=self.verilog_src_scanner,
Expand Down
3 changes: 3 additions & 0 deletions apio/scons/plugin_gowin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, apio_env: ApioEnv):

# -- Cache values.
self.yosys_lib_dir = apio_env.args.YOSYS_PATH + "/gowin"
self.yosys_lib_file = self.yosys_lib_dir + "/cells_sim.v"

def plugin_info(self) -> ArchPluginInfo:
"""Return plugin specific parameters."""
Expand Down Expand Up @@ -137,6 +138,7 @@ def action_generator(source, target, env, for_signature):
vcd_output_name=testbench_name,
is_interactive=apio_env.targeting("sim"),
lib_dirs=[self.yosys_lib_dir],
lib_files=[self.yosys_lib_file],
),
]
return action
Expand Down Expand Up @@ -177,6 +179,7 @@ def lint_builder(self) -> BuilderBase:
warns=args.VERILATOR_WARNS,
top_module=args.TOP_MODULE,
lib_dirs=[self.yosys_lib_dir],
lib_files=[self.yosys_lib_file],
),
src_suffix=SRC_SUFFIXES,
source_scanner=self.verilog_src_scanner,
Expand Down
2 changes: 2 additions & 0 deletions apio/scons/plugin_ice40.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def action_generator(source, target, env, for_signature):
vcd_output_name=testbench_name,
is_interactive=apio_env.targeting("sim"),
extra_params=["-DNO_ICE40_DEFAULT_ASSIGNMENTS"],
lib_dirs=[self.yosys_lib_dir],
lib_files=[self.yosys_lib_file],
),
]
Expand Down Expand Up @@ -174,6 +175,7 @@ def lint_builder(self) -> BuilderBase:
warns=args.VERILATOR_WARNS,
top_module=args.TOP_MODULE,
extra_params=["-DNO_ICE40_DEFAULT_ASSIGNMENTS"],
lib_dirs=[self.yosys_lib_dir],
lib_files=[self.yosys_lib_file],
),
src_suffix=SRC_SUFFIXES,
Expand Down
14 changes: 7 additions & 7 deletions apio/scons/plugin_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,25 +621,25 @@ def programmer_cmd(apio_env: ApioEnv) -> str:
arg."""

# Get the programer command template arg.
prog_arg = apio_env.args.PROG
command = apio_env.args.PROG

# If empty then return as is. This must be an apio command that
# doesn't use the programmer.
if not prog_arg:
return prog_arg
if not command:
return command

# It's an error if the programmer command doesn't have the $SOURCE
# placeholder when scons inserts the binary file name.
if "$SOURCE" not in prog_arg:
if "$SOURCE" not in command:
secho(
"Error: [Internal] 'prog' argument does not contain "
f"the '$SOURCE' marker. [{prog_arg}]",
"Error: [Internal] $SOURCE is missing in programmer command: "
f"{command}",
fg="red",
color=True,
)
sys.exit(1)

return prog_arg
return command


# pylint: disable=too-many-arguments
Expand Down
20 changes: 0 additions & 20 deletions scons_run.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/scons/test_plugin_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def test_get_programmer_cmd(capsys: LogCaptureFixture):
programmer_cmd(apio_env)
captured = capsys.readouterr()
assert e.value.code == 1
assert "does not contain the '$SOURCE'" in captured.out
assert "$SOURCE is missing" in captured.out


def test_map_params():
Expand Down

0 comments on commit 54bbe92

Please sign in to comment.