It looks like you're new here. If you want to get involved, click one of these buttons!
Hi Mattias,
Based on your example in
http://klayout.de/forum/comments.php?DiscussionID=293
I modified your code, to output the oas file only when the two gds files are not XOR clean.
However even for the same oas files, the final 'out.oas' file will still be generated.
Can you please help to take a look?
Many thanks!
LW
# Save as "xor.drc" and run with:
# klayout -b -r xor.drc -rd gds1=a.gds -rd gds2=b.gds -rd out=out.gds
#
# Useful options:
#
# * verbose log:
# verbose
#
# * enable tiling:
# tiles(1.mm, 1.mm)
#
# * use 4 cores in parallel (with tiles):
# threads(4)
#
l1 = layout($gds1)
l2 = layout($gds2)
$xor_result = 0
layers = []
[ l1, l2 ].each do |l|
l.layout.layer_indices.each do |index|
info = l.layout.get_info(index)
layers << [info.layer, info.datatype ]
end
end
layers.sort.uniq.each do |l,d|
log "Running XOR between #{l}/#{d} .."
if l1.input(l, d) ^ l2.input(l, d)
$xor_result = 1
end
end
puts [$xor_result]
if $xor_result == 1
target($out)
# collect layers
layers.sort.uniq.each do |l,d|
log "Running XOR between #{l}/#{d} .."
(l1.input(l, d) ^ l2.input(l, d)).output(l, d)
end
end
Comments
The correct usage should be:
- if l1.input(l, d) ^ l2.input(l, d)
+ unless is_empty?(l1.input(l, d) ^ l2.input(l, d))
Maybe the overhead in layer object is different even if the two layers are same.
Thanks!
LW
Hi werk,
A boolean operation returns a layer object and that is never false in Ruby. The method to test whether a layer is empty is
is_empty?
. So this should work:Another remark: please don't use global variables (like
$xor_result
). The file names have to be global since they are specified externally. But internal variables can be local, so simplyxor_result
is better.Regards,
Matthias