Exemple #1
0
    def register_device(circuit: SpiceCircuit, d: pya.Device):
        """
        Create a SPICE instance of the device `d` and add it to the `circuit`.
        :param circuit: PySpice circuit to add the device.
        :param d: KLayout device.
        :return:
        """
        device_class = d.device_class()

        # Map terminal names to nets
        terminal_map = {
            tdef.name: d.net_for_terminal(tdef.id())
            for tdef in device_class.terminal_definitions()
        }

        # Get net names at terminals
        ds1, gate, ds2 = [
            get_net_name(terminal_map[terminal_name])
            for terminal_name in ['S', 'G', 'D']
        ]

        # parameter_defs = device_class.parameter_definitions()

        assert device_class.name(
        ) in device_class_name_to_model_mapping, "Unknown device class name: {}".format(
            device_class.name())

        model = device_class_name_to_model_mapping[device_class.name()]

        length = d.parameter('L')
        width = d.parameter('W')
        area_drain = d.parameter('AD')
        area_source = d.parameter('AS')

        # Get net of body if defined. Otherwise create a new floating net.
        bulk = terminal_map.get('B', None)

        if bulk is None:
            if default_bulk_net == 'floating':
                bulk = temp_net_name()
            elif isinstance(default_bulk_net, dict):
                bulk = default_bulk_net[device_class.name()]

        # TODO: parameters AS, AD
        circuit.M(
            "{}".format(d.id()),
            ds1,
            gate,
            ds2,
            bulk,
            model=model,
            width=width @ u_um,
            length=length @ u_um,
        )
Exemple #2
0
skidl_M['d', 'g', 's', 'b'] += net_1, net_2, net_3, net_4
skidl_circ = generate_netlist()
print(skidl_circ)

# In[34]:

pyspice_circ = Circuit('')
pyspice_circ.M('1',
               'N1',
               'N2',
               'N3',
               'N4',
               model=5,
               m=5,
               l=5,
               w=5,
               drain_area=5,
               source_area=5,
               drain_perimeter=5,
               source_perimeter=5,
               drain_number_square=5,
               source_number_square=5,
               off=5,
               temp=5)
print(pyspice_circ)

# In[35]:

netlist_comp_check(skidl_circ, pyspice_circ)

# | N            | Numerical device for GSS                             |