Step by Step Xsection

edited May 2018 in KLayout Support
Hey team,

Just to set the expectations, I'm new to KLayout as well as Ruby scripting. In my job role I have been tasked to see if there is a possibility to run the Xsection add-on available within KLayout to achieve a step by step processing of the layout. In other words stopping the "cmos.xs" (https://github.com/klayoutmatthias/xsection/blob/master/docs/cmos.xs) after every step like deposition or etch or Litho to look at the process flow step by step.

In the language of code:
Is there a way to execute the "output" command one by one, controlled by a user input? The user input is expected to click a button, where the button(I'm envisioning) could be a QtDialog box awaiting the user to click "Next". From my self guided learning on Ruby and the code it seems difficult because the whole Xsection is an event and cannot have "pause and play" kind functions.

Please excuse, if my question is unclear or if it is a repeat question. I did try to search the forums but couldn't find any thing similar.

Comments

  • edited November -1
    Hi Asharma:

    If you want to look at the mask output you first would have to execute the fab boolean operations on the layout. For this you would have to parse the boolean, and then combine layers into mask data. I think the functionality of stepping through the flow can be done after reading the use interface part of the KLayout reference.
    I used Python instead of Ruby because there is a free very high quality parser generator available (written by David Beazley).

    Also I used PyCharm as the IDE and drive KLayout with it. This is by far the fastest development environment for layout in the industry, since PyCharm is the by far best IDE (= Android Studio etc.). I think there may also be a Ruby plugin ...

    Cheers, Erwin
  • edited November -1

    Hi Asharma,

    In general, a cross-section script has to prepared differently when you want to show the process progress. The concept is currently to keep the computed material outline internally and visualize it in a final step. If you put the output statements in the right places, supply a "wait" function and patch the output function to allow overriding outputs, a simple solution can be implemented.

    This is an example for a modified .xs script which provides this feature:

    # patched version of the original output function which 
    # can be called multiple times. It will override the 
    # output already present.
    def output(layer_spec, layer_data)
    
      ls = string_to_layerinfo(layer_spec)
      li = @target_layout.layer(ls)
      shapes = @target_layout.cell(@target_cell).shapes(li)
      shapes.clear  # new feature
    
      # confine the shapes to the region of interest
      @ep.boolean_to_polygon([ RBA::Polygon.new(@roi) ], layer_data.data, RBA::EdgeProcessor::mode_and, true, true).each do |polygon|
        shapes.insert(polygon)
      end
    
    end
    
    # Shows a message box with the given message
    def wait(text)
    
      # Show all layers which were created in between
      RBA::Application.instance.main_window.cm_lv_add_missing 
      if @lyp_file
        @target_view.load_layer_props(@lyp_file)
      end
      @target_view.zoom_fit
    
      if RBA::QMessageBox::question(nil, "Continue", "#{text}\n\nPress Ok to continue", RBA::QMessageBox::Ok | RBA::QMessageBox::Cancel) != RBA::QMessageBox::Ok
        raise "XSection script interrupted"
      end
    
    end
    
    # ------------------------------------------------------------
    # Actual xs starts here:    
    
    # Prepare input layers
    layer_TRENCH = layer("2/0")
    layer_IMPLANT = layer("3/0")
    
    substrate = bulk
    output("1/0", substrate)
    wait("Substrate Step")
    
    # First epitaxial layer
    epi = deposit(0.5)
    output("2/0", epi)
    wait("Epi Step")
    
    # Second epitaxial layer
    epi2 = deposit(0.5)
    output("3/0", epi2)
    wait("Epi2 Step")
    
    # Etch substrate on mask with thickness 0.7µm and angle 30°
    mask(layer_TRENCH).etch(0.7, :taper => 30, :into => [substrate, epi, epi2])
    # Note that we output the layer once again to present the etched version 
    output("2/0", epi)
    output("3/0", epi2)
    wait("Etch Step")
    
    # Create an implant by growing the mask into the substrate material and both epitaxial layers.
    implant=mask(layer_IMPLANT).grow(0.2, 0.05, :mode => :round, :into => [substrate, epi, epi2])
    output("6/0", implant)
    wait("Implant Step")
    

    Regards,

    Matthias

  • edited May 2018
    @Erwin: thanks for your prompt feedback and suggestions. Unfortunately I'm not familiar with Python coding too and so starting over seems daunting. So for now I would like to stick with Ruby, especially since I could get Matthias suggestion to work.

    @Matthias: Thanks to you too for the work around, it worked like a charm! I was able to stick your modified "output" and accomplish what I had set out to do. Also I forgot to mention this in my first comment, a big thanks for creating the Xsection as a whole, since it is a savior for my team and we are heavily dependent on it. So keep up the awesome work.

    -Ankur
  • Hello @Matthias, I'm trying to use your method above, for step-by-step, having pasted your modified output and wait routines into my .xs script, but I'm hitting "undefined method `string_to_layerinfo' " for the relevant line of the new output function definition.

    What am I missing? Does xsection package have additional pre-requisites? Presently on KLayout .27.9 with only xsection 1.4 and examples 1.0 packages added.

    If I comment out the output function definition, and restart to lose the broken output, the wait() function works a treat

Sign In or Register to comment.