Coverage for tsfpga/vivado/test/test_build_result.py: 100%
24 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-01 20:51 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-01 20:51 +0000
1# --------------------------------------------------------------------------------------------------
2# Copyright (c) Lukas Vik. All rights reserved.
3#
4# This file is part of the tsfpga project, a project platform for modern FPGA development.
5# https://tsfpga.com
6# https://github.com/tsfpga/tsfpga
7# --------------------------------------------------------------------------------------------------
9from tsfpga.vivado.build_result import BuildResult
12def test_size_summary():
13 build_result = BuildResult(name="apa")
15 build_result.synthesis_size = {"LUT": 3, "FFs": 4}
16 expected = """\
17Size of apa after synthesis:
18{
19 "LUT": 3,
20 "FFs": 4
21}"""
22 assert build_result.size_summary() == expected
24 build_result.implementation_size = {"LUT": 8, "FFs": 9}
25 expected = """\
26Size of apa after implementation:
27{
28 "LUT": 8,
29 "FFs": 9
30}"""
31 assert build_result.size_summary() == expected
34def test_report():
35 build_result = BuildResult(name="apa")
37 build_result.synthesis_size = {"LUT": 3, "FFs": 4}
38 expected = """\
39Size of apa after synthesis:
40{
41 "LUT": 3,
42 "FFs": 4
43}"""
44 assert build_result.report() == expected
46 # Add a logic level distribution report
47 build_result.logic_level_distribution = """\
48+-----------------+-------------+-----+----+---+----+
49| End Point Clock | Requirement | 0 | 1 | 2 | 3 |
50+-----------------+-------------+-----+----+---+----+
51| clk_fpga_0 | 2.000ns | 491 | 12 | 1 | 11 |
52+-----------------+-------------+-----+----+---+----+\
53"""
54 expected = """\
55Size of apa after synthesis:
56{
57 "LUT": 3,
58 "FFs": 4
59}
60Logic level distribution:
61+-----------------+-------------+-----+----+---+----+
62| End Point Clock | Requirement | 0 | 1 | 2 | 3 |
63+-----------------+-------------+-----+----+---+----+
64| clk_fpga_0 | 2.000ns | 491 | 12 | 1 | 11 |
65+-----------------+-------------+-----+----+---+----+\
66"""
67 assert build_result.report() == expected
68 assert build_result.maximum_logic_level == 3
71def test_maximum_logic_level_should_be_none_if_no_logic_level_distribution_is_set():
72 build_result = BuildResult(name="apa")
73 build_result.synthesis_size = {"LUT": 3, "FFs": 4}
75 # maximum_logic_level is calculated based on the logic_level_distribution, which is not set
76 # in this test case
77 assert build_result.logic_level_distribution is None
78 assert build_result.maximum_logic_level is None
79 assert "level" not in build_result.report()