Coverage for apio/commands/apio_report.py: 100%
21 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-09 01:55 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-09 01:55 +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 typing import Optional
12from pathlib import Path
13import click
14from apio.managers.scons_manager import SConsManager
15from apio.commands import options
16from apio.apio_context import (
17 ApioContext,
18 PackagesPolicy,
19 ProjectPolicy,
20 RemoteConfigPolicy,
21)
22from apio.common.proto.apio_pb2 import Verbosity, ReportParams
23from apio.utils import cmd_util
25# ---------- apio report
27# -- Text in the rich-text format of the python rich library.
28APIO_REPORT_HELP = """
29The command 'apio report' provides information on the utilization and timing \
30of the design. It is useful for analyzing utilization bottlenecks and \
31verifying that the design can operate at the desired clock speed.
33By default, the command reports only the used resources. To also include \
34unused resources, use the '--all' option. The '--verbose' option prints \
35additional information and implies '--all'.
37Examples:[code]
38 apio report # Print report.
39 apio report --all # Report also unused resources.
40 apio report --verbose # Print extra information.[/code]
41"""
44@click.command(
45 name="report",
46 cls=cmd_util.ApioCommand,
47 short_help="Report design utilization and timing.",
48 help=APIO_REPORT_HELP,
49)
50@click.pass_context
51@options.all_option_gen(short_help="Show also unused resources.")
52@options.env_option_gen()
53@options.project_dir_option
54@options.verbose_option
55def cli(
56 _: click.Context,
57 *,
58 # Options
59 all_: bool,
60 env: Optional[str],
61 project_dir: Optional[Path],
62 verbose: bool,
63):
64 """Analyze the design and report timing."""
66 # -- Create the apio context.
67 apio_ctx = ApioContext(
68 project_policy=ProjectPolicy.PROJECT_REQUIRED,
69 remote_config_policy=RemoteConfigPolicy.CACHED_OK,
70 packages_policy=PackagesPolicy.ENSURE_PACKAGES,
71 project_dir_arg=project_dir,
72 env_arg=env,
73 )
75 # -- Create the scons manager.
76 scons = SConsManager(apio_ctx)
78 # Run scons with the report target.
79 exit_code = scons.report(
80 report_params=ReportParams(report_all=(all_ or verbose)),
81 verbosity=Verbosity(pnr=verbose),
82 )
84 # -- Done!
85 sys.exit(exit_code)