Bisection of DRC checks to find min distance

This is a continuation of https://www.klayout.de/forum/discussion/1946 which kind of got hijacked for this topic. Yet I think it's an interesting topic, so I'll provide the solution here.

Goal is to find the minimum distance of shapes of a layer in DRC below a given maximum distance.

l1 = input(1, 0)

d = 5.0.um   # max distance

step = d * 0.5
while step >= 2.dbu do
  d -= step
  if l1.space(d).count == 0
    d += step
  end
  step *= 0.5
end 

# round down to DBU
d = (d / dbu).floor * dbu

puts "Min distance is #{'%.12g' % d}"

Matthias

Comments

  • Hi Matthias,

    Thanks for this cool script. B)
    I had to change "step >= 2.dbu" to "step >= 0.1.dbu" to display the correct values...

    Cheers,

    Tomas

Sign In or Register to comment.