使用PrimeTime PX進行功耗分析有兩種:一種是平均功耗的分析Averaged power analysis,一種是Time-based power analysis。
電路的功耗主要有兩種,一種是漏電流功耗(Leakage Power),也就是一個單元在沒有switching,inactive或者static情況下的功耗,包括intrinsic leakage power和gate leakage power。
其中intrinsic leakage power主要是由source-to-drain的漏電流引起,也包括擴散區diffusion layer和基底substrate之間的電流泄露。
Gate leakage power是由source-to-gate和gate-to-drain的漏電流引起,隨着工藝尺寸的降低diminish,它已經成為主要的漏電流功耗來源。Gate leakage power主要依賴於gate oxide的厚度和電壓強度,不依賴於溫度。
另外一種是Dynamic Power,是指電路在active時候的功耗,包括internal power和switching power。
Internal power是指在boundary of cell內的動態功耗,包含cell內部的電容充放電,PN節之間的瞬時短路(momentary short circuit, P晶體管和N晶體管在關閉打開過程中間的某一短暫時刻,會短路,導致從VDD到GND的瞬時電流).因此,對於具有較慢transition time的電路,short-circuit power能夠占到總的gate power的50%。
Switching power是由一個cell的輸出端負載電容的充放電導致的(power dissipated by the charging and discharging of load capacitance at the output of the cell).總的load capacitance是輸出驅動端(driving output)net和gate電容的累加。
Averaged mode: SAIF, VCD, set_switching_activity, Tool defaults
Time-based mode: RTL-VCD, Gate-Level VCD (Peak power)
關於SAIF和VCD的區別:
SAIF: SAIF stands for Switching Activity Interface Format. The SAIF files capture signal transitions and the time spent at each logic level. The SAIF file contains the toggle counts and static probabilities for the nets in the design. SAIF is supported only in the averaged power analysis mode. Use the read_saif command to annotate the activity information in the SAIF format.

