It looks like you're new here. If you want to get involved, click one of these buttons!
Hi sir ,
in our team , we not only need to know if the case is out of rule , but we also need what the min. value of out rule issue is.
below is what my code , as you can see , I make a DRC check in first , then let it export result and re-load it into programming to sort and get min value.
But it is not smare way due to we have to run this code 2 times.
in first time, DRC function export the text data.
in second time , using this code to read the text data and get min. value.
do you have another way or smart function to get the same result?
#############################################
def dis(a1x,a1y,b1x,b1y)
distance=(((a1x-b1x)**2 + (a1y-b1y)**2)**0.5).round(3)
return distance
end
############################################
def disMin(a1x,a1y,a2x,a2y,c1x,c1y)
distanceR=((c1x-a1x)*(a2x-a1x) + (c1y-a1y)*(a2y-a1y)) / ((a1x-a2x)**2 + (a1y-a2y)**2)
if distanceR <= 0 then
return dis(a1x,a1y,c1x,c1y)
else
return dis(a2x,a2y,c1x,c1y)
end
end
###############rule for width check#################
def readFile_getdis(filename)
gap=0.05
dataR= Array.new()
dataC=Array.new()
realdata=Array.new()
IO.foreach(filename) {
|block|
if block.split(":")[0]==" <value>edge-pair" then
realdata << (block.split(":")[1].split("<")[0]).gsub('(',"").gsub(')',"").gsub('/','|')
dataZ = (block.split(":")[1].split("<")[0]).gsub('(',"").gsub(')',"").gsub('/','|')
dataZ_E1=dataZ.split("|")[0]
dataZ_E2=dataZ.split("|")[1]
dataZ_E1P1=dataZ_E1.split(";")[0]
dataZ_E1P2=dataZ_E1.split(";")[1]
dataZ_E2P1=dataZ_E2.split(";")[0]
dataZ_E2P2=dataZ_E2.split(";")[1]
dataZ_E1P1x=dataZ_E1P1.split(",")[0].to_f
dataZ_E1P1y=dataZ_E1P1.split(",")[1].to_f
dataZ_E1P2x=dataZ_E1P2.split(",")[0].to_f
dataZ_E1P2y=dataZ_E1P2.split(",")[1].to_f
dataZ_E2P1x=dataZ_E2P1.split(",")[0].to_f
dataZ_E2P1y=dataZ_E2P1.split(",")[1].to_f
dataZ_E2P2x=dataZ_E2P2.split(",")[0].to_f
dataZ_E2P2y=dataZ_E2P2.split(",")[1].to_f
value1=disMin(dataZ_E1P1x,dataZ_E1P1y,dataZ_E1P2x,dataZ_E1P2y,dataZ_E2P1x,dataZ_E2P1y)
value2=disMin(dataZ_E1P1x,dataZ_E1P1y,dataZ_E1P2x,dataZ_E1P2y,dataZ_E2P2x,dataZ_E2P2y)
if value1 > gap then
dataC << value1
end
if value2 > gap then
dataC << value2
end
end
#############################################################
}
min_value_dataC=dataC.min
puts "min. value is #{min_value_dataC}"
end
##################################################################################
layoutlibrary = RBA::Application::instance.main_window.current_view.active_cellview.name
rulefile="D:\\rulefile.txt"
ubm=input(94,0)
ruleE=26 ##Check space
report("rulechecker",rulefile)
ubm.space(ruleE.micron,projection).output("RuleE")
if File.exist?(rulefile) then
minvalueE=readFile_getdis(rulefile)
end
Comments
Hi jiunnweiyeh
Because you request to dump DRC results to a file so the file will be occupied by DRC engine until the script is completed finished, which blocks the
readFile_getdis
from accessing the contents.The way to avoid this is actually simple, since the space check DRC already provides a
EdgePairs
object, contains all the data required for this distiance calculation so we can drop the text parsing completely.The
readFile_getdis
anddisMin
can be combined into this:Hi @RawrRanger,
thanks for bringing this up. I noticed that on C++ level, the edge pairs have a distance property, but not on Python or Ruby level. I will add this implementation to the API.
The C++ implementation computes the distance in a slightly different way, but in normal cases, the results should be same.
Best regards,
Matthias
Hi @RawrRanger
Thanks , it is workable.
Here is my code for reference .
Hi @RawrRanger
May I know what the function for "distance_abs"?
Yes , I knew that wording should be check what the distance between first / sencond.
But when I usnig code as below to double confirm the distance .
dist1 , using distnace_abs function ,
distance_fp1sp1 , using (((X1-X2)^2+(Y1-Y2)^2))^0.5 to do the cacaulator.
I got difference answer...
by the way , I am using Klayout 0.28.12
sorry for code typo , I update it as below.
But , same issue I got.. the distance_abs result didn't match with real data.
hi sir, sorry , the code should be update as below.
But same issue,
dist1 , using distnace_abs function ,
distance_fp1sp1 , using (((X1-X2)^2+(Y1-Y2)^2))^0.5 to do the cacaulator.
I got difference answer.
Hi jiunnweiyeh
The
abs_distance
provided from edge returns a minimum distance between point and given line which extends to infinity. Dependes on use case, you will need to add some conditions check to get what you want.Here's an example of running result of different
min
dist extraction methodMethod-1 : use
edge.abs_distance
only, which does not always get correct results.Method-2 : use 4 vertiex from edge pair to find distance, which only works for certain cases.
Method-3 : combine the concept of both case, dilivers the correct results.
Both method-1 and 2 failed on case-2 for different reasons. Case-2 returns 2 error

