数字逻辑综合DC脚本示例及解释

#script for Design Compiler
# Language  : TCL
# Usage     :
#           1) make sure the lib in the current directory
#           2) if you have the file .synopsys_dc.setup,
#              set synopsys_dc_setup_file 1,
#              if not, set synopsys_dc_setup_file 0
#           3) change Step 3 : Variables to what you want
#              Especially : top module name, clock name,
#              reset name, all files name, and period
#           4) typing dc_shell-t -f run_72.tcl | tee -i run.log

#========================================================

set synopsys_dc_setup_file 0
#-----------------------------------------------------
# Step 1 :
# Setting Up path and library:
# If you have edited the file .synopsys_dc.setup, then you can skip over this step
#-----------------------------------------------------
if { $synopsys_dc_setup_file == 0} {
set search_path [list /home/chanshi/dc/library/smic /home/chanshi/dc/rfid/source /home/chanshi/dc/script]
set target_library  {typical.db}
#set target_library  {CSM35OS142_typ.db};
# if you want use typical library,change to typical.db
#set link_library  [list {*} ram_interp_typical_syn.db ram_458_typical_syn.db typical.db]
set link_library  [list {*} $target_library]
}
#set symbol_library  {csm18ic.sdb csm18io.sdb}
#set synthetic_library  {dw_foundation.sldb};
# Design Ware
set command_log_file   "command.log"

#-----------------------------------------------------
# Step 2 :
# Compile Swithes
#-----------------------------------------------------
#set verilogout_no_tri                  true ;
# if inout used, tri net will be used
#通过将三态(tri)逻辑声明成线网(wire)来确保网表中不会出现三态逻辑,因为一些布线工具很难读取包含tri、tran源语、assign语句 的网表,对于“inout”类型的port,DC产生tri wire 语句和tran 源语,对于tri,还会产生assign语句
set test_default_scan_style          multiplexed_flip_flop
#设置扫描链的类型,还可以通过set_scan_configuration -style来设置
set link_force_case                  case_insensitive
#设置link命令是否区分大小写,默认是check_reference,就是根据产生reference的模块格式来判断是否大小写敏感,如果是vhdl格式就是不敏感,如果是verilog就敏感
define_name_rules VLSI_NET -allowed "a-zA-Z0-9_" -first_restricted "0-9_" -type net -max_length 256
define_name_rules VLSI_CELL -allowed "a-zA-Z0-9_" -first_restricted "0-9_" -type cell -max_length 256
define_name_rules VLSI_PORT -allowed "a-zA-Z0-9_" -first_restricted "0-9_" -type port -max_length 256
define_name_rules TAN_RULE -allowed "a-zA-Z0-9_" -first_restricted "0-9_\[]" -max_length 256 -map {{{"*cell*", "mycell"}, {"*-return", "myreturn"}}};
set hdlin_check_no_latch "true"
#设置如果推断出锁存器,是否报warning,默认是false,即不报。
set hdlin_merge_nested_conditional_statements "true"
#顾名思义,是否把嵌套的if融合,默认值是false,就是对于嵌套的条件语句(if或case语句)中的每一个if和case都推断出一个选择器,这 种做法有利于把某些迟到的条件判断信号(late arriving signals)安排到离输出最近的选择器上(进而有利于减小延迟),如果设成true,就会把这些选择器融合成一个大的选择器,这样所有的选择信号到输 出的距离都是相同的