VCD: VCD stands for Verilog Change Dump format. It is an event-based format that contains every value change for the signals in the design and the time at which they occurred. Use the read_vcd command to specify the VCD file in both the averaged and time-based analysis modes. Use the read_vcd command to specify the activity files in other event-based formats within the PrimeTime PX tool. Internally, the tool converts these formats to the VCD format using the appropriate utility.
VCD文件示例:http://en.wikipedia.org/wiki/Value_change_dump
這里只關注Gate-level的功耗分析,對於RTL level的,需要進行一系列的mapping操作。
首先看SAIF文件格式
對於Gate-level的SAIF文件,報刊每個單元activities的反標,用來計算平均功耗。使用read_saif來讀取saif文件。
SAIF文件的產生有多種途徑,甚至可以由VCD文件轉換(vcd2saif),也可以在simulation中獲得,這里補充一下,使用Synopsys的VCS MX可以對Verilog、System Verilog和VHDL的工程實現混仿。這里需要關注Power Compiler的文檔。
VCD文件格式
同樣,對於VCD文件格式,也有RTL和Gate-level之分,對於RTL level的VCD文件,需要使用read_vcd –rtl或者read_vcd –zero_delay讀取activity file。read_vcd默認為讀取gate-level的文件。
對於VCD文件,同樣可以使用VCS或者其他的HDL仿真環境來產生。
在time-based的功耗分析模式,PT PX不支持多個activity VCD文件的讀入。在讀取VCD文件的時候,經常會出現VCD hierarchy與當前design不匹配的情況,導致最終反標成功的cell為0,這個mismatch主要是由於當使用read_vcd -strip_path來指定當前的design時,-strip_path選擇錯誤,或者VCD文件沒有包含所有的design hierarchy。
使用PT PX的重要內容之一是name mapping,主要是對於RTL級別的design進行功耗分析的時候,需要將RTL級別的activity與門級網表進行map。這里不贅述。
Averaged Power Analysis
進行平均功耗的分析需要的switching activity主要包含static probability和toggle rate兩個參數。
Static probability是某個信號在某一個特定logic state下的概率,比如,SP1和SP0就是某個信號在logic-1和logic-0下的概率。SP是一個信號在某一個狀態的時間/總的仿真時間,得到的一個比值,比如SP1=0.7表示在70%的時間這個信號等於1.
Toggle rates是一個對象,比如net、pin、port在per unit time下的0->1和1->0的transition數目。由TR表示。
行為反標的方法包括:
Annotation of RTL or gate-level VCD files with read_vcd command
Annotation of RTL or gate-level SAIF files with the read_saif or merge_saif commands
使用VCD文件進行反標:
read_vcd -strip_path TB/DUT my.vcd
-strip_path指定當前實例化的設計的path。
需要注意的是,在做平均的功耗分析的時候,PT PX支持讀入多個VCD文件,但是條件是需要指定不同的時間,在使用read_vcd命令的時候使用-time指定。
read_vcd還支持有條件的功耗分析,使用-when開關,比如說指定分析在某個信號為true時候的功耗。
使用SAIF文件的時候,涉及的commands有read_saif (read_saif -strip_path TB/DUT my.saif)、merge_saif和write_saif.
當分析不同時鍾頻率情況下的功耗的時候,需要set_app_var power_enable_analysis true,並且使用set_power_clock_scaling的命令。
當simulation的activity文件無法得到時,需要用戶自己定義activity,使用的命令包括set_case_analysis, create_clock, infer_switching_activity and set_switching_activity。
report switching activity
另一個重要內容是report switching activity。在讀入saif或者vcd文件,或者set_switching_activity之后,使用report_switching_activity就能夠報告switching activity的各項活動。可以使用-list_not_annotated可以列出沒有被反標的對象。
使用下面的屬性還可以得到TR和SP的值:
toggle_count/toggle_rate/glitch_rate/static_probability
注意,在此之前,首先要update_power。
還有一些選項,如report_switching_activity -average_activity -hierarchy
還有一個命令為get_switching_activity,使用activity_source屬性,可以定義activity information的來源,包括file, set_switching_activity, set_case_analysis, propagated, implied, default, or UNINITIALIZED等。可以得到TR,SP和glitch rate
在得到switching activity之后,使用update_power來將其反標,使用report_power來報告power的值。
使用report_annotated_power -list_annotated可以得到反標的報告列表。
Time-based power analysis
PT PX使用VCD來計算每個事件導致的功耗,SAIF格式對此不支持。
read_vcd "../sim/vcd.dump" -strip_path "tb/macinst" -when {N5},讀取VCD文件中,在N5為true時候的activities。另外還有-time選項。
Handling Large Activity Files
Gate-level的VCD文件可能會非常大,盡管PT PX能夠處理大於2G的VCD文件,但是還是要盡量避免產生和儲存大的VCD文件。方法一是生成壓縮的文件格式來減小activity file的尺寸,比如FSDB或者gzipped的VCD文件。另一種方法是直接將simulation生成的activity數據導入到PT PX,步驟如下:
1) 建立HDL的仿真環境,產生activity文件。比如,在testbench中必須包含$dumpvars或者$dumpfile來產生VCD文件。這個文件名即管道名,因此,兩個工具都知道從哪里讀寫數據,而不需要創建大的文件
2) 定義命令或者運行腳本來調用HDL的仿真,使用-pipe_exec。比如,如果運行一個腳本執行VCS的仿真,包含vcs –R –f arguments –l log。使用下面的某一個命令來調用仿真,並直接讀取VCD數據到PT PX
-pipe_exec run_vcs
-pipe_exec “vcs –R –f arguments –l log”
Average Toggle Rate=Number of Toggles on All Signals Per Interval/Number of Signals
Coverage=Number of Signals with at least one Toggle/Number of Signals
建立分布式環境,加速功耗分析
1) 建立分布式的計算環境,允許同時運行多個scenarios。使用LSF的兩個machines進行分布式的peak power分析。
set_app_var power_enable_analysis true
set multi_scenario_working_directory ./work
set multi_scenario_merged_error_log ./work/error_log.txt
set_multi_scenario_license_limit -feature PrimeTime 2
set_multi_scenario_license_limit -feature PrimeTime-PX 2
set_host_options -32bit -num_processes 2 -submit_command /lsf/bin/bsub
start_hosts
2) 將仿真分割成兩個模塊
set test_dir .
# The common data is used by all the scenarios. Since all the scenarios must read the design data and update timing.
create_scenario -name run_0 -specific_data run_0.tcl -common_data common.tcl -common_variables {test_dir}
create_scenario -name run_1 -specific_data run_1.tcl -common_data common.tcl -common_variables {test_dir}
set_app_var power_enable_analysis true
set_app_var power_analysis_mode time_based
set_app_var search_path "."
set_app_var link_library " * link_library.db"
read_verilog mac.vg
current_design mac
link
read_sdc $test_dir/mac.sdc
set_disable_timing [get_lib_pins ssc_core_typG]
read_parasitics ../src/annotate/mac.spef.gz
#####################################################
# check, update, or report the timing
#####################################################
check_timing
update_timing
report_timing
#####################################################
# read switching activity file
#####################################################
read_vcd -strip_path tb/macinst ../sim/vcd.dump.gz
report_switching_activity -list_not_annotated
#####################################################
# check or update or report power
#####################################################
check_power
update_power
report_power -hierarchy
quit
Example 4 Script Example for Time-Based Power Analysis
#####################################################
# Set the Power Analysis Mode
#####################################################
set power_enable_analysis TRUE
set power_analysis_mode time_based
#####################################################
# link design
##############################################
set search_path "../src/hdl/gate ../src/lib/snps . "
set link_library " * core_typ.db"
read_verilog mac.vg
current_design mac
link
#####################################################
# set transition time / annotate parasitics
#####################################################
read_sdc ../src//hdl/gate/mac.sdc
set_disable_timing [get_lib_pins ssc_core_typ/*/G]
read_parasitics ../src/annotate/mac.spef.gz
#####################################################
check_timing
update_timing
report_timing
#####################################################
# read switching activity file
#####################################################
read_vcd ../sim/vcd.dump.gz -strip_path tb/macinst
#####################################################
# analyze power
#####################################################
check_power
set_power_analysis_options -waveform_format out -waveform_output vcd
update_power
report_power
quit