def buildSimulations(self):
     print('Building Simulations')
     simName = projName = 'Short'
     print(simName)
     tdrsim = siapp.SignalIntegrityAppHeadless()
     tdrsim.OpenProjectFile('TDRSimulation.si')
     self.setRefProperty(tdrsim, 'V1', 'gain', self.g1)
     self.setRefProperty(tdrsim, 'V2', 'gain', self.g2)
     self.setRefProperty(tdrsim, 'DUT', 'file', simName + '.si')
     self.setRefProperty(tdrsim, 'VG1', 'a', self.V1)
     self.setRefProperty(tdrsim, 'VG2', 'a', self.V2)
     tdrsim.SaveProjectToFile('TDRSimulation' + simName + '.si')
     simName = projName = 'Open'
     print(simName)
     tdrsim = siapp.SignalIntegrityAppHeadless()
     tdrsim.OpenProjectFile('TDRSimulation.si')
     self.setRefProperty(tdrsim, 'V1', 'gain', self.g1)
     self.setRefProperty(tdrsim, 'V2', 'gain', self.g2)
     self.setRefProperty(tdrsim, 'DUT', 'file', simName + '.si')
     self.setRefProperty(tdrsim, 'VG1', 'a', self.V1)
     self.setRefProperty(tdrsim, 'VG2', 'a', self.V2)
     tdrsim.SaveProjectToFile('TDRSimulation' + simName + '.si')
     simName = projName = 'Load'
     print(simName)
     tdrsim = siapp.SignalIntegrityAppHeadless()
     tdrsim.OpenProjectFile('TDRSimulation.si')
     self.setRefProperty(tdrsim, 'V1', 'gain', self.g1)
     self.setRefProperty(tdrsim, 'V2', 'gain', self.g2)
     self.setRefProperty(tdrsim, 'DUT', 'file', simName + '.si')
     self.setRefProperty(tdrsim, 'VG1', 'a', self.V1)
     self.setRefProperty(tdrsim, 'VG2', 'a', self.V2)
     tdrsim.SaveProjectToFile('TDRSimulation' + simName + '.si')
     simName = 'Thru'
     projName = simName + '1'
     print(simName)
     tdrsim = siapp.SignalIntegrityAppHeadless()
     tdrsim.OpenProjectFile('TDRSimulation.si')
     self.setRefProperty(tdrsim, 'V1', 'gain', self.g1)
     self.setRefProperty(tdrsim, 'V2', 'gain', self.g2)
     self.setRefProperty(tdrsim, 'DUT', 'file', simName + '.si')
     self.setRefProperty(tdrsim, 'VG1', 'a', self.V1)
     self.setRefProperty(tdrsim, 'VG2', 'a', 0.0)
     tdrsim.SaveProjectToFile('TDRSimulation' + projName + '.si')
     simName = 'Thru'
     projName = simName + '2'
     print(simName)
     tdrsim = siapp.SignalIntegrityAppHeadless()
     tdrsim.OpenProjectFile('TDRSimulation.si')
     self.setRefProperty(tdrsim, 'V1', 'gain', self.g1)
     self.setRefProperty(tdrsim, 'V2', 'gain', self.g2)
     self.setRefProperty(tdrsim, 'DUT', 'file', simName + '.si')
     self.setRefProperty(tdrsim, 'VG1', 'a', 0.0)
     self.setRefProperty(tdrsim, 'VG2', 'a', self.V2)
     tdrsim.SaveProjectToFile('TDRSimulation' + projName + '.si')
 def testPowerDelivery(self):
     proj = siapp.SignalIntegrityAppHeadless()
     proj.OpenProjectFile('PowerDelivery.si')
     res = proj.Simulate()
     vgnames = res[0]
     onames = res[1]
     TM = res[2][0]
     V = [[None], [None]]
     V[vgnames.index(
         'VG1')][0] = (-1 + random() * 2.) + 1j * (-1 + random() * 2.)
     V[vgnames.index(
         'VG2')][0] = (-1 + random() * 2.) + 1j * (-1 + random() * 2.)
     b = [v[0] for v in (array(TM).dot(array(V))).tolist()]
     A1 = b[onames.index('A1')] / sqrt(50.)
     A2 = b[onames.index('A2')] / sqrt(50.)
     B1 = b[onames.index('B1')] / sqrt(50.)
     B2 = b[onames.index('B2')] / sqrt(50.)
     V1 = b[onames.index('V1')]
     V2 = b[onames.index('V2')]
     I1 = b[onames.index('I1')]
     I2 = b[onames.index('I2')]
     pvi = V1 * I1.conjugate() + V2 * I2.conjugate()
     pab = abs(A1) * abs(A1) + abs(A2) * abs(A2) - abs(B1) * abs(B1) - abs(
         B2) * abs(B2)
     A = array([[A1], [A2]])
     B = array([[B1], [B2]])
     pab2 = (A.conj().T.dot(A) - B.conj().T.dot(B)).tolist()[0][0]
     self.assertAlmostEqual(pvi, pab, 12, 'power delivered incorrect')
     self.assertAlmostEqual(pvi, pab2, 12, 'power delivered incorrect')
     pass
