using Region and Empty Layer in DRC

Hi there!

Hi! I'm a beginner with klayout and im still learning how to program with DRCs.

I've been running into some interesting issues when I'm trying to iterate through each individual shapes using DRC

like the example below, say for layer 10 you got some sort of circle and it isnt very big, but I find the out put of the result would somewhat alter the cordinate of the input shape. It would round it to the nearest integer. I wonder is there a way to make the result to be normal and not rounded?

I do notice that in region it autometically convert the Dpolygon in layers into just a polygon, and I think when you convert a dpolygon into polygon it would round the cordinate, I wonder is there a way to make it not do that, or is there something similar that I could use can avoid this type of issue

L10 = input(10).raw
someRandomRegion = RBA::Region::new()
checkingResultLayer = polygon_layer

L10.each{|someRandomShape| someRandomRegion.insert(RBA::DPolygon::new(someRandomShape))}
someRandomRegion.each{|someRandomShape| checkingResultLayer.insert(RBA::DPolygon::new(someRandomShape))}

checkingResultLayer.output(103, 0)

So with what is it above I decided to try something else, instead of putting the shape into an empty region, I decided to put them into layers and do my operation, but I was encountered with another error

Sorry this piece of code is very very rough, and really diffcult to read, it was mixed with nested functions and gloable varibles, I'm doing all sort of things that that I'm not suppose to do(by the time I wrote this code I didn't know that the capital letter in ruby means constant, so thats why it was global, it also sort of stayed that way since the nested function and stuff)

The code is a bit easy to read if you read the parts that has been comment out, it doesn't have all the nested function and stuff, the reason I did the nested function is because the I thought the error i encountered has something to do with the loop,.

Here is the idea of how this piece code suppose to work and what I'm trying to do

  • A giant for loop iterate through each shape of layer 10
  • for each shape in layer 10, put that one shape into a new layer
  • for each small shape that has been covered by that individual shape, expend that small shape
  • use that expended shape and minus the original one shape that was putted into the new layer
  • collect what's left over and gater it into a result layer
  • after all shape is intereated through from layer 10, return result layer
def getSomeHoles(lay10, lay60)

    #creating some variables
    #
    $aALayer = polygon_layer
    $releaseHoleLayer = polygon_layer
    $resultLayer = polygon_layer


    def innerFuc(polygon)
      $newPolyLayer = polygon_layer
      $newPolyLayer.insert(polygon)

      def innerInFuc(eachHole)
        bigHole = eachHole.sized(100.um)
        $newPolyLayer = $newPolyLayer - bigHole
      end

      $releaseHoleLayer.inside($newPolyLayer).each{|holes| innerInFuc(holes)}
      $newPolyLayer.each{|resultPiece| resultLayer.insert(resultPiece)}
    end



    lay10.each{|bigAA| $aALayer.insert(bigAA)}
    lay60.each{|holes| $releaseHoleLayer.insert(holes)}
    $aALayer.each{|asds| innerFuc(asds)} #********* Error*********


    #aALayer.each do |bigPolygon|
      #newPolyLayer = polygon_layer
      #newPolyLayer.insert(bigPolygon)

      #releaseHoleLayer.inside(newPolyLayer).each do |singleReleaseHole|
        #bigHole = singleReleaseHole.sized(100.um)
        #newPolyLayer = newPolyLayer - bigHole
      #end
    #newPolyLayer.each{|resultPiece| resultLayer.insert(resultPiece)}
    #end
  return $resultLayer
end

When you try to run this code, it would throw an error at the part where it says #********* Error*********
it would say that $aALayer is not a DRC layer and there fore it doesn't have the .each thing, but when I print it out, it does say
$aAlayer is a DRC layer and I don't know what went wrong. however if I use .each{|stuff| exampleLayer.insert(stuff)} it would not complain
so, I wonder is it possible to do what I want on DRC or do I have to bring it to the python scripting in order to achieve my goal.

Thank you very much!
Andy Wang

Comments

  • Hi Andy,

    I don't get the details, but there are a few things to say:

    • You should not confuse DRC with scripting. DRC works with layers, script work with objects.
    • "Region" is a script object and can only hold integer-unit polygons. When you insert a DPolygon which is micrometer units, you have to transform it into integer-units based on a database unit (basic grid). The preferred way is to use a transformation:
    from_dbu = RBA::CplxTrans(dbu)
    to_dbu = RBA::CplxTrans(dbu).inverted
    
    dpoly = ... # a DPolygon object
    ipoly = to_dbu * dpoly   # an integer-unit Polygon object
    dpoly = from_dbu * ipoly   # the reverse
    
    • Variables prefixed with "$" are global variables in Ruby. Do no use them here. Use function arguments. This makes you code readable.
    • If you say you get an error, please tell me which one.

    Matthias

  • edited April 11

    Hi Matthias

    Thank you very much! the dbu one would help me out a lot, also the error I got says Arguement needs to be a DRC layer(class run time error)

    That happens when I try to insert stuff into layers

    thank you ver much!

    Andy

Sign In or Register to comment.