Call DRC function in Ruby

Hi Sir,
I want to create a function in tool bar , and reference to other sample , I make that as below.
But , look like I can't call DRC functin in Ruby , May I know how to do that?

class MenuAction < RBA::Action
  def initialize( title, shortcut, &action ) 
    self.title = title
    self.shortcut = shortcut
    @action = action
  end
  def triggered 
    @action.call( self ) 
  end
private
  @action
end

$Check_bump_pitch = MenuAction.new( "Check min. bump pitch", "" ) do 

  app = RBA::Application.instance
  mw = app.main_window

  lv = mw.current_view
  if lv == nil
    raise "No view selected"
  end

ly = pya.CellView.active().layout()

# equivalent of "a = input(7, 0)"
layer_a = ly.layer(94, 0)
UBM = pya.Region(ly.top_cell().begin_shapes_rec(layer_a))


layer_b = ly.layer(71, 0)
DIE = pya.Region(ly.top_cell().begin_shapes_rec(layer_b))


############################################

ubmcount=0
UBM.each {
ubmcount +=1
}

############################################
minPitch=Array.new
x=0
LayerList=[[0.0,0.0,0.25,0.25],[0.0,0.25,0.25,0.5],[0.0,0.5,0.25,0.75],[0.0,0.75,0.25,1.0] \
                 ,[0.25,0.0,0.5,0.25],[0.25,0.25,0.5,0.5],[0.25,0.5,0.5,0.75],[0.25,0.75,0.5,1.0] \
                 ,[0.5,0.0,0.75,0.25],[0.5,0.25,0.75,0.5],[0.5,0.5,0.75,0.75],[0.5,0.75,0.75,1.0] \
                 ,[0.75,0.0,1.0,0.25],[0.75,0.25,1.0,0.5],[0.75,0.5,1.0,0.75],[0.75,0.75,1.0,1.0]]
LayerList.each { |n|
x1 = n[0].to_f
y1 = n[1].to_f
x2 = n[2].to_f
y2 = n[3].to_f

DIE.extent_refs(x1,y1,x2,y2).output(1000,x)
outline1=input(1000,x)
UBM.interacting(outline1).output(50000,x)
ubm1=input(50000,x)

outputdataX=Array.new
outputdataY=Array.new
pitchValue=Array.new

count=0
  ubm1.each do |obj|
  outputdataX << "#{obj.bbox.center.x.round(3)},#{obj.bbox.center.y.round(3)}"
  outputdataY << "#{obj.bbox.center.x.round(3)},#{obj.bbox.center.y.round(3)}"
 end  

 outputdataX.each do |out1|
 point1 = out1.split(",")
 xvalue1 = point1 [0]
 yvalue1 = point1 [1]

 outputdataY.each do |out2|
 point2 = out2.split(",")
 xvalue2 = point2 [0]
 yvalue2 = point2 [1]
 distance=Math.sqrt(( ( xvalue1.to_f - xvalue2.to_f ) *  ( xvalue1.to_f - xvalue2.to_f ))  +  (( yvalue1.to_f - yvalue2.to_f ) *  ( yvalue1.to_f - yvalue2.to_f ) ))
if distance > 0 then 
pitchValue << distance.round(3)
end
   end
 end 

minBumppitch = pitchValue.uniq.sort[0] 
minPitch << minBumppitch
#puts "Area #{x} ,min bump pitch is #{minBumppitch} ; layer is 50000/#{x}"
x+=1
}

RBA::MessageBox.info("min. Bump pitch", "The min. bump pitch is {minPitch.sort[0]}", RBA::MessageBox.b_ok)
end

app = RBA::Application.instance
mw = app.main_window

menu = mw.menu
menu.insert_separator("tools_menu.end", "name")
menu.insert_item("tools_menu.end", "Check_bump_pitch", $Check_bump_pitch)

