can we get the overlapping BBOX area for sub-level instance.

Hi sir,
This is my code , the working cell is "DIE_UBM"
As this code , I can get the information of first level instance .
How can I get more instance information of second level(UBM_0 in this case) or thrid level ?

celllayoutView = RBA::Application::instance.main_window.current_view.active_cellview.cell
data_base= (1 / dbu ).round(0)
x1=500*data_base
x2=-500*data_base
y1=500*data_base
y2=-500*data_base
iter = celllayoutView.each_overlapping_inst(RBA::Box::new(x1, y1, x2, y2)) 
count=0
iter.each do |inst|
locationx= (inst.cell_inst.trans.disp.x / data_base).round(3)
locationy= (inst.cell_inst.trans.disp.y / data_base).round(3)
puts "the instance cell is #{inst.cell.name} , location is :#{locationx} and #{locationy}"
count+=1
end
puts "final counts : #{count}"

another question is , how to using overlapping shape ? in this code,
I can't get the each shape in the area BBox I maked.
I knew the document shown that...
(1) Signature: [const,iter] Shape each_overlapping_shape (unsigned int layer_index, const Box box, unsigned int flags)
Description: Iterates over all shapes of a given layer that overlap the given box
flags:
An "or"-ed combination of the S.. constants of the Shapes class
box:
The box by which to query the shapes
layer_index:
The layer on which to run the query
But , the question is ...what is "Flags"? do you have an example for the full command ?

ubm_index=0
layoutView = RBA::Application::instance.main_window.current_view.active_cellview.layout
  layoutView.layer_indexes.each do |layer_index|
  layer_info = layoutView.get_info(layer_index)
  if layer_info.to_s.match("94/0") then
  puts "The #{layer_index} mapping to #{layer_info}"
  ubm_index=layer_info
  end
 end

celllayoutView = RBA::Application::instance.main_window.current_view.active_cellview.cell
data_base= (1 / dbu ).round(0)
x1=500*data_base
x2=-500*data_base
y1=500*data_base
y2=-500*data_base
iter = celllayoutView.each_overlapping_shape(ubm_index,RBA::Box::new(x1, y1, x2, y2)) 
count=0
iter.each do |inst|

count+=1
end

puts "final counts : #{count}"

Comments

  • edited December 2023

    Hi jiunnweiyeh

    To get information for Inst in deeper hierarchy, you might need to use begin_instances_rec_overlapping instead of each_overlapping_inst, following example should able to provide the info you need.

    cellView = RBA::Application::instance.main_window.current_view.active_cellview
    cell     = cellView.cell
    dbu      = cellView.layout.dbu
    iter     = cell.begin_instances_rec_overlapping(RBA::DBox::new(-500, -500, 500, 500)) 
    count    = 0
    
    while !iter.at_end?
        name   = iter.inst_cell.name
        x      = iter.inst_dtrans.disp.x 
        y      = iter.inst_dtrans.disp.y
        count += 1
        puts "the instance cell is #{name} , location is :#{x} and #{y}"
        iter.next
    end
    puts "final counts : #{count}"
    

    Similar for shapes, if you like to list out all shapes use begin_shapes_rec_overlapping instead of each_overlapping_shapes.

  • Hi @RawrRanger
    in this code , can I choose how deep for the instance level ?
    that like this ...
    in the below , I can choose how deep cell I can get ...start from 0 to level 10.

    dbTraverse -cv $OpenCV -layer $cmp_layName -purpose $cmp_purName -startLevel 0 -stopLevel 10

  • edited December 2023

    Hi jiunnweiyeh

    cell.begin_instances_rec_overlapping returns a RecursiveInstanceIterator
    which contains it's hier info from your current view cell to the end.

    Following example provides the hier depth infor counting from current view cell, please notice this is a reletive depth level instead of a actual hier level if you are not viewed from a top cell.

    iter.path returns a list of instElements [<InstElement xxx>, <InstElement xxx>, <InstElement xxx>], the length of the list is it's reletive level from view cell.

    def InstInfo(box, levels = [])
        cellView = RBA::Application::instance.main_window.current_view.active_cellview
        cell     = cellView.cell
        layout   = cellView.layout
        dbu      = layout.dbu
        iter     = cell.begin_instances_rec_overlapping(box) 
        lvCount  = {}
    
        while !iter.at_end?
            name   = iter.inst_cell.name
            x      = iter.inst_dtrans.disp.x 
            y      = iter.inst_dtrans.disp.y
            level  = iter.path.length() + 1
            hier   = iter.path.each.map{|ie| layout.cell(ie.cell_inst.cell_index).name}.insert(0, cell.name).append(name)
            #hier is to show the relation between view cell, can be removed.
    
            if levels.include?(level) or levels == []
                puts "Cell: #{name}\t @(#{'%.3f'% x},#{'%.3f'% y})\t @level #{level}\t #{hier})"
                lvCount[level] = lvCount.include?(level) ? lvCount[level] + 1 : 0
            end
    
            iter.next
        end
        puts lvCount.sort.map{|l| "Level : #{l[0]} Counts: #{l[1]}"}
    end
    
    box = RBA::DBox::new(-500, -500, 500, 500)
    InstInfo(box, levels = [])
    #levels list [1, 3, 5] only shows insts in level 1, 3, and 5
    #levels list [0..5] to show all insts from level 0~5
    #leave empt to show all insts
    
Sign In or Register to comment.