Design Compiler中list和collection的区别

Design Compiler中list和collection的区别

前言

集合(collection)的操作和列表(list)是不一样的,集合无法像列表一样使用foreach,而是使用foreach_in_collection来遍历。

一、list

list为列表创建的关键词,可以使用foreach遍历列表并用echo显示。

代码如下(示例):

set memlist [list sram_wrapper/u_sram_0 sram_wrapper/u_sram_1 sram_wrapper/u_sram_2 sram_wrapper/u_sram_3 sram_wrapper/u_sram_4 sram_wrapper/u_sram_5]
foreach imem_name $memlist {
echo $imem_name
set_dont_touch_network [get_pins $imem_name/SO*]
}

二、collection

A collection is a group of objects exported to the Tcl user interface,你可以用add_to_collection、append_to_collection、remove_from_collection等命令来修改collection。在dc_shell中常由get_*产生,它的每一个元素里面包含很多属性。

代码如下(示例1):

set memcollection [get_cells * -hier -filter "ref_name=~ TS*ZHOCP"]
foreach_in_collection imem $memcollection {
echo $imem
set_dont_touch_network [get_pins $imem/SO*]
}

结果:Error:Can’t find object matching “_sel4247/SO*” in design “sram_wrapper”.
因为collection中的每个元素包含很多属性,直接使用会返回它的指针即“_sel*",如果要得到元素的名字,需要先用get_object_name得到它的名字。

正确代码如下(示例2):

set memcollection [get_cells * -hier -filter "ref_name=~ TS*ZHOCP"]
foreach_in_collection imem $memcollection {
set imem_name [get_object_name $imem]
echo $imem_name
set_dont_touch_network [get_cells $imem_name/SO*]
}

总结

集合的操作和列表是不一样的,列表可以直接echo显示,集合无法直接echo显示,直接echo会输出_sel;另外,列表使用foreach遍历,而集合使用foreach_in_collection来遍历。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值