an unit bug for sized function in DRC

edited February 2014 in Ruby Scripting
Hi, Matthias:
I report a bug on the sized function in DRC script. The fucntion sized(value),value should be dbu or micron. I found it's free to use. Here is example:

###########code start #####################
width=[200,250,300]
space=[150,180,200,300]
poly=input("1/0")

tiles(0.1.mm) ## for 100um tiles
tile_border(5.0.um)## for 5um border

threads(4) ##use 4 CPU cores

##calculate space Perato
ss_old=poly
i=0
space.each do |space|
j=i+1
halfsize=space/2 ##for micron? or DBU??
halfsize=halfsize.to_i ## change to integer

## to pick space = 150,180,200,300 spaces groups ##
ss=poly.sized(halfsize).sized(-halfsize)
s=ss.not(ss_old)
layerSave="""S"+space.to_s+"nm (2/"+j.to_s+")""" ## to save layer (name(layer)) "Sxxxnm 2/j"
s.output(layerSave)
puts "space=#{space} nm done; save to #{layerSave}"
i+=1
ss_old=ss
end
puts "total #{i} space groups"
TotalSpace=i


##calculate width Perato
i=0
ss_old=poly
width.each do |width|
j=i+1
## caculate width as micron unit.

halfsizew=width.to_i/2000.0
halfsizew=halfsizew.to_f ## change to float
##pick width 0.2,0.25,0.3 groups
ss=poly.sized(-halfsizew).sized(halfsizew)
s=ss_old.not(ss)
layerSave=="""w"+width.to_s+"nm (3/"+j.to_s+")""" ## to save layer (name(layer)) "Wxxxnm 3/j"
s.output(layerSave)
puts"Width=#{width} nm done; save to #{layerSave}; halfsize #{halfsizew}um."
ss_old=s
i+=1
end
puts "Total #{i} width groups"
TotalWidth=i

##return no border
no_borders
flat

### free all memories
s=nil
ss=nil
ss_old=nil
poly=nil
GC.start ##Gabage Collection start
##########code end here###############################

I found that sized can access the 100, 200 DBU unit but also acess 0.18, 0.15 micron unit. Is it bug?

Thanks!
arided

Comments

  • edited February 2014

    Hi arided,

    well, actually the behaviour is intended.

    The implementation of "sized" and other functions which accept distance values is such:

    • If the value is a Float type, it is taken as micron units
    • If the value is a Fixnum type, it is takes as database units

    So basically, by using to_i, you fool the system :-)

    If you explicitly use units, you can avoid these issues. You can specify units also for variables, for example

    halfsize = 2
    layer.sized(-halfsize.um).sized(halfsize.um)
    

    But, I'd rather prefer the use of units with constants

    halfsize = 2.um
    layer.sized(-halfsize).sized(halfsize)
    

    Beware of the following:

    fullsize = 200   # supposed to be DBU?
    halfsize = fullsize * 0.5    # will convert to Float, hence interpretation is "micron"
    layer.sized(-halfsize).sized(halfsize)
    

    You can work around that by explicitly using ".dbu":

    fullsize = 200.dbu
    halfsize = fullsize * 0.5
    layer.sized(-halfsize).sized(halfsize)
    

    the latter works because ".dbu" actually converts to micron units (hence Float type).

    Matthias

  • edited November -1
    Hi, Matthias:
    Understood. Thank you!
    arided
Sign In or Register to comment.