TilingProcessor

Hello Matthias,

I'm looking into the TilingProcessor feature and came along your example:

layout = ... # the layout
cell = ... # the top cell's index
layout = ... # the input layer

class MyReceiver < RBA::TileOutputReceiver
  def put(ix, iy, tile, obj, dbu, clip)
    puts "got area for tile #{ix+1},#{iy+1}: #{obj.to_s}"
  end
end

tp = RBA::TilingProcessor::new

# register the custom receiver
tp.output("my_receiver", MyReceiver::new)
tp.input("the_input", layout.begin_shapes(cell, layer))
tp.tile_size(100, 100)  # 100x100 um tile size
# The script clips the input at the tile and computes the (merged) area:
tp.queue("_output(my_receiver, (the_input & _tile).area)")
tp.execute("Job description")

I would like to store the area values in an array instead of putting them to the console. I'm using a global variable to do this. Is this a good idea or is there a better way?

$tile_areas = []
...
class MyReceiver < TileOutputReceiver

          def put(ix, iy, tile, obj, dbu, clip)

            area = (obj*dbu**2).round(4)

            puts "Area for tile #{ix+1},#{iy+1}: #{area.to_s}"

            $tile_areas << [ix+1, iy+1, area]

          end # def

end # class

Cheers,

Tomas

Comments

  • Hi @tomas2004,

    Global variables are never good as you don't know if someone else creates a variable with the same name.

    Try collecting the values inside the receiver:

    class MyReceiver < TileOutputReceiver
    
      def initialize
        @tile_areas = []
      end
    
      # getter
      def tile_areas
         @tile_areas
      end
    
      def put(ix, iy, tile, obj, dbu, clip)
        area = (obj*dbu**2).round(4)
        @tile_areas << [ix+1, iy+1, area]
      end # def
    
    end # class
    
    ...
    receiver = MyReceiver::new
    tp.output("my_receiver", receiver)
    ...
    
    tile_areas = receiver.tile_areas 
    

    Matthias

  • Hello Matthias,

    Agreed, this looks way better :-)

    Cheers,

    Tomas

Sign In or Register to comment.