Skip to content

[Power] Refine power estimation flow and add power evaluation flow #718

Open
qianxu1998 wants to merge 24 commits intoEPFL-LAP:mainfrom
qianxu1998:power_analysis
Open

[Power] Refine power estimation flow and add power evaluation flow #718
qianxu1998 wants to merge 24 commits intoEPFL-LAP:mainfrom
qianxu1998:power_analysis

Conversation

@qianxu1998
Copy link
Collaborator

@qianxu1998 qianxu1998 commented Jan 27, 2026

Summary

  • Move and expand the estimate-power flow into tools/dynamatic/power, add Verilog support, stage selection (pre/post), and optional post-synthesis netlist generation for higher-accuracy SAIF generation.
  • Add a new evaluate-power flow (frontend command + Python + TCL template) that builds and optionally runs a Vivado XSim-based power evaluation script; supports synth/impl stages and optional hierarchy flattening. For now this is Verilog-only, and produces both functional and timing power reports per stage.
  • Plumb the configured clock period into the simulation/testbench path so timing simulation and SAIF generation use the correct clock period.

Script details

  • tools/dynamatic/power/estimate_power.py
    • Args: --output_dir, --kernel_name, --hdl (vhdl|verilog), --synth (pre|post), --cp, --vivado_cmd
    • Behavior: generates period.xdc, Modelsim .do, optional pre-synth via Vivado, then report_power.tcl using SAIF from simulation.
  • tools/dynamatic/power/power_eval.py
    • Args: --output_dir, --kernel_name, --hdl (verilog|verilog-beta|vhdl), --stage (synth|impl), --flatten_hierarchy, --cp, --vivado_cmd, --no-run
    • Behavior: emits power_extraction.tcl to run XSim, dump SAIF/VCD, and generate power reports; runs Vivado unless --no-run is set.

Usage (Dynamatic Frontend)

# estimate-power
estimate-power --hdl verilog --synth pre

# evaluate-power (Verilog backend only)
evaluate-power --hdl verilog --stage impl --flatten-hierarchy 1

@qianxu1998 qianxu1998 requested a review from murphe67 January 27, 2026 23:12
set SAIF_OUT %saif_pre

# =============================================================
# 1. Create an in-memory project
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in-memory? comment outdated, or something I don't understand?

]

# Constraints (not required for behavioral sim, but harmless if you want periods/IO constraints loaded)
if {[file exists $XDC_FILE]} {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we throw an error if the xdc file doesnt exist? the dict structure enforces that we pass an xdc file right? so if we have a typo in the name, should we tell the user?

add_files -fileset sim_1 [list \
%{sim_sources}
]
set_property top $TB_TOP [get_filesets sim_1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dumb q from me: set_property applies separately to sources_1 and sim_1? we are not overriding the previous set_top from line 43?

maybe a comment would help for someone learning about power estimation from this script

#
# Get all the simulation hdl input files
# As a list of imports for the simulation.do
sim_hdl_inputs = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a comment about what the vhdl files we want are when hdl is verilog?

sim_inputs = "\n".join(sim_inputs)

# Get all the input VHDl files
if hdl != "verilog":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mild recommendation:

if hdl == "verilog":
elseif hdl == "vhdl":
else
throw error

had a lot of bugs in my code from stuff like this from python

for f in sorted(os.listdir(vhdl_src_folder))
if f.endswith(".vhd")
)
if hdl == "verilog":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same mild recc here of error on unrecognized hdl

Comment on lines +81 to +83
# Normalize HDL selection
# For now, verilog-beta is treated as verilog
hdl = _normalize_hdl(hdl)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add print or throw error? seem risky to do quietly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants