Ejemplo n.º 1
0
def test_model_xyce(testmos):
    assert testmos.xyce(
    ) == '* .MODEL TESTMOS ElementaryDevice(D, G, S, B) PARAM1={1.0} PARAM2={2}'
    with set_context(testmos.parent):
        newmos = Model(name='newmos',
                       base='TESTMOS',
                       parameters={'param3': '3'})
    assert newmos.xyce(
    ) == '.MODEL NEWMOS TESTMOS PARAM1={1.0} PARAM2={2} PARAM3={3}'
Ejemplo n.º 2
0
def test_new_model():
    with pytest.raises(Exception):
        MyDevice = Model()
    with pytest.raises(Exception):
        MyDevice = Model(name='MyDevice')
    MyDevice = Model(name='MyDevice',
                     pins=['D', 'S'],
                     parameters={
                         'PARAM1': '1.0',
                         'PARAM2': '2'
                     })
Ejemplo n.º 3
0
def testmos():
    return Model(name='TESTMOS',
                 pins=['D', 'G', 'S', 'B'],
                 parameters={
                     'PARAM1': '1.0',
                     'PARAM2': '2'
                 })
Ejemplo n.º 4
0
def test_derived_model(testmos):
    with pytest.raises(Exception):
        MyDevice = Model(base=testmos)
    with pytest.raises(Exception):
        MyDevice = Model(name='MyDevice')
    with pytest.raises(Exception):
        MyDevice = Model(name='MyDevice',
                         base=testmos,
                         pins=['D', 'G'],
                         parameters={'PARAM1': '3'})
    with pytest.raises(Exception):
        MyDevice = Model(name='MyDevice',
                         base=testmos,
                         pins=['D', 'G'],
                         parameters={'PARAM1': '3'})
    MyDevice = Model(name='MyDevice', base=testmos, parameters={'PARAM1': '3'})
Ejemplo n.º 5
0
def test_derived_model_case_insensitivity(testmos):
    DerivedMOS = Model(name='DerivedMOS',
                       base=testmos,
                       parameters={'param1': 'nf*4'})
    assert DerivedMOS.name == 'DERIVEDMOS'
    assert DerivedMOS.base.name == 'TESTMOS'
    assert DerivedMOS.pins == ['D', 'G', 'S', 'B']
    assert DerivedMOS.parameters == {'PARAM1': 'NF*4', 'PARAM2': '2'}
Ejemplo n.º 6
0
def simple_circuit(TwoTerminalDevice, ThreeTerminalDevice, circuit):
    CustomDevice = Model(name='CustomDevice',
                         base=ThreeTerminalDevice,
                         parameters={'myparameter': 1})
    circuit.add(
        Instance(name='X1',
                 model=CustomDevice,
                 pins={
                     'A': 'NET1',
                     'B': 'in1',
                     'C': 'net01'
                 }))
    circuit.add(
        Instance(name='X2',
                 model=CustomDevice,
                 pins={
                     'A': 'NET2',
                     'B': 'in2',
                     'C': 'net02'
                 }))
    circuit.add(
        Instance(name='X3',
                 model=CustomDevice,
                 pins={
                     'A': 'NET3',
                     'B': 'NET1',
                     'C': 'NET1'
                 }))
    circuit.add(
        Instance(name='X4',
                 model=CustomDevice,
                 pins={
                     'A': 'NET3',
                     'B': 'NET1',
                     'C': 'NET2'
                 }))
    circuit.add(
        Instance(name='X5',
                 model=TwoTerminalDevice,
                 pins={
                     'A': 'net01',
                     'B': 'net00'
                 }))
    circuit.add(
        Instance(name='X6',
                 model=TwoTerminalDevice,
                 pins={
                     'A': 'net02',
                     'B': 'net00'
                 }))
    circuit.add(
        Instance(name='X7',
                 model=TwoTerminalDevice,
                 pins={
                     'A': 'NET3',
                     'B': 'net03'
                 }))
    return circuit
