SDC命令详解:使用相对路径访问设计对象(current_instance命令) 相关阅读SDC命令详解https://blog.csdn.net/weixin_45791458/category_12931432.html?spm1001.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变量也可以设置当前范围它们之间的差别很小。