예제 #3
0
 def EyePattern(project, waveform, delay, bitrate):
     import numpy as np
     import SignalIntegrity.App as siapp
     app = siapp.SignalIntegrityAppHeadless()
     app.OpenProjectFile(project)
     (_, outputWaveformLabels, _, outputWaveformList) = app.Simulate()
     prbswf = outputWaveformList[outputWaveformLabels.index(waveform)]
     ui = 1. / bitrate
     times = prbswf.Times()
     timesInBit = [((t - delay) / 3. / ui - int(
         (t - delay) / 3. / ui)) * 3. * ui for t in times]
     from PIL import Image
     R = 400
     C = 600
     EyeWfCols = [int(t / 3. / ui * C) for t in timesInBit]
     EyeWfRows = [int((v + 0.3) / 0.6 * R) for v in prbswf.Values()]
     bitmap = [[0 for c in range(C)] for _ in range(R)]
     for i in range(len(EyeWfRows)):
         bitmap[EyeWfRows[i]][
             EyeWfCols[i]] = bitmap[EyeWfRows[i]][EyeWfCols[i]] + 1
     maxValue = (max([max(v) for v in bitmap]))
     bitmap = [[
         int((maxValue - float(bitmap[r][c])) / maxValue * 255.0)
         for c in range(C)
     ] for r in range(R)]
     img = Image.fromarray(
         np.squeeze(np.asarray(np.matrix(bitmap))).astype(np.uint8))
     img.save(waveform + '.png')
예제 #4
0
 def testEqualizerFit(self):
     app=siapp.SignalIntegrityAppHeadless()
     app.OpenProjectFile(os.path.realpath('../../SignalIntegrity/App/Examples/PRBSExample/PRBSTest.si'))
     (_,outputWaveformLabels,_,outputWaveformList)=app.Simulate()
     prbswf=outputWaveformList[outputWaveformLabels.index('Vdiff')]
     H=prbswf.td.H; bitrate=5e9; ui=1./bitrate
     dH=int(H/ui)*ui-56e-12+ui
     lastTime=prbswf.Times()[-1]
     dK=int((lastTime-ui-dH)/ui)
     decwftd=si.td.wf.TimeDescriptor(dH,dK,bitrate)
     decwf=si.td.wf.Waveform(decwftd,[prbswf.Measure(t) for t in decwftd.Times()])
     os.chdir(os.path.dirname(os.path.realpath(__file__)))
     self.m_fitter=EqualizerFitter(self.PrintProgress)
     self.m_fitter.Initialize(decwf,[-0.25,-0.1667/2.,0.1667/2.,0.25],1,1)
     self.m_fitter.Solve()
     results=self.m_fitter.Results()
     print(results)
     reggressionFile=self.NameForTest()+'.txt'
     if not os.path.exists(reggressionFile):
         resultFile2=open(reggressionFile,'w')
         resultFile2.write(str(results))
         resultFile2.close()
         self.assertTrue(False,reggressionFile+ ' not found')
     with open(reggressionFile,'rU' if sys.version_info.major < 3 else 'r') as f:
         fitRegression=[[float(e)] for e in f.readline().replace(']','').replace('[','').split(',')]
     for (res,reg) in zip(results,fitRegression):
         self.assertAlmostEqual(res[0], reg[0], 5, 'equalizer fit failed')
