Start klayout from command line and review drc results

edited February 2018 in Ruby Scripting

Dear klayout-experts,
The following script works perfect if I add -b to run a batch execution.

But now I would like to keep the GUI open to review the results inside klayout.

Reason is that I run KL through an ipc channel in another tool providing 2 gds file names I'd like to xor.

I tried several ways to provide a script to klayout to start the exceution in GUI mode.

Any idea is highly appriciated.

Thanks in advance,
Andy

# Batch run:                       klayout -b -r test.drc -rd gds1=a.gds -rd gds2=b.gds 
# GUI open but closed at the end:  klayout    -r test.drc -rd gds1=a.gds -rd gds2=b.gds 
l1 = source($gds1)
l2 = layout($gds2)
layers = []
[ l1, l2 ].each do |l|
  l.layout.layer_indices.each do |index|
    info = l.layout.get_info(index)
    layers << [info.layer, info.datatype ]
  end
end
# collect layers
layers.sort.uniq.each do |l,d|
  log "Running XOR between #{l}/#{d} .."
  (l1.input(l, d) ^ l2.input(l, d)).output(l, d)
end

Comments

  • edited November -1

    Hi,

    here is a version which will display the results in a third layout:

    # prelude: load the two layouts and prepare an output layout
    app = RBA::Application::instance
    app.main_window.load_layout($gds1, 2)
    app.main_window.load_layout($gds2, 2)
    app.main_window.create_layout(2)
    view = RBA::LayoutView::current
    output_cv = RBA::CellView::active
    
    # do the XOR (use @1 and @2 for the first and second layout loaded
    # and @3 for the third as output)
    
    l1 = source("@1")
    l2 = layout("@2")
    target("@3")
    
    layers = []
    [ l1, l2 ].each do |l|
      l.layout.layer_indices.each do |index|
        info = l.layout.get_info(index)
        layers << [info.layer, info.datatype ]
      end
    end
    # collect layers
    layers.sort.uniq.each do |l,d|
      log "Running XOR between #{l}/#{d} .."
      (l1.input(l, d) ^ l2.input(l, d)).output(l, d)
    end
    
    # finish the output by adding the layer views and selecting the top cell
    view.add_missing_layers
    output_cv.cell = output_cv.layout.top_cell
    
    # run the application - this will show the UI
    app.exec
    

    Run this script the same way you described ("klayout -r test.drc ..." without -b).

    Matthias

  • edited November -1
    Hello Matthias,

    Thanks for your update, I got it up and running as expected by the designer.
    Also congrats to the new release. With the major improvments introduced in 0.25x Klayout becomes an even more outstanding SW - Thanks for this.

    Best Regards,
    Andy
  • Matthias,

    I have tried to modify your script to select the cells but my syntax is not accepted, although you suggest it in another post.
    Where is my mistake ?

    # Batch run:                       klayout -b -r test.drc -rd gds1=a.gds -rd gds2=b.gds -rd cell1=cell_a -rd cell2=cell_b
    # GUI open but closed at the end:  klayout    -r test.drc -rd gds1=a.gds -rd gds2=b.gds -rd cell1=cell_a -rd cell2=cell_b 
    #
    # prelude: load the two layouts and prepare an output layout
    app = RBA::Application::instance
    app.main_window.load_layout($gds1, 2)
    app.main_window.load_layout($gds2, 2)
    app.main_window.create_layout(2)
    view = RBA::LayoutView::current
    output_cv = RBA::CellView::active
    
    # do the XOR (use @1 and @2 for the first and second layout loaded
    # and @3 for the third as output)
    
    l1 = source("@1", $cell1)
    l2 = layout("@2", $cell2)
    target("@3")
    
    layers = []
    [ l1, l2 ].each do |l|
        l.layout.layer_indices.each do |index|
            info = l.layout.get_info(index)
            layers << [info.layer, info.datatype ]
        end
    end
    # collect layers
    layers.sort.uniq.each do |l,d|
        log "Running XOR between #{l}/#{d} .."
        (l1.input(l, d) ^ l2.input(l, d)).output(l, d)
    end
    
    # finish the output by adding the layer views and selecting the top cell
    view.add_missing_layers
    output_cv.cell = output_cv.layout.top_cell
    
    # run the application - this will show the UI
    app.exec
    

    Laurent

Sign In or Register to comment.