EdgePairs
EP1 and EP2The checked distance is marked in black double arrow.
Method-1

Check
Edge
fromEdgePair
to points on another sides, the issue of this method is theabs_distance
returns distance of aPoint
toEdge
EXTENDED line. additional condition check is required to get good results.Method-2

Check distance of four corner and not actual
Edge
topoint
distance.Method-3

Check
Point
toEdge
relation, if point is in direct projection range of theEdge
, useabs_distance
, otherwise returnsPoint
to closestEdge.Point
distance.Example as below, this compares three method with 5um spacing check test case, test case gds is as attached.
Hi @RawrRanger
Thanks very much for your help , look like it is what I need.
But in my case , the method 1/3 will get 0..
I need to check what is better way in my side.
Thanks your hard work.
Here I have some modify , just a little difference..
hope this will be helpful for everyone.
I have just released version 0.28.14 where EdgePair features a method "distance". It will return the minimum distance between every two points on edge 1 and 2.
It is based on the definition of an euclidian distance of a point from an edge:
The minimum distance is either the distance of one of the points of edge 1 against edge 2 or vice versa.
The C++ implementation is this:
Matthias
Hi sir,
1 issue need your help for DRC function.
In bumping house , we usually using "circle" or "oval(track)" pattern for UBM layer (Under Bump metal )
that always not a regular shape like suqare or octagon.
Yes, that is similar to PCB...not only using a track shape , we also rotate it.....
as what the programming /code in space .
sometimes that can't find the min. space between edge to edge in this case.
Look like that programming wants to checking where the out of rule in pattern edge (shift to on grid )
to another edge(shift to on grid).
As below ( this is a Hyperbole picture , just to shown what I means)
so that will cause the DRC result have little shift (compare with what the real space)around 0.05um.
(in fact , I didn't know what the gap is , I just base on current pattern to guess that)
Is any possible way to avoid this gap or make it as shrink /little /reduce as possible?
Hi jiunnweiyeh,
I've adjust the Min distance code based on Matthias suggestion, the only difference I've made is this section in
epDistance
.this length check exist is to avoid the zero distance issue you've mensioned in previous post, which I found is triggered by
Edge
inEdgePair
having length that is 0, in this case the edge to edge calculation is no longer suitable and returns point to point distance instead.Example code as below, test cased as attached, return result : 49.729um

(without checking length, result will be 0um)
Regarding to the DRC display accuracy issue you've mentioned, this only affects the final display showed on screen
following example runs a space check on a 4um space object, the result is accurate, but the display result have an offset of 1 dbu on each side.
DRC EdgePair printed out by function :
(6.5,-5;6.5,5) (2.5,2.5;2.5,-2.5)
DRC result from property window
(6.501, -5.001) (2.499, -2.501) (2.499, 2.501) (6.501, 5.001)
This I think this offset might be implemented on purpose to make display result of small/slim object have better visibility.
The way to avoid this is actually simple:
Hi @RawrRanger
Thanks very much for your help , I will base on that code to check and building mind.
Thanks.
@jiunnweiyeh and @RawRanger
Version 0.28.14 now has the
EdgePair#distance
attribute. Maybe you would like to try this.Best regards,
Matthias
@Matthias,
OK, got it , I will try 0.28.14 version and the function of EdgePair .
Thanks.