#-----------------------------------------------------
# Step 3 :
# Define Variables
#-----------------------------------------------------
set active_design "whole_modules";
# Top module name
source files.tcl;
# All RTL source_files (verilog)
set clock_name "clk";
# Name of clock
set reset_name "reset";
# Name of reset
set clk_period  70.0
#设置时钟周期,注意带小数点,这样计算出的值都带小数点,不然小于1的数都显示为0
# Desired Clock Period = 1000/Frequence
set clk_uncertainty_setup [expr $clk_period/200];
#设置时钟不确定性,这里只设置了相对于建立时间的不确定性,就是时钟上升沿有可能提前 clk_uncertainty_setup(时钟偏差和时钟抖动之和)到来,dc要提前clk_uncertainty_setup检查建立时间是否满足
# Uncertainty of clock
set clk_latency [expr $clk_period/10];
#设置时钟延迟,是时钟信号从其实际时钟原点到设计中时钟定义点的传输时间
# Network Latency of clock
#考虑reg1+combo1--------combo2_input+reg2+combo2_output----------- combo3+reg3的模型来解释input_delay和output_delay,中间的 combo2_input+reg2+combo2_output是要综合的模块
set input_delay [expr $clk_period/4];
#设置输入延迟,设置一个外部输入(组合逻辑combo1)用了多少时间(即从时钟上升沿到输入数据到来经历的延迟),dc计算还有多少时间留给内部组合 逻辑combo2_input,例如时钟周期为10ns,input_delay是4ns,则还有(6-tsu)留给内部组合逻辑 combo2_input
# Input Delay of all input ports except clock
set output_delay [expr $clk_period/4];
#设置输出延迟,设置一个外部输出(组合逻辑combo3)用了多少时间(即外部组合逻辑的延迟),dc计算有多少时间留给内部组合逻辑 combo2_output,例如时钟周期为10ns,output_delay为4ns,则还有(6-Tclk2Q)留给内部组合逻辑 combo2_output
# Output Delay of all output ports
set area_desired 0;
#设置面积的期望值,用于set_max_area
set wire_load_model "smic18_wl20";
#为了精确地计算设置线载模型(DC支持三种模式:
 
以此来决定如何选择用于跨层次边界的网线的线载模型),用于计算时序路径的延迟,用于set_wire_load_model
# Model of the intra net
set output_load "typical/NAND2BX1/AN" ;
#为了精确地计算输出电路的时间,需要设置端口负载(输出或输入的外部电容负载),就是为所有输出端口指定一个负载,综合时dc就会认为这里有一个这样的 负载(并不是说综合时在这里强制添加一个电容),dc综合时就会选择满足这个负载的器件,例如假设已经知道某输出端口要驱动的是一个反相器,那么把输出负 载设置成这个反相器的输入负载即可,当然可以设置成很大,这样dc就会用驱动能力很大的器件,来满足所有单元被驱动。这个指令的作用是在布图前综合过程中 设置模块输出端口的容性负载和往连线上反标注布图后提取的电容信息,这里选取某一器件的某一引脚的负载作为output load,也就是dc认为所有输出端口要达到能驱动这个引脚
# model of the output_load
set synthesis_reports  {/home/chanshi/dc/report};
#指定综合报告的输出目录
#name of report directory
sh  mkdir $synthesis_reports;
set timing_report       "$synthesis_reports/$active_design\_timing.rpt"
set timing_max20_report "$synthesis_reports/$active_design\_timing_max20.rpt"
set area_report         "$synthesis_reports/$active_design\_area.rpt"
set references_report   "$synthesis_reports/$active_design\_references.rpt"
set cell_report         "$synthesis_reports/$active_design\_cell.rpt"
set constraint_report   "$synthesis_reports/$active_design\_constraint.rpt"
set power_report        "$synthesis_reports/$active_design\_power.rpt"
set check_syntax_report "$synthesis_reports/$active_design\_check_design.rpt"
set synthesis_netlist  {/home/chanshi/dc/result};
#指定网表和sdf/sdc/db文件输出目录,本dc不支持生成db文件
#name of outfile directory
sh  mkdir $synthesis_netlist;
#创建目录
set out_netlist         "$synthesis_netlist/$active_design.v";
set out_db              "$synthesis_netlist/$active_design.db";
set out_sdf             "$synthesis_netlist/$active_design.sdf";
set out_sdc             "$synthesis_netlist/$active_design.sdc";

#-----------------------------------------------------
# Step 4 :
# Read design to DC Memory
#-----------------------------------------------------
foreach active_files $files {read_verilog $active_files}
#foreach语句,$files是一个文件列表,把列表里的每一个文件轮流赋值给active_files,然后对active_files执行read_verilog函数,就相当于轮流对每一个文件执行read_verilog函数
#exit
current_design $active_design
#设置当前设计
link
#把当前设计中实例化引用的单元链接到当前设计(即读取link_library指定的库到当前设计)
uniquify
#为每一个例化单元起一个单独的名字(是对于某个模块多次引用的情况)

