Coverage for pyEDAA/OutputFilter/Xilinx/OptimizeDesign.py: 100%

129 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-07-20 22:02 +0000

1# ==================================================================================================================== # 

2# _____ ____ _ _ ___ _ _ _____ _ _ _ # 

3# _ __ _ _| ____| _ \ / \ / \ / _ \ _ _| |_ _ __ _ _| |_| ___(_) | |_ ___ _ __ # 

4# | '_ \| | | | _| | | | |/ _ \ / _ \ | | | | | | | __| '_ \| | | | __| |_ | | | __/ _ \ '__| # 

5# | |_) | |_| | |___| |_| / ___ \ / ___ \ | |_| | |_| | |_| |_) | |_| | |_| _| | | | || __/ | # 

6# | .__/ \__, |_____|____/_/ \_\/_/ \_(_)___/ \__,_|\__| .__/ \__,_|\__|_| |_|_|\__\___|_| # 

7# |_| |___/ |_| # 

8# ==================================================================================================================== # 

9# Authors: # 

10# Patrick Lehmann # 

11# # 

12# License: # 

13# ==================================================================================================================== # 

14# Copyright 2025-2026 Electronic Design Automation Abstraction (EDA²) # 

15# # 

16# Licensed under the Apache License, Version 2.0 (the "License"); # 

17# you may not use this file except in compliance with the License. # 

18# You may obtain a copy of the License at # 

19# # 

20# http://www.apache.org/licenses/LICENSE-2.0 # 

21# # 

22# Unless required by applicable law or agreed to in writing, software # 

23# distributed under the License is distributed on an "AS IS" BASIS, # 

24# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

25# See the License for the specific language governing permissions and # 

26# limitations under the License. # 

27# # 

28# SPDX-License-Identifier: Apache-2.0 # 

29# ==================================================================================================================== # 

30# 

31"""A filtering anc classification processor for AMD/Xilinx Vivado Synthesis outputs.""" 

32from re import compile, Pattern 

33from typing import ClassVar, Type, Tuple 

34 

35from pyTooling.Decorators import export 

36 

37from pyEDAA.OutputFilter.Xilinx import Task, TaskWithPhases, TaskWithSubTasks, SubTask 

38from pyEDAA.OutputFilter.Xilinx import Phase, SubPhase, PhaseWithChildren 

39from pyEDAA.OutputFilter.Xilinx import MAJOR, MAJOR_MINOR 

40 

41 

42@export 

43class Phase_Retarget(Phase): 

44 """ 

45 *Retarget* phase. 

46 

47 Used by task :class:`LogicOptimizationTask`. 

48 """ 

49 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR} Retarget") 

50 _FINISH: ClassVar[str] = "Phase {phaseIndex} Retarget | Checksum:" 

51 _TIME: ClassVar[str] = "Time (s):" 

52 _FINAL: ClassVar[str] = "Retarget | Checksum:" 

53 

54 

55@export 

56class SubPhase_CoreGenerationAndDesignSetup(SubPhase): 

57 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR_MINOR} Core Generation And Design Setup") 

58 _FINISH: ClassVar[str] = "Phase {phaseIndex}.{subPhaseIndex} Core Generation And Design Setup | Checksum:" 

59 _TIME: ClassVar[str] = "Time (s):" 

60 

61 

62@export 

63class SubPhase_SetupConstraintsAndSortNetlist(SubPhase): 

64 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR_MINOR} Setup Constraints And Sort Netlist") 

65 _FINISH: ClassVar[str] = "Phase {phaseIndex}.{subPhaseIndex} Setup Constraints And Sort Netlist | Checksum:" 

66 _TIME: ClassVar[str] = "Time (s):" 

67 

68 

69@export 

70class Phase_Initialization(PhaseWithChildren): 

71 """ 

72 *Initialization* phase. 

73 

74 Used by task :class:`LogicOptimizationTask`. 

75 """ 

76 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR} Initialization") 

77 _FINISH: ClassVar[str] = "Phase {phaseIndex} Initialization | Checksum:" 

78 _TIME: ClassVar[str] = "Time (s):" 

79 _FINAL: ClassVar[str] = None 

80 

81 _PARSERS: ClassVar[Tuple[Type[SubPhase], ...]] = ( 

82 SubPhase_CoreGenerationAndDesignSetup, 

83 SubPhase_SetupConstraintsAndSortNetlist 

84 ) 

85 

86 

