-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuserSettingsObjects.py
239 lines (186 loc) · 8.17 KB
/
userSettingsObjects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
'''
This file is used to define the data objects used for the simulation
so that functions can know what to expect and to ensure that the
configuration data is accessed properly.
'''
from dataclasses import dataclass, field
from numpy import ndarray, empty
# Generic dataclass for any value that may have an associated increment and limits for both.
@dataclass(init=False)
class valueWithLimits:
value: float = float("nan")
maxValue: float = float("nan")
minValue: float = float("nan")
increment: float = float("nan")
minIncrement: float = float("nan")
maxIncrement: float = float("nan")
def __init__(self, val: float = float("nan")):
self.value = val
@dataclass
class valueList:
value: ndarray = empty(0)
class nothing:
def __init__(self):
pass
@dataclass
class plottingSettings:
# Display responses
channelResponse: bool = False
CTLEResponse: bool = False
pulseResponse: bool = False
# Display inteferences
jitterSource: bool = False
noiseSource: bool = False
distortionSource: bool = False
# Display probability distributions
ISI: bool = False # CAREFUL: CAN BE SLOW TO PLOT!
PDFInitial: bool = False
PDFCrossTalk: bool = False
PDFDistorted: bool = False
PDFJitter: bool = False
PDFNoise: bool = False
PDFFinal: bool = False
# Display bit-error rate distributions
BER: bool = False # plot BER contour over BER
BER2: bool = False # plot BER contour over PDF
# Display measurement results
results: bool = False
@dataclass
class generalSettings:
symbolRate: valueWithLimits = valueWithLimits() #symbol rate [S/s] (or 2x frequency [Hz])
symbolPeriod: valueWithLimits = valueWithLimits()
sampleRate: valueWithLimits = valueWithLimits()
samplePeriod: valueWithLimits = valueWithLimits()
# Signaling mode ('standard','1+D','1+0.5D','clock')
signalingMode: str = 'standard'
# Modulation (M-PAM)
modulation: valueWithLimits = valueWithLimits()
# Resolution
samplesPerSymb: valueWithLimits = valueWithLimits() # horizontal resolution
yAxis: valueList = valueList()
yAxisLength: valueWithLimits = valueWithLimits() # vertical resolution (must be odd)
yIncrement: valueWithLimits = valueWithLimits()
xAxisCenter: valueList = valueList()
xAxisLong: valueList = valueList()
# General display
numbSymb: valueWithLimits = valueWithLimits() # number of symbols to plot
contLevels: valueWithLimits = valueWithLimits() # number of contour levels
levelNumb: valueWithLimits = valueWithLimits()
samplerNumb: valueWithLimits = valueWithLimits()
# Target BER
targetBER: valueWithLimits = valueWithLimits() # used for measurement purposes
plotting: plottingSettings = plottingSettings()
@dataclass
class originalSettings:
modulation: valueWithLimits = valueWithLimits()
levelNumb: valueWithLimits = valueWithLimits()
samplerNumb: valueWithLimits = valueWithLimits()
preCursorCount: valueWithLimits = valueWithLimits()
postCursorCount: valueWithLimits = valueWithLimits()
cursorCount: valueWithLimits = valueWithLimits()
@dataclass
class adaptionSettings:
adapt: bool = False
knobs: list = field(default_factory=lambda : [])
# Adaption complexity
totalParents: valueWithLimits = valueWithLimits()
childrenPerParent: valueWithLimits = valueWithLimits()
totalMutations: valueWithLimits = valueWithLimits()
mode1Generations: valueWithLimits = valueWithLimits()# coarse adjustment
mode2Generations: valueWithLimits = valueWithLimits() # fine adjustment
totalSimulations: valueWithLimits = valueWithLimits()
totalPopulation: valueWithLimits = valueWithLimits()
speedUpSim: bool = False
savedSettings: originalSettings = originalSettings()
@dataclass
class distortionSetting:
addDistortion: bool = False
fileName: str = ''
class noiseSettings:
def __init__(self):
self.addNoise: bool = False
self.stdDeviation: valueWithLimits = valueWithLimits() # TX random noise standard diviation [V]
self.amplitude: valueWithLimits = valueWithLimits() # TX deterministic noise amplitude [V]
self.frequency: valueWithLimits = valueWithLimits() # TX deterministic noise frequency [Hz]
self.noiseDensity: valueWithLimits = valueWithLimits() # Noise density [V^2/Hz]
class jitterSettings:
def __init__(self):
self.addJitter = False
self.stdDeviation = valueWithLimits() # TX random jitter standard diviation [UI]
self.amplitude = valueWithLimits() # TX deterministic jitter amplitude [UI]
self.DCD = valueWithLimits() # TX duty-cycle distortion jitter [UI]
class equalizerSettings:
def __init__(self):
self.addEqualization = False
self.taps = nothing()
@dataclass
class transmitterSettings:
signalAmplitude: valueWithLimits = valueWithLimits() # Maximum amplitude [V]
TXBandwidth: valueWithLimits = valueWithLimits() # TX bandwidth [Hz]
# Impulse cursor length
preCursorCount: valueWithLimits = valueWithLimits()
postCursorCount: valueWithLimits = valueWithLimits()
cursorCount: valueWithLimits = valueWithLimits()
tRise: valueWithLimits = valueWithLimits() # Rise/fall time [s]
EQ: equalizerSettings = equalizerSettings() # Pre-emphasis
jitter: jitterSettings = jitterSettings()
noise: noiseSettings = noiseSettings()
distortion: distortionSetting = distortionSetting()
includeSourceImpedance: bool = True # Add source impedance (drop amplitude by half)
@dataclass
class preAmpSettings:
addGain: bool = False
gain: valueWithLimits = valueWithLimits()
@dataclass
class CTLESettings:
zeroFreq: valueWithLimits = valueWithLimits() # frequency of first zero [Hz]
zeroNumb: valueWithLimits = valueWithLimits() # number of zeros
pole1Freq: valueWithLimits = valueWithLimits() # frequency of first pole [Hz]
pole1Numb: valueWithLimits = valueWithLimits() # number of first poles
pole2Freq: valueWithLimits = valueWithLimits() # frequency of additional poles [Hz]
pole2Numb: valueWithLimits = valueWithLimits() # number of additional poles
addEqualization: bool = False
@dataclass
class receiverSettings:
signalAmplitude: valueWithLimits = valueWithLimits() # Maximum amplitude [V]
preAmp: preAmpSettings = preAmpSettings()
CTLE: CTLESettings = CTLESettings()
FFE: equalizerSettings = equalizerSettings()
DFE: equalizerSettings = equalizerSettings()
jitter: jitterSettings = jitterSettings()
noise: noiseSettings = noiseSettings()
distortion: distortionSetting = distortionSetting()
@dataclass
class fileNamesHolder:
pass
@dataclass
class channelSettings:
# Apply channel/cross-talk
addChannel: bool = True
addCrossTalk: bool = True
# Noise
noise: noiseSettings = noiseSettings()
# Add notch (must update transfer function)
notchFreq: valueWithLimits = valueWithLimits() # frequency of notch
notchAttenuation: valueWithLimits = valueWithLimits() # attenuation at notch [dB]
addNotch: bool = False
# Convolve pulse response (convolve all channels with additional transfer function, must update transfer function)
modelCircuitTF: bool = False
modelCircuitTFName: str = ''
# Override channel pulse response (must have same over-sampling frequency)
overrideResponse: bool = False
overrideFileName: str = ''
# Approximate cross-talk to speed up simulation
approximate: bool = True
# Make cross-talk channels asynchronous
makeAsynchronous: bool = True
# Channel file names (ensure channel data has same frequency points)
fileNames: fileNamesHolder = fileNamesHolder()
# The complete compiled class for all simulation settings
@dataclass
class simulationSettings:
general: generalSettings = generalSettings()
adaption: adaptionSettings = adaptionSettings()
transmitter: transmitterSettings = transmitterSettings()
channel: channelSettings = channelSettings()
receiver: receiverSettings = receiverSettings()