#check_design > $check_syntax_report
#if {[check_design] == 0} {
 #     echo "Check Design Error!";
 #     exit;
 #      }
#-----------------------------------------------------
# Step 5 :
# Constraint
#-----------------------------------------------------
#-----Net load------
set_wire_load_model -name $wire_load_model
#设置线载模型
set_wire_load_mode top
#设置线载模式(top:所有层次中所有连线将继承和顶层模块同样的线载模型,因为顶层电路规模最大,所以连线延迟最大,线载模型最悲 观;enclosed:选择连线所在的子模块的线载模型,子模块电路规模较顶层要小,连线延迟较短;segmented:不常用,用于跨层次边界的连线)
#-----clock------
create_clock -name $clock_name -period [expr $clk_period] [get_ports $clock_name]
#设置时钟
set_clock_uncertainty -setup $clk_uncertainty_setup [get_clocks $clock_name]
#设置时钟不确定性
set_clock_latency $clk_latency [get_clocks $clock_name]
#设置时钟延迟
set_dont_touch_network [get_clocks $clock_name]
#在优化过程中对时钟网络不进行改变和替换,原因:由于时钟端口的负载很大,DC 会使用 Buffer 来增加其驱动能力。但一般设计者都使用布局布线工具来完成此项工作,所以有必要指示 DC 不要对时钟网络进行修改,可以选中上图中“Don’t touch network”进行设置。
set_dont_touch_network [get_ports $reset_name]
#在优化过程中对复位信号不进行改变和替换
set_ideal_network [get_ports $reset_name]
#对reset设置成理想线网,因为reset的fanout太大,一般布图前都设置成理想线网,具体原因有待研究#-----drive------
#set_driving_cell -lib_cell xr02d2 -pin A1 -library CSM35OS142_typ  [all_inputs]
set_driving_cell -lib_cell NAND2BX1 -pin Y [all_inputs]
#为所有输入端口(除去时钟和复位)设置驱动模型,从而指定了驱动强度和转换时间
set_drive 0 [get_ports $clock_name]
#将时钟驱动能力设为无穷大,即将其阻抗设为 0
set_drive 0 [get_ports $reset_name]
#同上
#-----input/output delay------
set allin_except_CLK [remove_from_collection [all_inputs] [get_ports clk]]
set_input_delay [expr $input_delay] -clock $clock_name $allin_except_CLK
#设置输入延时
set_output_delay [expr $output_delay] -clock $clock_name [all_outputs]
#设置输出延时
#-----Output load------
set_load [load_of $output_load] [all_outputs]
#设置所有输出端口的负载
#----- Area ------
#set_max_area $area_desired
#----- insert buffer replace assign ------
set_fix_multiple_port_nets -all -buffer_constants
#如果一个线网连接着多个端口,则在网表中会出现assign语句,这是一种错误,为避免这种错误,要消除多端口连线,可以通过插入buffer来消除(具体见《专用集成电路设计实用教程》p146)
#-----------------------------------------------------
# Step 6 :
# Compile
# Also can use compile_ultra
#-----------------------------------------------------
compile -map_effort medium -boundary_optimization
#compile -map_effort medium
#-boundary_optimization -area_effort high
#compile -incremental_mapping
#-----------------------------------------------------
# Step 7 :
# Reports (Timing, Area ...)
#-----------------------------------------------------
remove_unconnected_ports [get_cells -hier {*}]
change_names -hierarchy -rules TAN_RULE
report_timing -delay max -max_paths 1 > $timing_report
report_timing -delay max -path end -max_path 80 > $timing_max20_report
report_area > $area_report
report_reference > $references_report
report_cell [get_cells -hier *] > $cell_report
report_constraint -all_violators -verbose > $constraint_report
report_power -analysis_effort high -verbose > $power_report
check_design > $check_syntax_report
#-----------------------------------------------------
# Step 8 :
# Write Files (netlist out)
#-----------------------------------------------------
change_names -rule verilog –hier
write -format verilog -hierarchy -output $out_netlist
write -format db -hierarchy -output $out_db
write_sdf  $out_sdf
write_sdc  $out_sdc
exit
#----------------------end-------------------

------------

转载

原文地址:https://www.cnblogs.com/zeushuang/p/2631878.html