def ZeroForcingEqualizer(project, waveform, bitrate, value, pre, taps):
    import SignalIntegrity.App as siapp
    from numpy import array
    from numpy.linalg import inv
    app = siapp.SignalIntegrityAppHeadless()
    app.OpenProjectFile(project)
    (_, outputWaveformLabels, _, outputWaveformList) = app.Simulate()
    pulsewf = outputWaveformList[outputWaveformLabels.index(waveform)]
    delay = pulsewf.td.TimeOfPoint(pulsewf.Values().index(max(
        pulsewf.Values())))
    print('delay: ' + str(delay))
    H = pulsewf.td.H
    ui = 1. / bitrate
    startTime = delay - (int((delay - H) / ui) - 1) * ui
    endTime = delay + (int((pulsewf.Times()[-1] - delay) / ui - 1) * ui)
    M = int((endTime - startTime) / ui + 0.5)
    d = int((delay - startTime) / ui + 0.5)
    x = [pulsewf.Measure(startTime + m * ui) for m in range(M)]
    X = [[0 if r - c < 0 else x[r - c] for c in range(taps)] for r in range(M)]
    r = [[value] if r == d + pre else [0] for r in range(len(X))]
    a = [
        v[0] for v in (inv((
            array(X).T).dot(array(X))).dot(array(X).T).dot(array(r))).tolist()
    ]
    print('results: ' + str(a))
예제 #6
0
 def testZZZZDoThisLast(self):
     proj = siapp.SignalIntegrityAppHeadless()
     self.assertTrue(proj.OpenProjectFile('TDRModel.si'))
     proj.Device('N1')['vrms']['Value'] = 6e-6
     proj.Device('N2')['vrms']['Value'] = 6e-6
     proj.Device('N3')['vrms']['Value'] = 6e-6
     proj.Device('N4')['vrms']['Value'] = 6e-6
     proj.SaveProjectToFile('TDRModel.si')
 def testMixedModeConversion(self):
     import SignalIntegrity.App as siapp
     pysi = siapp.SignalIntegrityAppHeadless()
     pysi.OpenProjectFile('MixedMode.si')
     netlist = [
         line.replace(' file None', '')
         for line in pysi.Drawing.schematic.NetList().Text()
     ]
     sd = si.p.SystemDescriptionParser().AddLines(
         netlist).SystemDescription()
     sd.AssignSParameters('MM1', si.dev.MixedModeConverter())
     sd.AssignSParameters('MM2', si.dev.MixedModeConverter())
     ssps = si.sd.SystemSParametersSymbolic(sd, size='small')
     ssps.DocStart().LaTeXSolution().DocEnd().WriteToFile('mixedmode.tex')
