Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# -------------------------------------------------------------------------------------------------- 

2# Copyright (c) Lukas Vik. All rights reserved. 

3# 

4# This file is part of the tsfpga project. 

5# https://tsfpga.com 

6# https://gitlab.com/tsfpga/tsfpga 

7# -------------------------------------------------------------------------------------------------- 

8 

9import json 

10 

11from .logic_level_distribution_parser import LogicLevelDistributionParser 

12 

13 

14class BuildResult: 

15 

16 """ 

17 Attributes: 

18 project_name (`str`): The name of the build. 

19 success (`bool`): True if the build and all pre- and post hooks succeeded. 

20 synthesis_size (`dict`): A dictionary with the utilization of primitives for the 

21 synthesized design. Will be ``None`` if synthesis failed or did not run. 

22 implementation_size (`dict`): A dictionary with the utilization of primitives for 

23 the implemented design. Will be ``None`` if implementation failed or did not run. 

24 maximum_logic_level (int): The maximum level in the the logic level distribution. 

25 Will be ``None`` if synthesis failed or did not run. 

26 """ 

27 

28 def __init__(self, name): 

29 """ 

30 Arguments: 

31 name (`str`): The name of the build. 

32 """ 

33 self.name = name 

34 self.success = True 

35 self.synthesis_size = None 

36 self.implementation_size = None 

37 self._logic_level_distribution = None 

38 self.maximum_logic_level = None 

39 

40 def size_summary(self): 

41 """ 

42 Return a string with a formatted message of the size. 

43 

44 Returns: 

45 str: A human-readable message of the latest size. ``None`` if no size is set. 

46 """ 

47 build_step = None 

48 size = None 

49 

50 if self.implementation_size is not None: 

51 build_step = "implementation" 

52 size = self.implementation_size 

53 elif self.synthesis_size is not None: 

54 build_step = "synthesis" 

55 size = self.synthesis_size 

56 else: 

57 return None 

58 

59 return f"Size of {self.name} after {build_step}:\n{json.dumps(size, indent=2)}" 

60 

61 def report(self): 

62 """ 

63 Return a report of the build result. Includes all metrics and information that has been 

64 extracted from the Vivado reports. 

65 

66 Returns: 

67 str: The report. 

68 """ 

69 result = self.size_summary() 

70 

71 if self.logic_level_distribution is not None: 

72 result = f"{result}\nLogic level distribution:\n{self.logic_level_distribution}" 

73 

74 return result 

75 

76 @property 

77 def logic_level_distribution(self): 

78 """ 

79 str: A table with logic level distribution as reported by Vivado. 

80 Will be ``None`` if synthesis failed or did not run. 

81 """ 

82 # Getter for logic_level_distribution. 

83 return self._logic_level_distribution 

84 

85 @logic_level_distribution.setter 

86 def logic_level_distribution(self, value): 

87 """ 

88 Setter for logic_level_distribution that also sets the calculated maximum logic level. 

89 """ 

90 self._logic_level_distribution = value 

91 self.maximum_logic_level = LogicLevelDistributionParser.get_maximum_logic_level(value)