Is there a way to merge and "blend" two hierarchies?

I'm interested to blend two hierarchies, meaning that rather than creating duplicate hierarchies, and shapes on layers from the second design would be added into the same cell of the first design if it already existed. To "blend" this way would be distinctly different from adding de-duped cell names or merging with overwrite as there would be a minimal final hierarchy with no loss of data from either source.

If used ill advisedly it might result in duplicate shapes, but a classic example would be pulling back together a hierarchy in all layers from stream files each containing only subsets of layers. It could be implementing by blend option opening or importing, or a blend option when copying cells containing hierarchy.

Apologies if I missed something, if it's already been addressed?


  • I've observed klayout (like many other tools) will
    auto-number-append same-named cells if you
    pull them into an existing database. This is a
    good thing because you don't know a priori that
    two same-named cells from two databases are
    in fact the same, content-wise.

    Now if you knew that was the case, you'd see
    stuff like nand2 and nand2_1 in the cell browser
    and you might just undertake to search & replace
    either manually or by script. I've got nothing for
    you, on scripting. But I could imagine someone
    making a useful point-tool, which might let you
    populate a "translation table" for "cell name is"
    and "cell name should be", and semi-automate
    the name-cleaning. Whether you'd really want to
    delegate the decision to a script unsupervised,
    I kind of doubt (or, only after making sure you
    know your two feed-stocks are in fact harmonious).

    I suppose that it would be possible to do some
    sort of cell-identical-ness check (maybe simple XOR?)
    and turn a script loose on the task of replacing all
    found-identical instances of any master, into one
    that you select as the go-to. And then it ought to be
    possible to "rack 'em up" and crush the number of
    identical but differently named cells. Like all those
    pesky auto-named vias.

  • Thanks for the suggestions and comments. My case in point is reconstructing a single hierarchical design when essentially the same design has been streamed into layer subsets from multiple databases in a foreign design system. In this case, appending shapes and layers into cells, or creating new cells where they don't already exist, is all that's needed to reestablish a proper hierarchy that pulls together the specific combinations.

    I've seen one commercial tool offering such a "blend" mode of merging, as opposed to "add" (de-duping by name appends) or "merge" (overwriting), so the requirement is clearly not unique to me, but the licence is prohibitive for what may be a single use.

    Maybe I should call this "combine"? In my example, or in the commercial version I saw, perhaps the only downside is you might end up with multiple coincident shapes if you combine files contain the same layers and the same cells.

  • Dear all,

    thanks for this discussion. It's actually hitting the point.

    But: "Blending" will not just blend the shapes but also instances. So consider you have a hierarchy "A->B->C" (C is child cell of B, B of A) and blend the same hierarchy again, you'll see "A->B2->C2" which means C turns up 4 times on the same location! Carry this on to further levels and you'll see an exponential growth of redundant instances.

    Hence I don't recommend this mode in your specific case. In the UI you can use "File/Import Other Files into current" to merge in a smarter way (hierarchy mapping). In a script, the recommended way is to load every part in one layout and use "Cell#copy_tree" to transfer the shapes.


Sign In or Register to comment.