synopsys的Tcl脚本语言学习笔记(2)

时间:2024-05-22 14:05:57

转自http://blog.sina.com.cn/s/blog_6840802c0100k1o0.html

Chapter 5
A Tcl Script Example

本章将讲解一些Tcl脚本文件,以说明怎样使用Tcl脚本文件和synopsys命令,以及在前些章节中讲解的topics. 从细节上对Tcl脚本文件进行讲解。

    脚本文件中包含dc_rpt_cell进程和define_proc_attributes命令,用来扩展dc_rpt_cell的属性。

DC_rpt_cell综述

DC_rpt_cell脚本有两个部分,第一部分是dc_rpt_cell进程,第二部分是define_proc_attributes命令,define_proc_attributes命令扩展了dc_rpt_cell进程的属性。DC_rpt_cell进程列举了设计中所有的cell,并且如果cell有如下的特性将产生报告文档。

黑盒,保护属性,继承,组合以及测试cell。

在例子5-1中给出了脚本文件的全部程序代码Dc_rpt_cell,这里给出了使用该Tcl家在设计数据库德方法:我在这里使用的是任意整数分频电路,而脚本文件使用的例5-1中的脚本文件,最后执行的结果和例子中的还是有很大的区别,这里只是想了解一下,因而在Desing compiler中跑了一下,由于没有添加时序路径的约束,因而生成的报告中,没有关于路径约束的部分。这个脚本文件还是值得自己仔细研究一下。

Source DC_rpt_cell  #脚本文件

Read_file –format verilog ddc /home/fzz/verilog_study/clk_any.ddc

DC_rpt_cell –total_only

synopsys的Tcl脚本语言学习笔记(2)
 

例子5-1 DC_rpt_cell脚本文件

#Title:        DC_rpt_cell.tcl

#

#Description: This Design Compiler Tcl procedure generates a cell

#              report of a design.

#              It reports all cells and the following attributes:

#                b - black box (unknown)

#                d - has dont_touch attribute

#                dw - DesignWare part

#                h - hierarchy

#                n - noncombinational

#                t - test cell

#

#Options:      -all_cells    one line per cell plus summary

#              -hier_only    every hierarchy cell and summary

#              -total_only   generate summary only

#

#Software:     Y-2006.06

#Version:      June 2006

#Usage:        dc_shell> source DC_rpt_cell.tcl

#              dc_shell> DC_rpt_cell -t

#

