Coverage for apio/commands/apio_report.py: 100%
19 statements
« prev ^ index » next coverage.py v7.16.1, created at 2026-09-23 03:53 +0000
« prev ^ index » next coverage.py v7.16.1, created at 2026-09-23 03:53 +0000
1# -*- coding: utf-8 -*-
2# -- This file is part of the Apio project
3# -- (C) 2016-2024 FPGAwars
4# -- Authors
5# -- * Jesús Arroyo (2016-2019)
6# -- * Juan Gonzalez (obijuan) (2019-2024)
7# -- License GPLv2
8"""Implementation of 'apio' report' command"""
10import sys
11from pathlib import Path
12import click
13from apio.managers.scons_manager import SConsManager
14from apio.commands import options
15from apio.apio_context import (
16 ApioContext,
17 PackagesPolicy,
18 ProjectPolicy,
19 RemoteConfigPolicy,
20)
21from apio.common.proto.apio_scons_pb2 import Verbosity
22from apio.utils import cmd_util
24# ---------- apio report
26# -- Text in the rich-text format of the python rich library.
27APIO_REPORT_HELP = """
28The command 'apio report' provides information on the utilization and timing \
29of the design. It is useful for analyzing utilization bottlenecks and \
30verifying that the design can operate at the desired clock speed.
32The '--verbose' option prints additional information such as as unused \
33resources and critical nets.
35Examples:[code]
36 apio report # Print report.
37 apio report --verbose # Print extra information.[/code]
38"""
41@click.command(
42 name="report",
43 cls=cmd_util.ApioCommand,
44 short_help="Report design utilization and timing.",
45 help=APIO_REPORT_HELP,
46)
47@click.pass_context
48@options.env_option_gen()
49@options.project_dir_option
50@options.verbose_option
51def cli(
52 _: click.Context,
53 *,
54 # Options
55 env: str | None,
56 project_dir: Path | None,
57 verbose: bool,
58):
59 """Analyze the design and report timing."""
61 # -- Create the apio context.
62 apio_ctx = ApioContext(
63 project_policy=ProjectPolicy.PROJECT_REQUIRED,
64 remote_config_policy=RemoteConfigPolicy.CACHED_OK,
65 packages_policy=PackagesPolicy.ENSURE_PACKAGES,
66 project_dir_arg=project_dir,
67 env_arg=env,
68 )
70 # -- Create the scons manager.
71 scons = SConsManager(apio_ctx)
73 # Run scons with the report target.
74 exit_code = scons.report(
75 verbosity=Verbosity(pnr=verbose),
76 )
78 # -- Done!
79 sys.exit(exit_code)