Dynamic PCell Parameter Update/Refresh

edited October 2014 in Ruby Scripting
First, sorry, I am a Ruby Newby so this might be a very simply question. I have been trying to find a way to create a PCell within a PCell. Mainly, I am building some test structures that I would like to vary the pad sizes and I would like to print those pad sizes on the test structure (using the TEXT PCell). I am trying to transition from Cadence to KLayout (I realize that Klayout has a static repository and I might need to do something like in post: http://klayout.de/forum/comments.php?DiscussionID=475&page=1#Item_0). My main problem is that in cadence I could do a cellname->? and it would list the variables within that cell. So, it has been difficult for me to find the variable that holds the text parameter to update. The nearest I have been able to find is: http://klayout.de/forum/comments.php?DiscussionID=230 With some finagling I have been able to dynamically change the PCell in this but I have to close out the gds file and then reopen it for the update to work but it won't let me do the truck of the ly = RBA::CellView::active.layout ly.each_cell { |cell| cell.refresh } of the first aforementioned post to update the instances. It even makes me close and then reopen the gds file on the first instantiation of the PCell. Any help would be greatly appreciated!

Comments

  • edited November -1

    Hi,

    creating PCell instances inside PCell's is not beginners level ... that is actually quite advanced.

    First of all, KLayout was not designed with PCell placement automation in mind. First goal was to provide parametrized cells for the layouter.

    It is possible to create PCell instances. However, if you instantiate a PCell inside a PCell you're basically calling layout production code from your code and in the end that is equivalent to including the code directly. Or in other words: your code may be more efficient, maintainable and reliable if you build yourself a Ruby module producing the texts and include that code in your PCell rather that create PCell instances.

    And you're not correct - KLayout does not have a static repository. Normally, it should not be required to call the refresh method. It is required if you change a library externally or if you change the code of the PCell. But not under normal conditions. Everthing else I'd consider a bug.

    And yes, I know, KLayout is not Cadence. I'm not a billion dollar company. I can't tailor a language to my requirements. I have to take what I get and Ruby is in many respects a very good choice. So, no "->?". On the other hand, I've seen a so much Skill code working around limitations of Skill which you won't need in Ruby, simply because you get it for free.

    If you want to know the parameters of library, here is a little script that lists the visible and writable parameter names:

    RBA::Library::library_names.each do |lib_name|
    
      puts "PCell's of library #{lib_name}:"
    
      lib = RBA::Library::library_by_name(lib_name)
    
      layout = lib.layout
    
      # workaround: missing iterator for PCell's
      pcell_id = 0
      while pcell_decl = layout.pcell_declaration(pcell_id)
    
        puts "    " + pcell_decl.name
    
        puts "      Parameters:"
        pcell_decl.get_parameters.each do |pd|
          (pd.hidden? || pd.readonly?) || puts("         #{pd.name} - #{pd.description}")
        end
    
        pcell_id += 1
    
      end
    
    end
    

    I can't give more support than that without knowing your code. Specifically if you claim to be new to Ruby it's important to provide sample code so I can check the implementation.

    Matthias

Sign In or Register to comment.