Ejemplo n.º 7
0
def test_derived_model(testmos):
    with set_context(testmos.parent):
        with pytest.raises(Exception):
            MyDevice = Model(base='TESTMOS')
        with pytest.raises(Exception):
            MyDevice = Model(name='MyDevice')
        with pytest.raises(Exception):
            MyDevice = Model(name='MyDevice',
                             base='TESTMOS',
                             pins=['D', 'G'],
                             parameters={'PARAM1': '3'})
        with pytest.raises(Exception):
            MyDevice = Model(name='MyDevice',
                             base='TESTMOS',
                             pins=['D', 'G'],
                             parameters={'PARAM1': '3'})
        MyDevice = Model(name='MyDevice',
                         base='TESTMOS',
                         parameters={'PARAM1': '3'})
Ejemplo n.º 8
0
def testmos(library):
    with set_context(library):
        model = Model(name='TESTMOS',
                      pins=['D', 'G', 'S', 'B'],
                      parameters={
                          'PARAM1': '1.0',
                          'PARAM2': '2'
                      })
        library.append(model)
        return model
Ejemplo n.º 9
0
def test_library_registration(library):
    with set_context(library):
        test = Model(
            name='TEST', prefix = 'M',
            pins=['D', 'G', 'S', 'B'],
            parameters={'W': 0, 'L': 0, 'NFIN': 1})
    library.append(test)
    assert any(x.name == 'TEST' for x in library)
    assert test.parent == library
    assert test.name == 'TEST'
Ejemplo n.º 10
0
def library():
    library = List[Model]()
    with set_context(library):
        model = Model(name='TESTMOS',
                      pins=['D', 'G', 'S', 'B'],
                      parameters={
                          'PARAM1': '1.0',
                          'PARAM2': '2'
                      })
    library.append(model)
    return library
Ejemplo n.º 11
0
def test_model_str_casting():
    '''
    Parameter values are stored as string internally
    (for model consistency)
    '''
    MyDevice = Model(name='MyDevice',
                     pins=['D', 'S'],
                     parameters={
                         'PARAM1': 1.0,
                         'PARAM2': 2
                     })
    assert MyDevice.parameters == {'PARAM1': '1.0', 'PARAM2': '2'}
Ejemplo n.º 12
0
def test_derived_model_new_parameters(testmos):
    DerivedMOS = Model(name='DERIVEDMOS',
                       base=testmos,
                       parameters={
                           'PARAM1': 'NF*6',
                           'PARAM3': 'NF*4'
                       })
    assert DerivedMOS.parameters == {
        'PARAM1': 'NF*6',
        'PARAM2': '2',
        'PARAM3': 'NF*4'
    }
Ejemplo n.º 13
0
def test_derived_model_new_parameters(testmos):
    with set_context(testmos.parent):
        DerivedMOS = Model(name='DERIVEDMOS',
                           base='testmos',
                           parameters={
                               'PARAM1': 'NF*6',
                               'PARAM3': 'NF*4'
                           })
    assert DerivedMOS.parameters == {
        'PARAM1': 'NF*6',
        'PARAM2': '2',
        'PARAM3': 'NF*4'
    }
Ejemplo n.º 14
0
def test_base_model_case_insensitivity():
    '''
    Everything should be converted to uppercase internally
        (SPICE is case-insensitive)
    '''
    MyDevice = Model(name='MyDevice',
                     pins=['d', 'S'],
                     parameters={
                         'PARAM1': 'nf*4',
                         'param2': '2'
                     })
    assert MyDevice.name == 'MYDEVICE'
    assert MyDevice.pins == ['D', 'S']
    assert MyDevice.parameters == {'PARAM1': 'NF*4', 'PARAM2': '2'}
Ejemplo n.º 15
0
def ThreeTerminalDevice():
    return Model(name='ThreeTerminalDevice',
                 pins=['A', 'B', 'C'],
                 parameters={'MYPARAMETER': '1'})
Ejemplo n.º 16
0
def TwoTerminalDevice():
    return Model(name='TwoTerminalDevice',
                 pins=['A', 'B'],
                 parameters={'MYPARAMETER': '3'})