예제 #8
0
 def EqualizerFit(project,waveform,delay,bitrate):
     import SignalIntegrity.App as siapp
     import SignalIntegrity.Lib as si
     app=siapp.SignalIntegrityAppHeadless()
     app.OpenProjectFile(project)
     (_,outputWaveformLabels,_,outputWaveformList)=app.Simulate()
     prbswf=outputWaveformList[outputWaveformLabels.index(waveform)]
     H=prbswf.td.H; ui=1./bitrate
     dH=int(H/ui)*ui-delay+ui; lastTime=prbswf.Times()[-1]; dK=int((lastTime-ui-dH)/ui)
     decwftd=si.td.wf.TimeDescriptor(dH,dK,bitrate)
     decwf=si.td.wf.Waveform(decwftd,[prbswf.Measure(t) for t in decwftd.Times()])
     os.chdir(os.path.dirname(os.path.realpath(__file__)))
     fitter=EqualizerFitter()
     fitter.Initialize(decwf,[-0.25,-0.1667/2.,0.1667/2.,0.25],1,1)
     fitter.Solve()
     print(fitter.Results())
예제 #9
0
 def testAAAADoThisFirst(self):
     proj = siapp.SignalIntegrityAppHeadless()
     self.assertTrue(proj.OpenProjectFile('TDRModel.si'))
     proj.Device('N1')['vrms']['Value'] = 0.0
     proj.Device('N2')['vrms']['Value'] = 0.0
     proj.Device('N3')['vrms']['Value'] = 0.0
     proj.Device('N4')['vrms']['Value'] = 0.0
     proj.SaveProjectToFile('TDRModel.si')
     if self.deleteCache:
         import glob
         # Get a list of all cached files
         fileList = glob.glob('*_cache*')
         # Iterate over the list of filepaths & remove each file.
         for filePath in fileList:
             try:
                 os.remove(filePath)
             except:
                 print("Error while deleting file : ", filePath)
    def DoSimulation(self):
        resDict = TestTDRErrorTermsTest.resDict
        if not resDict is None:
            return
        self.buildSimulations()
        resDict = {}
        print('S-Parameters')
        simName = 'Gamma1'
        print(simName)
        projName = simName + '.si'
        spProj = siapp.SignalIntegrityAppHeadless()
        spProj.OpenProjectFile(projName)
        (sp, name) = spProj.CalculateSParameters()
        resDict[simName] = sp
        simName = 'Gamma2'
        print(simName)
        projName = simName + '.si'
        spProj = siapp.SignalIntegrityAppHeadless()
        spProj.OpenProjectFile(projName)
        (sp, name) = spProj.CalculateSParameters()
        resDict[simName] = sp
        simName = 'Fixture1'
        print(simName)
        projName = simName + '.si'
        spProj = siapp.SignalIntegrityAppHeadless()
        spProj.OpenProjectFile(projName)
        (sp, name) = spProj.CalculateSParameters()
        resDict[simName] = sp
        simName = 'Fixture2'
        print(simName)
        projName = simName + '.si'
        spProj = siapp.SignalIntegrityAppHeadless()
        spProj.OpenProjectFile(projName)
        (sp, name) = spProj.CalculateSParameters()
        resDict[simName] = sp
        simName = 'Thru'
        print(simName)
        projName = simName + '.si'
        spProj = siapp.SignalIntegrityAppHeadless()
        spProj.OpenProjectFile(projName)
        (sp, name) = spProj.CalculateSParameters()
        resDict[simName] = sp
        simName = 'Short'
        print(simName)
        projName = simName + '.si'
        spProj = siapp.SignalIntegrityAppHeadless()
        spProj.OpenProjectFile(projName)
        (sp, name) = spProj.CalculateSParameters()
        resDict[simName + '1'] = sp.PortReorder([0])
        resDict[simName + '2'] = sp.PortReorder([1])
        simName = 'Open'
        print(simName)
        projName = simName + '.si'
        spProj = siapp.SignalIntegrityAppHeadless()
        spProj.OpenProjectFile(projName)
        (sp, name) = spProj.CalculateSParameters()
        resDict[simName + '1'] = sp.PortReorder([0])
        resDict[simName + '2'] = sp.PortReorder([1])
        simName = 'Load'
        print(simName)
        projName = simName + '.si'
        spProj = siapp.SignalIntegrityAppHeadless()
        spProj.OpenProjectFile(projName)
        (sp, name) = spProj.CalculateSParameters()
        resDict[simName + '1'] = sp.PortReorder([0])
        resDict[simName + '2'] = sp.PortReorder([1])
        print('TDR Simulations')
        tdrsim = siapp.SignalIntegrityAppHeadless()
        simName = projName = 'Short'
        tdrsim.OpenProjectFile('TDRSimulation' + simName + '.si')
        print(simName)
        (sourceNames, outputWaveformLabels, transferMatrices,
         outputWaveformList) = tdrsim.Simulate()
        resDict.update(
            dict(
                zip([simName + label for label in outputWaveformLabels],
                    outputWaveformList)))
        tdrsim = siapp.SignalIntegrityAppHeadless()
        simName = projName = 'Open'
        tdrsim.OpenProjectFile('TDRSimulation' + simName + '.si')
        print(simName)
        (sourceNames, outputWaveformLabels, transferMatrices,
         outputWaveformList) = tdrsim.Simulate()
        resDict.update(
            dict(
                zip([simName + label for label in outputWaveformLabels],
                    outputWaveformList)))
        simName = projName = 'Load'
        tdrsim.OpenProjectFile('TDRSimulation' + simName + '.si')
        print(simName)
        (sourceNames, outputWaveformLabels, transferMatrices,
         outputWaveformList) = tdrsim.Simulate()
        resDict.update(
            dict(
                zip([simName + label for label in outputWaveformLabels],
                    outputWaveformList)))
        projName = 'Thru'
        simName = projName + '1'
        print(simName)
        tdrsim.OpenProjectFile('TDRSimulation' + simName + '.si')
        (sourceNames, outputWaveformLabels, transferMatrices,
         outputWaveformList) = tdrsim.Simulate()
        resDict.update(
            dict(
                zip([simName + label for label in outputWaveformLabels],
                    outputWaveformList)))
        projName = 'Thru'
        simName = projName + '2'
        print(simName)
        tdrsim.OpenProjectFile('TDRSimulation' + simName + '.si')
        (sourceNames, outputWaveformLabels, transferMatrices,
         outputWaveformList) = tdrsim.Simulate()
        resDict.update(
            dict(
                zip([simName + label for label in outputWaveformLabels],
                    outputWaveformList)))
        print('converting TDR')
        self.tdr = si.m.tdr.TDRWaveformToSParameterConverter(Step=False,
                                                             fd=self.fd)

        cs = si.m.calkit.CalibrationKit(f=self.fd)

        resDict['Short1Measurement'] = self.tdr.RawMeasuredSParameters(
            resDict['ShortV1'])
        resDict['Short2Measurement'] = self.tdr.RawMeasuredSParameters(
            resDict['ShortV2'])
        resDict['Open1Measurement'] = self.tdr.RawMeasuredSParameters(
            resDict['OpenV1'])
        resDict['Open2Measurement'] = self.tdr.RawMeasuredSParameters(
            resDict['OpenV2'])
        resDict['Load1Measurement'] = self.tdr.RawMeasuredSParameters(
            resDict['LoadV1'])
        resDict['Load2Measurement'] = self.tdr.RawMeasuredSParameters(
            resDict['LoadV2'])
        resDict['ThruMeasurement'] = self.tdr.RawMeasuredSParameters(
            [[resDict['Thru1V1'], resDict['Thru1V2']],
             [resDict['Thru2V1'], resDict['Thru2V2']]])

        resDict['CalibrationTDR'] = si.m.cal.Calibration(
            2, self.fd, [
                si.m.cal.ReflectCalibrationMeasurement(
                    resDict['Short1Measurement'].FrequencyResponse(1, 1),
                    cs.shortStandard, 0, 'Short1'),
                si.m.cal.ReflectCalibrationMeasurement(
                    resDict['Open1Measurement'].FrequencyResponse(1, 1),
                    cs.openStandard, 0, 'Open1'),
                si.m.cal.ReflectCalibrationMeasurement(
                    resDict['Load1Measurement'].FrequencyResponse(1, 1),
                    cs.loadStandard, 0, 'Load1'),
                si.m.cal.ReflectCalibrationMeasurement(
                    resDict['Short2Measurement'].FrequencyResponse(1, 1),
                    cs.shortStandard, 1, 'Short2'),
                si.m.cal.ReflectCalibrationMeasurement(
                    resDict['Open2Measurement'].FrequencyResponse(1, 1),
                    cs.openStandard, 1, 'Open2'),
                si.m.cal.ReflectCalibrationMeasurement(
                    resDict['Load2Measurement'].FrequencyResponse(1, 1),
                    cs.loadStandard, 1, 'Load2'),
                si.m.cal.ThruCalibrationMeasurement(
                    resDict['ThruMeasurement'].FrequencyResponse(
                        1, 1), resDict['ThruMeasurement'].FrequencyResponse(
                            2, 1), cs.thruStandard, 0, 1, 'Thru1'),
                si.m.cal.ThruCalibrationMeasurement(
                    resDict['ThruMeasurement'].FrequencyResponse(
                        2, 2), resDict['ThruMeasurement'].FrequencyResponse(
                            1, 2), cs.thruStandard, 1, 0, 'Thru2'),
            ])
        TestTDRErrorTermsTest.resDict = resDict