Comments

  • You have to use RBA::Region instead of pya.Region. "pya" is Python, "RBA" is Ruby.

    Plus, creating the Region in Ruby is done by using "new":

    UBM = pya.Region(ly.top_cell().begin_shapes_rec(layer_a))
    

    I'd also recommend not to use upper-case variable names such as "UBM", because Ruby will treat these variables as constants.

    Regards,

    Matthias

  • Hi Matthias,
    After change the code as ..

    ly = RBA::CellView.active().layout()
    # equivalent of "a = input(7, 0)"
    layer_a = ly.layer(94, 0)
    ubm = RBA::Region(ly.top_cell().begin_shapes_rec(layer_a))
    
    
    layer_b = ly.layer(71, 0)
    die = RBA::Region(ly.top_cell().begin_shapes_rec(layer_b))
    

    I get error message as this one.
    how can I do to debug this issue?
    and , If it is a multi-top cell case , and I just want to process current cell view in script.
    how to do that?

  • In Ruby, you need to call "new" to create a new object. So it's

    ubm = RBA::Region::new(ly.top_cell().begin_shapes_rec(layer_a))
    

    in both places.

    Matthias

  • Hi Matthias,
    after change code as..

    ly = RBA::CellView.active().layout()
    currentcellview = RBA::CellView.active().cell()
    # equivalent of "a = input(7, 0)"
    layer_a = ly.layer(94, 0)
    ubm = RBA::Region::new(currentcellview.begin_shapes_rec(layer_a))
    layer_b = ly.layer(71, 0)
    die = RBA::Region::new(currentcellview.begin_shapes_rec(layer_b))
    

    I still get a message as attahced.
    Can you please help it ?
    Thanks.

  • Region#extent_refs is an undocumented method for use in DRC's "extent_refs" implementation. It expects the four relative dimension arguments plus an x and y oversize value. You can set these values to 0 in your case:

    DIE.extent_refs(x1,y1,x2,y2,0,0).output(1000,x)
    

    Matthias

  • @Matthias
    after change the code , it still get same result...

    class MenuAction < RBA::Action
      def initialize( title, shortcut, &action ) 
        self.title = title
        self.shortcut = shortcut
        @action = action
      end
      def triggered 
        @action.call( self ) 
      end
    private
      @action
    end
    
    $Check_bump_pitch = MenuAction.new( "Check min. bump pitch", "" ) do 
    
      app = RBA::Application.instance
      mw = app.main_window
    
      lv = mw.current_view
      if lv == nil
        raise "No view selected"
      end
    ly = RBA::CellView.active().layout()
    currentcellview = RBA::CellView.active().cell()
    # equivalent of "a = input(7, 0)"
    layer_a = ly.layer(94, 0)
    ubm = RBA::Region::new(currentcellview.begin_shapes_rec(layer_a))
    layer_b = ly.layer(71, 0)
    die = RBA::Region::new(currentcellview.begin_shapes_rec(layer_b))
    
    ############################################
    
    ubmcount=0
    ubm.each {
    ubmcount +=1
    }
    
    ############################################
    minPitch=Array.new
    x=0
    LayerList=[[0.0,0.0,0.25,0.25],[0.0,0.25,0.25,0.5],[0.0,0.5,0.25,0.75],[0.0,0.75,0.25,1.0] \
                     ,[0.25,0.0,0.5,0.25],[0.25,0.25,0.5,0.5],[0.25,0.5,0.5,0.75],[0.25,0.75,0.5,1.0] \
                     ,[0.5,0.0,0.75,0.25],[0.5,0.25,0.75,0.5],[0.5,0.5,0.75,0.75],[0.5,0.75,0.75,1.0] \
                     ,[0.75,0.0,1.0,0.25],[0.75,0.25,1.0,0.5],[0.75,0.5,1.0,0.75],[0.75,0.75,1.0,1.0]]
    LayerList.each { |n|
    x1 = n[0].to_f
    y1 = n[1].to_f
    x2 = n[2].to_f
    y2 = n[3].to_f
    
    die.extent_refs(x1,y1,x2,y2,0,0).output(1000,x)
    outline1=input(1000,x)
    ubm.interacting(outline1).output(50000,x)
    ubm1=input(50000,x)
    
    outputdataX=Array.new
    outputdataY=Array.new
    pitchValue=Array.new
    
    count=0
      ubm1.each do |obj|
      outputdataX << "#{obj.bbox.center.x.round(3)},#{obj.bbox.center.y.round(3)}"
      outputdataY << "#{obj.bbox.center.x.round(3)},#{obj.bbox.center.y.round(3)}"
     end  
    
     outputdataX.each do |out1|
     point1 = out1.split(",")
     xvalue1 = point1 [0]
     yvalue1 = point1 [1]
    
     outputdataY.each do |out2|
     point2 = out2.split(",")
     xvalue2 = point2 [0]
     yvalue2 = point2 [1]
     distance=Math.sqrt(( ( xvalue1.to_f - xvalue2.to_f ) *  ( xvalue1.to_f - xvalue2.to_f ))  +  (( yvalue1.to_f - yvalue2.to_f ) *  ( yvalue1.to_f - yvalue2.to_f ) ))
    if distance > 0 then 
    pitchValue << distance.round(3)
    end
       end
     end 
    
    minBumppitch = pitchValue.uniq.sort[0] 
    minPitch << minBumppitch
    x+=1
    }
    
    RBA::MessageBox.info("min. Bump pitch", "The min. bump pitch is {minPitch.sort[0]}", RBA::MessageBox.b_ok)
    end
    
    app = RBA::Application.instance
    mw = app.main_window
    
    menu = mw.menu
    menu.insert_separator("tools_menu.end", "name")
    menu.insert_item("tools_menu.end", "Check_bump_pitch", $Check_bump_pitch)
    
  • It does not work this way ... "output" isn't a method of the Region class. It's a DRC method. The (flat) equivalent is to insert the Region into a Shapes object like this:

    output_cell.shapes(output_layer_index).insert(region_to_output)
    

    Matthias

  • @mathine
    Thanks for your answer , I will check it.
    Do you have idea for how to make a cellS inputer?
    As this code , I can enter 1 cell in input only. how to make multi input ?(I have many cells need to process...)

    LayoutView = RBA::Application::instance.main_window.current_view.active_cellview.layout
    dialog = RBA::QDialog.new( RBA::Application.instance.main_window)
    dialog.windowTitle = "Creater"
    layout = RBA::QVBoxLayout::new(dialog)
    dialog.setLayout(layout)
    eachcells = LayoutView.each_cell
    die_list =Array.new()
    
    eachcells.each do |ly|
      die_list << ly.name
     end 
    
    label =  RBA::QLabel.new(dialog)
    layout.addWidget(label)
    label.text = "Choose DIE cell"
    dieCell =  RBA::QComboBox.new(dialog)
    die_list.each do |subcell|
    dieCell.addItem(subcell)
    end
    layout.addWidget(dieCell)
    dialog.exec
    
  • @jiunnweiyeh A QComboBox cannot be used to select multiple cells. You'll need a QListWidget for this (https://doc.qt.io/qt-5/qlistwidget.html).

    Matthias

Sign In or Register to comment.