SDC命令详解:使用相对路径访问设计对象(current_instance命令)
相关阅读
SDC命令详解https://blog.csdn.net/weixin_45791458/category_12931432.html?spm=1001.2014.3001.5482
在使用get_cells等命令访问设计对象时,需要指定设计对象的名字,这个名字是一个相对路径,本文就将对此进行讨论。
本文针对Design Compiler,但该命令同样存在于PrimeTime、IC Compiler等工具中,它们大致相同,略有差别。
相对路径
使用相对路径来访问设计对象时,该对象必须位于当前设计(Current Design)中,且路径相对当前实例(Current Instance)指定,当前实例是当前设计中的一个层次单元,默认情况下当前实例就是当前设计,可以使用current_instance命令设置当前实例。
图1 一个简单的层次设计
以图1为例,如果想在当前设计中Multiplier_Booth_STG_0中设置单元M1/C150的dont_touch属性,可以使用下面两种方法:
// 方法一 prompt> current_design // 确认当前设计 Current design is 'Multiplier_Booth_STG_O'. (Multiplier_Booth_STG_0} prompt> set_dont_touch [get_cells M1/C150]// 方法二 prompt> current_design // 确认当前设计 Current design is 'Multiplier_Booth_STG_O'. (Multiplier_Booth_STG_0} prompt> current_instance . // 确认当前实例,注意点的添加 Current instance is the top-level of design 'Multiplier_Booth_STG_0'. prompt> current_instance M1 // 设置当前实例 Current instance is '/Multiplier_Booth_STG_0/M1'. /Multiplier_Booth_STG_0/M1 prompt> set_dont_touch [get_cells C150]在方法一中,路径相对当前设计(即顶层设计)指定;在方法二中,路径相对实例M1指定。若想将当前实例重置为当前设计,只需要使用不带参数或使用/作为参数的current_instance命令即可,如下所示。
prompt> current_instance Current instance is the top-level of design 'Multiplier_Booth_STG_0'. prompt> current_instance / Current instance is the top-level of design 'Multiplier_Booth_STG_0'.需要注意的是,如果使用current_design重新设置了当前设计,则当前实例也会被重置为当前设计,如下所示。
prompt> current_design // 确认当前设计 Current design is 'Multiplier_Booth_STG_O'. (Multiplier_Booth_STG_0} prompt> current_design Datapath // 设置当前设计 Current design is 'Datapath'. {Datapath} Current design is 'Datapath'. prompt> current_instance . // 确认当前实例,注意点的添加 Current instance is the top-level of design 'Datapath'.顺带一提,除了使用current_instance命令设置当前实例,current_instance变量也可以设置和查询当前实例,如下所示。
prompt> current_design // 确认当前设计 Current design is 'Multiplier_Booth_STG_O'. (Multiplier_Booth_STG_0} prompt> current_instance . // 确认当前实例,注意点的添加 Current instance is the top-level of design 'Multiplier_Booth_STG_0'. prompt> set current_instance M1 // 设置当前实例 Current instance is '/Multiplier_Booth_STG_0/M1'. /Multiplier_Booth_STG_0/M1 prompt> printvar current_instance // 直接查看变量值 current_instance = "/Multiplier_Booth_STG_0/M1"当使用get_cells/report_cell等命令时,如果不指定对象作为参数,默认以当前实例为参数,如下所示。需要注意的是,即使是相对当前实例指定的get_cell命令,返回的对象名还是相对当前设计而言的。
prompt> current_design // 确认当前设计 Current design is 'Multiplier_Booth_STG_O'. (Multiplier_Booth_STG_0} prompt> current_instance . // 确认当前实例,注意点的添加 Current instance is the top-level of design 'Multiplier_Booth_STG_0'. prompt> report_cell // 报告当前实例内的单元 **************************************** Report : cell Design : Multiplier_Booth_STG_0 Version: W-2024.09-SP2 Date : Sat Apr 12 13:17:57 2025 **************************************** Attributes: b - black box (unknown) h - hierarchical n - noncombinational r - removable u - contains unmapped logic Cell Reference Library Area Attributes -------------------------------------------------------------------------------- M1 Datapath 0.000000 h, n, u M2 Controller 0.000000 h, n, u -------------------------------------------------------------------------------- Total 2 cells 0.000000 prompt> set current_instance M1 // 设置当前实例 Current instance is '/Multiplier_Booth_STG_0/M1'. /Multiplier_Booth_STG_0/M1 prompt> report_cell // 报告当前实例内的单元 **************************************** Report : cell Design : Multiplier_Booth_STG_0/M1 (Datapath) Version: W-2024.09-SP2 Date : Sat Apr 12 13:21:17 2025 **************************************** Attributes: b - black box (unknown) c - control logic h - hierarchical n - noncombinational r - removable s - synthetic operator u - contains unmapped logic Cell Reference Library Area Attributes -------------------------------------------------------------------------------- B_0 GTECH_BUF gtech 0.000000 c, u B_1 GTECH_BUF gtech 0.000000 c, u C128 *SELECT_OP_5.1_5.1_1 0.000000 s, u C129 *SELECT_OP_2.8_2.1_8 0.000000 s, u C130 *SELECT_OP_2.4_2.1_4 0.000000 s, u C131 *SELECT_OP_5.1_5.1_1 0.000000 s, u C132 *SELECT_OP_3.8_3.1_8 0.000000 s, u C142 GTECH_OR2 gtech 0.000000 c, u C143 GTECH_OR2 gtech 0.000000 c, u C144 GTECH_OR2 gtech 0.000000 c, u C147 GTECH_AND2 gtech 0.000000 c, u C148 GTECH_AND2 gtech 0.000000 c, u C150 GTECH_AND2 gtech 0.000000 c, u C152 GTECH_AND2 gtech 0.000000 c, u C153 GTECH_AND2 gtech 0.000000 c, u C154 GTECH_AND2 gtech 0.000000 c, u C156 GTECH_AND2 gtech 0.000000 c, u C157 GTECH_AND2 gtech 0.000000 c, u C158 GTECH_AND2 gtech 0.000000 c, u I_0 GTECH_NOT gtech 0.000000 u I_1 GTECH_NOT gtech 0.000000 c, u I_2 GTECH_NOT gtech 0.000000 c, u I_3 GTECH_NOT gtech 0.000000 c, u I_4 GTECH_NOT gtech 0.000000 c, u add_28_S2 *ADD_UNS_OP_8_8_8 0.000000 s, u multiplicand_reg[0] **SEQGEN** 0.000000 n, u multiplicand_reg[1] **SEQGEN** 0.000000 n, u multiplicand_reg[2] **SEQGEN** 0.000000 n, u multiplicand_reg[3] **SEQGEN** 0.000000 n, u multiplicand_reg[4] **SEQGEN** 0.000000 n, u multiplicand_reg[5] **SEQGEN** 0.000000 n, u multiplicand_reg[6] **SEQGEN** 0.000000 n, u multiplicand_reg[7] **SEQGEN** 0.000000 n, u multiplier_reg[0] **SEQGEN** 0.000000 n, u multiplier_reg[1] **SEQGEN** 0.000000 n, u multiplier_reg[2] **SEQGEN** 0.000000 n, u multiplier_reg[3] **SEQGEN** 0.000000 n, u product_reg[0] **SEQGEN** 0.000000 n, u product_reg[1] **SEQGEN** 0.000000 n, u product_reg[2] **SEQGEN** 0.000000 n, u product_reg[3] **SEQGEN** 0.000000 n, u product_reg[4] **SEQGEN** 0.000000 n, u product_reg[5] **SEQGEN** 0.000000 n, u product_reg[6] **SEQGEN** 0.000000 n, u product_reg[7] **SEQGEN** 0.000000 n, u sub_31_S2 *SUB_UNS_OP_8_8_8 0.000000 s, u -------------------------------------------------------------------------------- Total 46 cells 0.000000有些命令只能在当前实例为当前设计时使用,如all_inputs/all_outputs等命令;有些命令需要配合current_instance命令使用才能完成某些效果,如create_cell/insert_buffer等命令。
current_instance命令
除了不带参数和使用当前实例下的层次单元作为参数,current_instance命令还可以接受其他类型的参数,就像Linux中的相对路径那样,可以接受.以表示当前实例和..表示上层实例,如下所示。
prompt> current_design // 确认当前设计 Current design is 'Multiplier_Booth_STG_O'. (Multiplier_Booth_STG_0} prompt> current_instance . // 确认当前实例,注意点的添加 Current instance is the top-level of design 'Multiplier_Booth_STG_0'. prompt> current_instance ./M1 // 设置当前实例,与current_instance M1等价 Current instance is '/Multiplier_Booth_STG_0/M1'. /Multiplier_Booth_STG_0/M1 prompt> current_instance .. // 设置当前实例 Current instance is the top-level of design 'Multiplier_Booth_STG_0'. prompt> current_instance ../../../M1 // 设置当前实例 Current instance is '/Multiplier_Booth_STG_0/M1'.上例还有两点细节可以注意:1、参数末尾加不加/效果相同(2021版本后支持),这与Linux中作为参数的目录类似;2、如果索引超出了当前设计,则视为当前设计。
类似概念
在低功耗设计(UPF)中也存在类似当前实例的概念,叫做当前范围(Current Scope),使用set_scope命令可以设置当前范围,实际上使用本文的current_instance命令和current_instance变量也可以设置当前范围,它们之间的差别很小。
