LayerMapping

I'm wondering how can I use the layer mapping function in ruby script.
I have a GDS database (source: foundry A) want to map the layer to other GDS database (target: foundry B)
1. grep all layer from source
2. map for related layer to target
3. loop #1 & #2 until got all layer

Now I just finish #1. I got the correct info while "puts" the related source layer info.
The problem I met is I can't use create_full to map

def joFileWpath(filePath,file)  
    fileWpath = File.join(File.dirname(filePath+"/ruby.rb"),file)
    return fileWpath
end

module MyMacro

  include RBA

lo = LoadLayoutOptions::new
layout = Layout::new        # read the layout

if $gds_in
    gds_in = $gds_in        # user define of GDSII input file
else
    puts "You can input your gds file, (default: TOP_POLT.gds)"
    gds_in = "test.gds"     # default of GDSII input file
end

workDir = File.expand_path(File.dirname(__FILE__))
layout.read(joFileWpath(workDir+"/gdsii",gds_in),lo)
lm = LayerMapping::new

layer_indexes = layout.layer_indexes
lenOfLindex = layer_indexes.length
layer_indexes.sort{|a,b| a<=>b}.each do |indx|
    layer_info = layout.get_info(indx)
    puts "Layer:"+layer_info.to_s+";"+layer_info.layer.to_s+"\n"
    lm.create_full(70,0 , layer_info)                 # this is a test case only, layer:70; datatype:0, finally would change to variable 
end
end

Got the error if set 70,0 (layer & datatype)

Got the error if set 70 (layer only)

How can I map the layer from source to target??

Comments

  • I'd try another method to map layer & datatype, but I still can't find the correct command.
    The plot file like this:
    diff,1,0,10,0
    m1,7,0,11,0
    ....
    ....

    The new code as below:

    def joFileWpath(filePath,file)  
        fileWpath = File.join(File.dirname(filePath+"/ruby.rb"),file)
        return fileWpath
    end
    
    def readLines(filePath,file)    
        readFile = File.open(joFileWpath(filePath,file))
        readfileCon = readFile.readlines.map(&:chomp)
        readFile.close
        lenOfrf = readfileCon.length
        return readfileCon,lenOfrf
    end
    
    module MyMacro
    
      include RBA
    
    lo = LoadLayoutOptions::new
    layout = Layout::new        # read the layout
    
    if $gds_in
        gds_in = $gds_in        # user define of GDSII input file
    else
        puts "You can input your gds file, (default: TOP_POLT.gds)"
        gds_in = "test.gds"     # default of GDSII input file
    end
    
    if $plot_file
        plot_file = $plot_file      # user define of pcell list input file
    else
        puts "You can input your plotting file, (default: plotting.txt)"
        plot_file = "plotting.txt"  # default of plotting file input file
    end
    
    workDir = File.expand_path(File.dirname(__FILE__))
    layout.read(joFileWpath(workDir,gds_in),lo)
    lm = LayerMapping::new
    
    plotFile,lenOfPtF = readLines(workDir,plot_file)    # get a plotting file,length of plotting file
    
    layer_indexes = layout.layer_indexes
    lenOfLindex = layer_indexes.length
    layer_indexes.sort{|a,b| a<=>b}.each do |indx|
        layer_info = layout.get_info(indx)
        puts "Layer:"+layer_info.to_s+";"+layer_info.layer.to_s+"\n"
    
            m = 0
        while m < lenOfPtF
            plotFileList = plotFile[m].split(",")
            sL = plotFileList[1].to_s
            sD = plotFileList[2].to_s
            tL = plotFileList[3].to_s
            tD = plotFileList[4].to_s
    
            if sL == layer_info.layer.to_s && sD == layer_info.datatype.to_s
                layer_info.layer = tL       # How can I map target layer to source layer??
                layer_info.datatype = tD    # How can I map target datatype to source datatype??
            end 
    
            m += 1
        end
    
        #lm.create_full(70, layer_info)                 # this is a test case only, layer:70; datatype:0, finally would change to variable 
    end
    end
    
  • Hi,

    You code is basically just missing the "set_info" statement which sets the modified layer information after you have modified it:

    layout.set_info(indx, layer_info)
    

    But there is an easier way to achieve this: by setting a layer mapping on the reader options:

    lo = pya.LoadLayoutOptions()
    lm = pya.LayerMap()
    lm.map(pya.LayerInfo(1, 0), 0, pya.LayerInfo(10, 0, "diff"))
    lm.map(pya.LayerInfo(7, 0), 1, pya.LayerInfo(11, 0, "m1"))
    ...
    lo.layer_map = lm
    

    The "map" method maps an input layer to an output layer. The arguments are:

    • A LayerInfo object representing the source layer from your layout
    • A logical index. This is a number which you increment on each line starting from 0.
    • A LayerInfo object representing the layer under which the layer is stored in the layout

    Just use the "lo" object in "read" and your layers will be translated upon reading. No need to modify them later.

    Matthias

Sign In or Register to comment.