Size of final GDS file

Hello, I am creating GDS document based on DXF drawings. The document is a palette of many small drawings (N by M) and I tried generating such GDS in two ways: (1) generate palette DXF and then convert to GDS and (2) convert each small DXF into GDS and merge them into single GDS.

In second case the size of my final GDS document is about 8-9 times larger than for the first case. Can someone please suggest why is that so?
XOR shows no difference between them, cells lists are also identical.

save layout options: no empty cells and gds2_max_vertex_count 200

thank you

Comments

  • Difficult to say without more details, but here is one guess: if the DXF you build the palette from share blocks (= cells in GDS), then in the first case, this blocks are only imported once while in the second case they are imported once for each small DXF. So they may effectively be multiplied many times.

    Matthias

  • Hi Matthias, thanks for the reply. I think you have got the point. Indeed, in the DXF palette I have many shared blocks. But how this works for GDS? Do you mean that my nested cells are copied but not shared, right? Is there way to do something after GDS is generated?

  • edited March 2022

    I suggest using OASIS instead of GDSII. OASIS results in much smaller file sizes. GDSII is outdated. I only convert my OASIS to GDSII at the final step when my counterpart needs GDSII. Cleaning up the GDSII after the fact is technically possible but usually not being done. Instead, everyone I know uses at least gzip compression of the GDSII for smaller file size.

  • edited March 2022

    @ejprinz thanks for the hint, I will try to dig it more. So far I tried to save to OASIS format with compression 10 and the size shrinked only slightly.

    @Matthias , you were right about nested cells. In my generated from single drawings GDS I have many nested cells with following names:
    Parent_cell 1
    - Child_cell
    Parent_cell 2
    - Child_cell$2

    So I am saving many copies of the same cells. I need to figure out how to avoid that.
    I tried using "from_names_full" method for pya.CellMapping() and it keeps only unique cells in the final drawing but in single quantity. In other words, If two cells share subcell, only first one will actually has it. Is there way to make it right? Looks like there should be something around CellMapping...

    Ok, I found your topic related to that issue:
    https://github.com/KLayout/klayout/issues/639

    Here is my function I am using to insert source layout into self one:

    def _insert(self, source: pya.Layout, *, position: Tuple[float, float] = (0.0, 0.0)):
        """Insert Layout object to given position"""
        # create destination cell
        target_cell = self._layout.create_cell(source.top_cell().name)
    
        # insert destination cell under top cell with respect to coordinate transition
        self._top_cell.insert(
            pya.CellInstArray(
                target_cell.cell_index(),
                pya.Trans(
                    pya.Point(
                        float(position[0]) / self._layout.dbu, float(position[1]) / self._layout.dbu
                    )
                ),
            )
        )
    
        # create cell mapping
        mapping = pya.CellMapping()
        mapping.from_geometry_full(
            self._layout, target_cell.cell_index(), source, source.top_cell().cell_index()
        )
    
        # copy shapes from source cell
        self._layout.copy_tree_shapes(source, mapping)
    

    from_geometry_full gives me all nested cells copied while for_multi_cells_full creates empty cells without anything nested.

  • @alexlpn

    If you want to share child cells, you cannot separate the copy into multiple calls, but you have to specify multiple source cells plus multiple target cells in the same call to "copy_tree_shapes".

    I guess however this is difficult here. I understand that you have multiple input layouts. How can these share a child cell? Multiple layouts cannot share the same object. They may use the same name for a child cell, but that is not the same object. Only if you have one layout with multiple source cells you can use "for_multi_cells_full". In that case you have to specify a list of cell indexes for source and target.

    I understand that you want to recombine different cells which carry the same name (hence you assume they are identical). Be careful with such an assumption! If you are really, really sure that all cells with identical names are really the same thing, you can load multiple layout files into the same object and use a special "cell conflict resolution" mode to reuse cells with the same name. But be careful: KLayout does not check if these cells are really identical:

    ly = pya.Layout()
    
    options = pya.LoadLayoutOptions()
    options.cell_conflict_resolution = pya.LoadLayoutOptions.SkipNewCell
    
    ly.read("file1.gds", options)
    ly.read("file2.gds", options)
    ...
    

    this will give you a new layout with multiple top cells - one for each file read (provided the input files have a single top cell).

    Matthias

  • @Matthias

    thank you for this advice. I tried to load my layouts in this way, and indeed all top level cells are now have their subcells of the same names, also file size shrinked significantly. However, this does not give me palette of my cells since there is no single top cell. When I tried to move tree of each cell under single top cell, I got the same result - all subcells renamed and size is now back to initial value.

    I remember your comment about cell library. Can you give me some example how I can create and fill such library and then change subcell instances by instances from such library? Does it sound like a solution (I will keep only unique cells inside library and swap them as soon as same name subcell arises)

  • edited March 2022

    Sorry, I do not fully understand what you are doing. Could you share your code please?

    After reading the files into a single layout, of course you have multiple top cells. But you can take this single layout and start constructing the single palette top cell from of these cells.

  • @Matthias , you are right, that is what I am trying to do (take this single layout and start constructing the single palette top cell from of these cells) but don't know actually how. What is the proper way to create empty top level cell and move all cells under it?
    Thank you for your support anyway!

  • Well, it's already in your code above. You don't need to do the copy_tree_shapes step, because you can read the partial layouts already into the target layout. The trick is to use the SkipNewCell option and do multiple reads into the same layout object. Please note my disclaimer.

    I don't know the way you want to build the palette. Apparently you have some positions. That's why I am asking for some sample code.

    Matthias

Sign In or Register to comment.