2026-02-13 11:19:09 +01:00
# Test power propagation, per-instance power breakdown, and activity querying.
source ../ ../ test/ helpers.tcl
2026-02-24 06:08:56 +01:00
suppress_msg 1140
2026-02-13 11:19:09 +01:00
# ---------------------------------------------------------------
# Test 1: Power with GCD design and VCD - comprehensive
# ---------------------------------------------------------------
puts " - - - T e s t 1 : G C D p o w e r w i t h V C D - - - "
read_liberty ../ ../ test/ sky130hd/ sky130_fd_sc_hd__tt_025C_1v80.lib
read_verilog ../ ../ examples/ gcd_sky130hd.v
link_design gcd
read_sdc ../ ../ examples/ gcd_sky130hd.sdc
# Read VCD to seed activities
read_vcd - scope gcd_tb/ gcd1 ../ ../ examples/ gcd_sky130hd.vcd.gz
# Report power - exercises full power calculation pipeline
report_power
# Report power with different digit counts
report_power - digits 2
report_power - digits 8
# ---------------------------------------------------------------
# Test 2: Instance-level power for specific cells
# Exercises: power(Instance) paths for various cell types
# ---------------------------------------------------------------
puts " - - - T e s t 2 : i n s t a n c e - l e v e l p o w e r - - - "
# Get all register instances
set regs [ all_registers - cells]
set reg_count [ llength $regs ]
puts " r e g i s t e r c e l l s : $ r e g _ c o u n t "
if { $reg_count > 0 } {
report_power - instances [ lrange $regs 0 2 ]
}
# Get combinational cells
set all_cells [ get_cells * ]
set combo_cells [ list ]
foreach cell $all_cells {
set cell_ref [ get_property $cell ref_name]
if { [ string match " * b u f * " $cell_ref ] || [ string match " * i n v * " $cell_ref ] || [ string match " * n a n d * " $cell_ref ] || [ string match " * n o r * " $cell_ref ] || [ string match " * a n d * " $cell_ref ] || [ string match " * o r * " $cell_ref ] } {
lappend combo_cells $cell
if { [ llength $combo_cells ] >= 5 } { break }
}
}
if { [ llength $combo_cells ] > 0 } {
report_power - instances $combo_cells
report_power - instances $combo_cells - format json
report_power - instances $combo_cells - digits 6
}
# ---------------------------------------------------------------
# Test 3: Highest power instances
# Exercises: highestPowerInstances sorting
# ---------------------------------------------------------------
puts " - - - T e s t 3 : h i g h e s t p o w e r i n s t a n c e s - - - "
2026-02-23 15:05:29 +01:00
# TODO: report_power -highest_power_instances broken (highest_power_instances SWIG fn removed)
sta : : report_power_highest_insts 3 [ sta : : cmd_scene] $sta_report_default_digits
2026-02-13 11:19:09 +01:00
2026-02-23 15:05:29 +01:00
sta : : report_power_highest_insts 10 [ sta : : cmd_scene] $sta_report_default_digits
2026-02-13 11:19:09 +01:00
2026-02-23 15:05:29 +01:00
# JSON format not available via report_power_highest_insts - skip
puts " h i g h e s t _ p o w e r _ i n s t a n c e s j s o n : s k i p p e d ( A P I r e m o v e d ) "
2026-02-13 11:19:09 +01:00
2026-02-23 15:05:29 +01:00
sta : : report_power_highest_insts 3 [ sta : : cmd_scene] 6
2026-02-13 11:19:09 +01:00
# ---------------------------------------------------------------
# Test 4: Activity annotation report
# Exercises: reportActivityAnnotation paths
# ---------------------------------------------------------------
puts " - - - T e s t 4 : a c t i v i t y a n n o t a t i o n - - - "
report_activity_annotation
report_activity_annotation - report_annotated
report_activity_annotation - report_unannotated
# ---------------------------------------------------------------
# Test 5: Override VCD activities with manual settings
# Exercises: setGlobalActivity, setInputActivity, setUserActivity paths
# ---------------------------------------------------------------
puts " - - - T e s t 5 : a c t i v i t y o v e r r i d e s - - - "
# Set global activity - overrides VCD
set_power_activity - global - activity 0.5 - duty 0.5
report_power
# Unset global
unset_power_activity - global
# Set input activity
set_power_activity - input - activity 0.3 - duty 0.4
report_power
unset_power_activity - input
# Set per-port activity
set_power_activity - input_ports [ get_ports req_msg[ 0 ] ] - activity 0.8 - duty 0.5
report_power
unset_power_activity - input_ports [ get_ports req_msg[ 0 ] ]
# Set per-pin activity
2026-02-19 15:30:23 +01:00
set clk_pins [ get_pins * / CLK]
if { [ llength $clk_pins ] > 0 } {
set first_clk [ lindex $clk_pins 0 ]
set_power_activity - pins $first_clk - activity 1.0 - duty 0.5
report_power
unset_power_activity - pins $first_clk
}
2026-02-13 11:19:09 +01:00
# Set density-based activity
set_power_activity - global - density 5 e8 - duty 0.5
report_power
unset_power_activity - global
# ---------------------------------------------------------------
# Test 6: SAIF-based power (different activity source)
# Exercises: readSaif path, SAIF annotation
# ---------------------------------------------------------------
puts " - - - T e s t 6 : S A I F p o w e r - - - "
# Re-read design
read_liberty ../ ../ test/ sky130hd/ sky130_fd_sc_hd__tt_025C_1v80.lib
read_verilog ../ ../ examples/ gcd_sky130hd.v
link_design gcd
read_sdc ../ ../ examples/ gcd_sky130hd.sdc
read_saif - scope gcd_tb/ gcd1 ../ ../ examples/ gcd_sky130hd.saif.gz
report_power
2026-02-23 15:05:29 +01:00
# TODO: report_power -highest_power_instances broken (highest_power_instances SWIG fn removed)
sta : : report_power_highest_insts 5 [ sta : : cmd_scene] $sta_report_default_digits
2026-02-13 11:19:09 +01:00
report_activity_annotation
# ---------------------------------------------------------------
# Test 7: Power with no activity data (default propagation)
# Exercises: ensureActivities default input activity paths
# ---------------------------------------------------------------
puts " - - - T e s t 7 : p o w e r w i t h d e f a u l t s - - - "
read_liberty ../ ../ test/ sky130hd/ sky130_fd_sc_hd__tt_025C_1v80.lib
read_verilog ../ ../ examples/ gcd_sky130hd.v
link_design gcd
read_sdc ../ ../ examples/ gcd_sky130hd.sdc
# No VCD or SAIF - relies on default activity propagation
report_power
report_power - format json
report_activity_annotation