87@export 

88class Phase_ConstantPropagation(Phase): 

89 """ 

90 *Constant propagation* phase. 

91 

92 Used by task :class:`LogicOptimizationTask`. 

93 """ 

94 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR} Constant propagation") 

95 _FINISH: ClassVar[str] = "Phase {phaseIndex} Constant propagation | Checksum:" 

96 _TIME: ClassVar[str] = "Time (s):" 

97 _FINAL: ClassVar[str] = "Constant propagation | Checksum:" 

98 

99 

100@export 

101class SubPhase_DetectIfminReqCacheNeeded(SubPhase): 

102 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR_MINOR} Detect if minReqCache needed") 

103 _FINISH: ClassVar[str] = "Phase {phaseIndex}.{subPhaseIndex} Detect if minReqCache needed | Checksum:" 

104 _TIME: ClassVar[str] = "Time (s):" 

105 

106 

107@export 

108class SubPhase_TimerUpdate(SubPhase): 

109 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR_MINOR} Timer Update") 

110 _FINISH: ClassVar[str] = "Phase {phaseIndex}.{subPhaseIndex} Timer Update | Checksum:" 

111 _TIME: ClassVar[str] = "Time (s):" 

112 

113 

114@export 

115class SubPhase_TimingDataCollection(SubPhase): 

116 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR_MINOR} Timing Data Collection") 

117 _FINISH: ClassVar[str] = "Phase {phaseIndex}.{subPhaseIndex} Timing Data Collection | Checksum:" 

118 _TIME: ClassVar[str] = "Time (s):" 

119 

120 

121@export 

122class Phase_TimerUpdateAndTimingDataCollection(PhaseWithChildren): 

123 """ 

124 *Timer Update And Timing Data Collection* phase. 

125 

126 Used by task :class:`LogicOptimizationTask`. 

127 """ 

128 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR} Timer Update And Timing Data Collection") 

129 _FINISH: ClassVar[str] = "Phase {phaseIndex} Timer Update And Timing Data Collection | Checksum:" 

130 _TIME: ClassVar[str] = "Time (s):" 

131 _FINAL: ClassVar[str] = None 

132 

133 _PARSERS: ClassVar[Tuple[Type[SubPhase], ...]] = ( 

134 SubPhase_DetectIfminReqCacheNeeded, 

135 SubPhase_TimerUpdate, 

136 SubPhase_TimingDataCollection 

137 ) 

138 

139 

140@export 

141class Phase_Sweep(Phase): 

142 """ 

143 *Sweep* phase. 

144 

145 Used by task :class:`LogicOptimizationTask`. 

146 """ 

147 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR} Sweep") 

148 _FINISH: ClassVar[str] = "Phase {phaseIndex} Sweep | Checksum:" 

149 _TIME: ClassVar[str] = "Time (s):" 

150 _FINAL: ClassVar[str] = "Sweep | Checksum:" 

151 

152 

153@export 

154class Phase_BUFGOptimization(Phase): 

155 """ 

156 *BUFG optimization* phase. 

157 

158 Used by task :class:`LogicOptimizationTask`. 

159 """ 

160 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR} BUFG optimization") 

161 _FINISH: ClassVar[str] = "Phase {phaseIndex} BUFG optimization | Checksum:" 

162 _TIME: ClassVar[str] = "Time (s):" 

163 _FINAL: ClassVar[str] = "BUFG optimization | Checksum:" 

164 

165 

166@export 

167class Phase_ShiftRegisterOptimization(Phase): 

168 """ 

169 *Shift Register Optimization* phase. 

170 

171 Used by task :class:`LogicOptimizationTask`. 

172 """ 

173 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR} Shift Register Optimization") 

174 _FINISH: ClassVar[str] = "Phase {phaseIndex} Shift Register Optimization | Checksum:" 

175 _TIME: ClassVar[str] = "Time (s):" 

176 _FINAL: ClassVar[str] = "Shift Register Optimization | Checksum:" 

177 

178 

179@export 

180class Phase_PostProcessingNetlist(Phase): 

181 """ 

182 *Post Processing Netlist* phase. 

183 

184 Used by task :class:`LogicOptimizationTask`. 

185 """ 

186 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR} Post Processing Netlist") 

187 _FINISH: ClassVar[str] = "Phase {phaseIndex} Post Processing Netlist | Checksum:" 

188 _TIME: ClassVar[str] = "Time (s):" 

189 _FINAL: ClassVar[str] = "Post Processing Netlist | Checksum:" 

190 

191 

192@export 

193class SubPhase_FinalizingDesignCoresAndUpdatingShapes(SubPhase): 

194 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR_MINOR} Finalizing Design Cores and Updating Shapes") 

195 _FINISH: ClassVar[str] = "Phase {phaseIndex}.{subPhaseIndex} Finalizing Design Cores and Updating Shapes | Checksum:" 

196 _TIME: ClassVar[str] = "Time (s):" 

197 

198 

199@export 

200class SubPhase_VerifyingNetlistConnectivity(SubPhase): 

201 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR_MINOR} Verifying Netlist Connectivity") 

202 _FINISH: ClassVar[str] = "Phase {phaseIndex}.{subPhaseIndex} Verifying Netlist Connectivity | Checksum:" 

203 _TIME: ClassVar[str] = "Time (s):" 

204 

205 

206@export 

207class Phase_Finalization(PhaseWithChildren): 

208 """ 

209 *Finalization* phase. 

210 

211 Used by task :class:`LogicOptimizationTask`. 

212 """ 

213 _START: ClassVar[Pattern] = compile(f"^Phase {MAJOR} Finalization") 

214 _FINISH: ClassVar[str] = "Phase {phaseIndex} Finalization | Checksum:" 

215 _TIME: ClassVar[str] = "Time (s):" 

216 _FINAL: ClassVar[str] = None 

217 

218 _PARSERS: ClassVar[Tuple[Type[SubPhase], ...]] = ( 

219 SubPhase_FinalizingDesignCoresAndUpdatingShapes, 

220 SubPhase_VerifyingNetlistConnectivity 

221 ) 

222 

223 

224@export 

225class DRCTask(Task): 

226 _START: ClassVar[str] = "Starting DRC Task" 

227 _FINISH: ClassVar[str] = "Time (s):" 

228 

229 

230@export 

231class CacheTimingInformationTask(Task): 

232 _START: ClassVar[str] = "Starting Cache Timing Information Task" 

233 _FINISH: ClassVar[str] = "Ending Cache Timing Information Task" 

234 

235 

236@export 

237class LogicOptimizationTask(TaskWithPhases): 

238 """ 

239 *Logic Optimization* task. 

240 

241 Used by Vivado command :class:`~pyEDAA.OutputFilter.Xilinx.Commands.OptimizeDesign`. 

242 """ 

243 _START: ClassVar[str] = "Starting Logic Optimization Task" 

244 _FINISH: ClassVar[str] = "Ending Logic Optimization Task" 

245 

246 _PARSERS: ClassVar[Tuple[Type[Phase], ...]] = ( 

247 Phase_Initialization, 

248 Phase_TimerUpdateAndTimingDataCollection, 

249 Phase_Retarget, 

250 Phase_ConstantPropagation, 

251 Phase_Sweep, 

252 Phase_BUFGOptimization, 

253 Phase_ShiftRegisterOptimization, 

254 Phase_PostProcessingNetlist, 

255 Phase_Finalization 

256 ) 

257 

258 

259@export 

260class PowerOptPatchEnablesTask(SubTask): 

261 _START: ClassVar[str] = "Starting PowerOpt Patch Enables Task" 

262 _FINISH: ClassVar[str] = "Ending PowerOpt Patch Enables Task" 

263 

264 

265@export 

266class PowerOptimizationTask(TaskWithSubTasks): 

267 _START: ClassVar[str] = "Starting Power Optimization Task" 

268 _FINISH: ClassVar[str] = "Ending Power Optimization Task" 

269 

270 _PARSERS: ClassVar[Tuple[Type[SubTask], ...]] = ( 

271 PowerOptPatchEnablesTask, 

272 ) 

273 

274 

275@export 

276class FinalCleanupTask(TaskWithSubTasks): 

277 _START: ClassVar[str] = "Starting Final Cleanup Task" 

278 _FINISH: ClassVar[str] = "Ending Final Cleanup Task" 

279 

280 _PARSERS: ClassVar[Tuple[Type[SubTask], ...]] = ( 

281 LogicOptimizationTask, 

282 ) 

283 

284 

285@export 

286class NetlistObfuscationTask(Task): 

287 _START: ClassVar[str] = "Starting Netlist Obfuscation Task" 

288 _FINISH: ClassVar[str] = "Ending Netlist Obfuscation Task"