CustomResistorExtraction: show faulty device in GUI

Hello,
I use a CustomResistorExtraction based on:

 def extract_devices(layer_geometry)

    # layer_geometry provides the input layers in the order they are 
    # defined with "define_layer"
    # conductor is supposed to be "conductor outside marker"
    # resistor is supposed to be "conductor inside marker"
    conductor = layer_geometry[0]
    resistor  = layer_geometry[1]

    # the index of the conductor layer (needed to make the terminals)
    conductor_geometry_index = 0

    resistor_merged = resistor.merged

    # this will be the edge where the resistor turns into conductor
    marker_edges = conductor.merged.edges & resistor_merged.edges

    resistor_merged.each do |r|

      # identify the edges where this resistor shape ends
      interface_edges = marker_edges.interacting(RBA::Region::new(r))

      # form terminal shapes from these edges
      terminals = interface_edges.extended_out(1)

      if terminals.size != 2
        error("Resistor shape does not touch marker border in exactly two places", r)
      else

        # A = L*W
        # P = 2*(L+W)
        # -> L = p+sqrt(p*p-A)
        # -> W = p-sqrt(p*p-A)
        # (p=P/4)

        p = 0.25 * r.perimeter
        a = r.area

        d = Math.sqrt(p * p - a)
        l = p + d
        w = p - d

        if w > 1e-3

          device = create_device
          device.set_parameter(RBA::DeviceClassResistor::PARAM_R, @sheet_rho * l / w);
          define_terminal(device, RBA::DeviceClassResistor::TERMINAL_A, conductor_geometry_index, terminals[0]);
          define_terminal(device, RBA::DeviceClassResistor::TERMINAL_B, conductor_geometry_index, terminals[1]);

        end

      end

    end

  end

The errors ("Resistor shape does not touch marker border in exactly two places") are logged. But how can I zoom to the faulty device?
If I click on a log error it's zooms always near 0,0 and shows the polygon there.
How can I zoom to the faulty device?

Steffen

Comments

  • edited January 27

    If you know -why- the device is "faulty" then I'd presume
    you could write a regular DRC rule to highlight the feature.

    Of course there are many ways to die, and you may find
    that this will "churn" your DRC deck ongoing as discoveries
    are made and traps, laid.

    DRC checks for extract rule "blockers" are a done thing.

    In the past I have seen some decks contain numerous
    "malformed" checks. Especially if the kit allows freehand
    device drawing, not "PCells or p!ss off". But even a good
    PCell placement could be munged by a stray polygon
    that breaks the logic.

  • Hi @Dunkelwind,

    I agree with @dick_freebird that you should first target a clean layout through DRC coverage. "bad devices" should be detected by DRC in the first place.

    Still, the "error" feature should work. Maybe the resistor is in a sub cell and it is not highlighted properly (e.g. subcell coordinates are shown in the top cell)?

    I need to spend some time creating a proper testcase before I can tell if that is a bug or not.

    Matthias

  • I can confirm there is a bug. It's not related to hierarchy. I have created a ticket here: https://github.com/KLayout/klayout/issues/1608

    Matthias

  • Thanks for pointing out the use of DRC.
    But when I debug my CustomExtractor, it would be good to find the faulty device. My idea was also that the extractor normalizes the shapes around 0,0.

  • Actually the extractor normalizes the shape, but the display is wrong. The marker needs to be moved back to the original location.

    I have fixed that now (-> see issue above). During the testing I found a small bug in the resistor extraction code above:

      def extract_devices(layer_geometry)
        # layer_geometry provides the input layers in the order they are defined with "define_layer"
        conductor = layer_geometry[0]
        resistor  = layer_geometry[1]
    
        resistor_regions = resistor.merged
    
        resistor_regions.each do |r|
          # BUGFIX: each polygon needs to be checked separately, so we build a new Region from r:
          terminals = conductor.interacting(RBA::Region::new(r))
          if terminals.size != 2
            error("Resistor shape does not touch marker border in exactly two places", r)
          else
            double_width = 0
            (terminals.edges & resistor.edges).merged.each do |e|
              double_width += e.length
            end
            # A = L*W
            # -> L = A/W
            a = r.area*dbu*dbu
            w = (double_width / 2.0)*dbu
            l = a / w
    
            device = create_device
            device.set_parameter(RBA::DeviceClassResistor::PARAM_R, @sheet_rho * l / w);
    
            device.set_parameter(RBA::DeviceClassResistor::PARAM_A, a)
            device.set_parameter(RBA::DeviceClassResistor::PARAM_L, l)
            device.set_parameter(RBA::DeviceClassResistor::PARAM_P, 2*l+2*w)
            device.set_parameter(RBA::DeviceClassResistor::PARAM_W, w)
            define_terminal(device, "A", "C", terminals[0]);
            define_terminal(device, "B", "C", terminals[1]);
          end
        end
      end
    

    Without this fix, buggy devices are not found if they are attached directly to good ones.

    Matthias

Sign In or Register to comment.