proc DC_rpt_cell args {

   suppress_message UID-101

   set option [lindex $args 0]

   if {[string match -a* $option]} {

       echo " "

       echo "Attributes:"

       echo " b - black-box (unknown)"

       echo " d - dont_touch"

       echo " dw - DesignWare"

       echo " h - hier"

       echo " n - noncombo"

       echo " t - test cell"

       echo " "

       echo [format "%-32s %-14s %5s %11s" "Cell" "Reference" "Area" "Attributes"]

       echo "-----------------------------------------------------------------"

      } elseif {[string match -t* $option]} {

           set option "-total_only"

           echo ""

           set cd [current_design]

           echo "Performing cell count on [get_object $cd]"

           echo " "

      } elseif {[string match -h* $option]} {

           set option "h";   # hierarchical only

           echo ""

           set cd [current_design]

          echo "Performing hierarchical cell report on [get_object $cd] "

           echo " "

 

 

           echo [format "%-36s %-14s %11s" "Cell" "Reference" "Attributes"]

           echo "-----------------------------------------------------------------"

      } else {

           echo " "

           echo " Message: Option Required (Version - December 2002)"

           echo " Usage: DC_rpt_cell \[-all_cells\] \[-hier_only\]\[-total_only\]"

           echo " "

           return

      }

   # initialize summary vars

   set total_cells 0

   set dt_cells 0

   set hier_cells 0

   set hier_dt_cells 0

   set dw_cells 0

   set seq_cells 0

   set seq_dt_cells 0

   set test_cells 0

   set total_area 0

   # initialize other vars

   set hdt ""

   set tc_atr ""

   set xcell_area 0

   # create a collection of all cell objects

   set all_cells [get_cells -h *]

   foreach_in_collection cell $all_cells {

      incr total_cells

      set cell_name [get_attribute $cell full_name]

      set dt [get_attribute $cell dont_touch]

      if {$dt=="true"} {

           set dt_atr "d"

           incr dt_cells

         } else {

           set dt_atr ""

         }

      set ref_name [get_attribute $cell ref_name]

      set cell_area [get_attribute $cell area]

      if {$cell_area > 0} {

        set xcell_area $cell_area

        } else {

        set cell_area 0

      }

 

      set t_cell [get_attribute $cell is_a_test_cell]

      if {$t_cell=="true"} {

        set tc_atr "t"

        incr test_cells

        } else {

        set tc_atr ""

      }

      set hier [get_attribute $cell is_hierarchical]

      set combo [get_attribute $cell is_combinational]

      set seq [get_attribute $cell is_sequential]

      set dwb [get_attribute $cell DesignWare]

      set dw_atr ""

      if {$hier} {

        set attribute "h"

        incr hier_cells

        set hdt [concat $option $hier]

        if {$dt_atr=="d"} {

          incr hier_dt_cells

        }

        if {$dwb=="true"} {

            set dw_atr "dw"

            incr dw_cells

        }

        } elseif {$seq} {

        set attribute "n"

        incr seq_cells

        if {$dt_atr=="d"} {

          incr seq_dt_cells

        }

        set total_area [expr $total_area + $xcell_area]

        } elseif {$combo} {

        set attribute ""

        set total_area [expr $total_area + $xcell_area]

        } else {

        set attribute "b"

      }

      if {[string match -a* $option]} {

       echo [format "%-32s %-14s %5.2f %2s %1s %1s %2s" $cell_name $ref_name \

              $cell_area $attribute $dt_atr $tc_atr $dw_atr]

      } elseif {$hdt=="h true"} {

          echo [format "%-36s %-14s %2s %2s" $cell_name $ref_name $attribute \

                  $dt_atr $dw_atr]

          set hdt ""

        }

     } ; # close foreach_in_collection

   echo "-----------------------------------------------------------------"

 

 

   echo [format "%10s Total Cells" $total_cells]

   echo [format "%10s Cells with dont_touch" $dt_cells]

   echo ""

   echo [format "%10s Hierarchical Cells (incl DesignWare)" $hier_cells]

   echo [format "%10s Hierarchical Cells with dont_touch" $hier_dt_cells]

   echo ""

   echo [format "%10s DesignWare Cells" $dw_cells]

   echo ""

   echo [format "%10s Sequential Cells (incl Test Cells)" $seq_cells]

   echo [format "%10s Sequential Cells with dont_touch" $seq_dt_cells]

   echo ""

   echo [format "%10s Test Cells" $test_cells]

   echo ""

   echo [format "%10.2f Total Cell Area" $total_area]

   echo "-----------------------------------------------------------------"

   echo ""

 }

 define_proc_attributes DC_rpt_cell \

   -info "Report all cells in the design (v12/2002)" \

   -define_args {

   {-a "report every cell and the summary"}

   {-h "report only hierarchy cells and the summary"}

   {-t "report the summary only"} }

DC _rpt_cell脚本通过以下的几个方面讲解:

定义进程,制止警告信息,检查参数,初始化变量,创建、并在集合之间迭代、收集报告数据,格式化输出

Defining the Procedure

 DC_rpt_cell进程仅要求有一个参数,因而定义简单,下面给出DC_rpt_cell的定义

proc DC_rpt_cell args{

   procedure body ….

}

使用Tcl中的proc命令实现定义进程,DC_rpt_cell命名进程,args是在进程被调用时接受参数的变量,args的值在进程内部的使用,例如如下的描述方式:

 Set option [linux $args 0] # 这里就是对参数的引用

Synopsys的define_proc_attributes命令提供关于进程的额外信息,例如定义一些帮助或者提示信息,对于DC_rpt_cell,define_proc_attributes命令用来声明关于dc_rpt_cell的额外的帮助信息。例5.4中给出了define_proc_attributes和DC_rpt_cell一起使用的例子

例子5-4 :

define_proc_attributes DC_rpt_cell \

-info "Procedure to report all cells in ..." \

-define_args {

{-a "report every cell and the summary"}

{-h "report only hierarchy cells and the summary"}

{-t "report the summary only"} }

额外的信息中有一行用来描述 dc_rpt_cell,描述其所希望启动的选项,在终端运行时,下面的例子给出了define_proc_attributes定义DC_rpt_cell的。给出了简单的的关于帮助的信息。