예제 #11
0
 def buildSimulations(self):
     # @todo: currently, I set the risetime on the pulse to a tiny number just to make
     # sure it actually comes out, but the definition of the pulse source is that at
     # time 0, it is at the 50% point, so when I do this, tiny pulses come out half
     # the size.  so down below, you'll see the amplitude doubled if the size is not
     # zero.  I should fix this by creating an impulse generator, and letting the
     # pulse generator be the way it is.
     risetime = 1e-21
     WaveformStartTime = -1e-9
     WaveformEndTime = 5e-9
     print('Building Simulations')
     simName = projName = 'Short'
     print(simName)
     tdrsim = siapp.SignalIntegrityAppHeadless()
     tdrsim.OpenProjectFile('TDRSimulation.si')
     siapp.Project['CalculationProperties.EndFrequency'] = self.fd.Fe
     siapp.Project['CalculationProperties.FrequencyPoints'] = self.fd.N
     siapp.Project[
         'CalculationProperties'].CalculateOthersFromBaseInformation()
     siapp.Project['CalculationProperties.UserSampleRate'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     siapp.Project[
         'CalculationProperties'].CalculateOthersFromBaseInformation()
     tdrsim.Device('V1')['gain']['Value'] = self.g1
     tdrsim.Device('V2')['gain']['Value'] = self.g2
     tdrsim.Device('DUT')['file']['Value'] = simName + '.si'
     tdrsim.Device('VG1')['a']['Value'] = self.V1 * (1. if risetime == 0.0
                                                     else 2.)
     tdrsim.Device('VG1')['rt']['Value'] = risetime
     tdrsim.Device('VG1')['fs']['Value'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     HorizontalOffset = WaveformStartTime - siapp.Project[
         'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG1')['ho']['Value'] = HorizontalOffset
     tdrsim.Device('VG1')['dur'][
         'Value'] = WaveformEndTime - HorizontalOffset + siapp.Project[
             'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG2')['a']['Value'] = self.V2 * (1. if risetime == 0.0
                                                     else 2.)
     tdrsim.Device('VG2')['rt']['Value'] = risetime
     tdrsim.Device('VG2')['fs']['Value'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     HorizontalOffset = WaveformStartTime - siapp.Project[
         'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG2')['ho']['Value'] = HorizontalOffset
     tdrsim.Device('VG2')['dur'][
         'Value'] = WaveformEndTime - HorizontalOffset + siapp.Project[
             'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.SaveProjectToFile('TDRSimulation' + simName + '.si')
     simName = projName = 'Open'
     print(simName)
     tdrsim = siapp.SignalIntegrityAppHeadless()
     tdrsim.OpenProjectFile('TDRSimulation.si')
     siapp.Project['CalculationProperties.EndFrequency'] = self.fd.Fe
     siapp.Project['CalculationProperties.FrequencyPoints'] = self.fd.N
     siapp.Project[
         'CalculationProperties'].CalculateOthersFromBaseInformation()
     siapp.Project['CalculationProperties.UserSampleRate'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     siapp.Project[
         'CalculationProperties'].CalculateOthersFromBaseInformation()
     tdrsim.Device('V1')['gain']['Value'] = self.g1
     tdrsim.Device('V2')['gain']['Value'] = self.g2
     tdrsim.Device('DUT')['file']['Value'] = simName + '.si'
     tdrsim.Device('VG1')['a']['Value'] = self.V1 * (1. if risetime == 0.0
                                                     else 2.)
     tdrsim.Device('VG1')['rt']['Value'] = risetime
     tdrsim.Device('VG1')['fs']['Value'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     HorizontalOffset = WaveformStartTime - siapp.Project[
         'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG1')['ho']['Value'] = HorizontalOffset
     tdrsim.Device('VG1')['dur'][
         'Value'] = WaveformEndTime - HorizontalOffset + siapp.Project[
             'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG2')['a']['Value'] = self.V2 * (1. if risetime == 0.0
                                                     else 2.)
     tdrsim.Device('VG2')['rt']['Value'] = risetime
     tdrsim.Device('VG2')['fs']['Value'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     HorizontalOffset = WaveformStartTime - siapp.Project[
         'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG2')['ho']['Value'] = HorizontalOffset
     tdrsim.Device('VG2')['dur'][
         'Value'] = WaveformEndTime - HorizontalOffset + siapp.Project[
             'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.SaveProjectToFile('TDRSimulation' + simName + '.si')
     simName = projName = 'Load'
     print(simName)
     tdrsim = siapp.SignalIntegrityAppHeadless()
     tdrsim.OpenProjectFile('TDRSimulation.si')
     siapp.Project['CalculationProperties.EndFrequency'] = self.fd.Fe
     siapp.Project['CalculationProperties.FrequencyPoints'] = self.fd.N
     siapp.Project[
         'CalculationProperties'].CalculateOthersFromBaseInformation()
     siapp.Project['CalculationProperties.UserSampleRate'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     siapp.Project[
         'CalculationProperties'].CalculateOthersFromBaseInformation()
     tdrsim.Device('V1')['gain']['Value'] = self.g1
     tdrsim.Device('V2')['gain']['Value'] = self.g2
     tdrsim.Device('DUT')['file']['Value'] = simName + '.si'
     tdrsim.Device('VG1')['a']['Value'] = self.V1 * (1. if risetime == 0.0
                                                     else 2.)
     tdrsim.Device('VG1')['rt']['Value'] = risetime
     tdrsim.Device('VG1')['fs']['Value'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     HorizontalOffset = WaveformStartTime - siapp.Project[
         'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG1')['ho']['Value'] = HorizontalOffset
     tdrsim.Device('VG1')['dur'][
         'Value'] = WaveformEndTime - HorizontalOffset + siapp.Project[
             'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG2')['a']['Value'] = self.V2 * (1. if risetime == 0.0
                                                     else 2.)
     tdrsim.Device('VG2')['rt']['Value'] = risetime
     tdrsim.Device('VG2')['fs']['Value'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     HorizontalOffset = WaveformStartTime - siapp.Project[
         'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG2')['ho']['Value'] = HorizontalOffset
     tdrsim.Device('VG2')['dur'][
         'Value'] = WaveformEndTime - HorizontalOffset + siapp.Project[
             'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.SaveProjectToFile('TDRSimulation' + simName + '.si')
     simName = 'Thru'
     projName = simName + '1'
     print(simName)
     tdrsim = siapp.SignalIntegrityAppHeadless()
     tdrsim.OpenProjectFile('TDRSimulation.si')
     siapp.Project['CalculationProperties.EndFrequency'] = self.fd.Fe
     siapp.Project['CalculationProperties.FrequencyPoints'] = self.fd.N
     siapp.Project[
         'CalculationProperties'].CalculateOthersFromBaseInformation()
     siapp.Project['CalculationProperties.UserSampleRate'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     siapp.Project[
         'CalculationProperties'].CalculateOthersFromBaseInformation()
     tdrsim.Device('V1')['gain']['Value'] = self.g1
     tdrsim.Device('V2')['gain']['Value'] = self.g2
     tdrsim.Device('DUT')['file']['Value'] = simName + '.si'
     tdrsim.Device('VG1')['a']['Value'] = self.V1 * (1. if risetime == 0.0
                                                     else 2.)
     tdrsim.Device('VG1')['rt']['Value'] = risetime
     tdrsim.Device('VG1')['fs']['Value'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     HorizontalOffset = WaveformStartTime - siapp.Project[
         'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG1')['ho']['Value'] = HorizontalOffset
     tdrsim.Device('VG1')['dur'][
         'Value'] = WaveformEndTime - HorizontalOffset + siapp.Project[
             'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG2')['a']['Value'] = 0.0
     tdrsim.Device('VG2')['rt']['Value'] = risetime
     tdrsim.Device('VG2')['fs']['Value'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     HorizontalOffset = WaveformStartTime - siapp.Project[
         'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG2')['ho']['Value'] = HorizontalOffset
     tdrsim.Device('VG2')['dur'][
         'Value'] = WaveformEndTime - HorizontalOffset + siapp.Project[
             'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.SaveProjectToFile('TDRSimulation' + projName + '.si')
     simName = 'Thru'
     projName = simName + '2'
     print(simName)
     tdrsim = siapp.SignalIntegrityAppHeadless()
     tdrsim.OpenProjectFile('TDRSimulation.si')
     siapp.Project['CalculationProperties.EndFrequency'] = self.fd.Fe
     siapp.Project['CalculationProperties.FrequencyPoints'] = self.fd.N
     siapp.Project[
         'CalculationProperties'].CalculateOthersFromBaseInformation()
     siapp.Project['CalculationProperties.UserSampleRate'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     siapp.Project[
         'CalculationProperties'].CalculateOthersFromBaseInformation()
     tdrsim.Device('V1')['gain']['Value'] = self.g1
     tdrsim.Device('V2')['gain']['Value'] = self.g2
     tdrsim.Device('DUT')['file']['Value'] = simName + '.si'
     tdrsim.Device('VG1')['a']['Value'] = 0.0
     tdrsim.Device('VG1')['rt']['Value'] = risetime
     tdrsim.Device('VG1')['fs']['Value'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     HorizontalOffset = WaveformStartTime - siapp.Project[
         'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG1')['ho']['Value'] = HorizontalOffset
     tdrsim.Device('VG1')['dur'][
         'Value'] = WaveformEndTime - HorizontalOffset + siapp.Project[
             'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG2')['a']['Value'] = self.V2 * (1. if risetime == 0.0
                                                     else 2.)
     tdrsim.Device('VG2')['rt']['Value'] = risetime
     tdrsim.Device('VG2')['fs']['Value'] = siapp.Project[
         'CalculationProperties.BaseSampleRate']
     HorizontalOffset = WaveformStartTime - siapp.Project[
         'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.Device('VG2')['ho']['Value'] = HorizontalOffset
     tdrsim.Device('VG2')['dur'][
         'Value'] = WaveformEndTime - HorizontalOffset + siapp.Project[
             'CalculationProperties.ImpulseResponseLength'] / 2.
     tdrsim.SaveProjectToFile('TDRSimulation' + projName + '.si')