1
- import numpy as np
2
1
from pathlib import Path
3
2
4
- from dragonphy import Channel , Wiener , Quantizer , Packager
3
+ from dragonphy import Channel , Packager
5
4
6
5
class AdaptFir :
7
6
def __init__ (self , filename = None , ** system_values ):
@@ -10,52 +9,18 @@ def __init__(self, filename=None, **system_values):
10
9
ffe_config = system_values ['generic' ]['ffe' ]
11
10
constant_config = system_values ['generic' ]
12
11
mlsd_config = system_values ['generic' ]['mlsd' ]
13
- comp_config = system_values ['generic' ]['comp' ]
12
+ comp_config = system_values ['generic' ]['comp' ]
13
+
14
14
# create channel model
15
15
kwargs = dict (
16
- channel_type = 'arctan ' ,
17
- tau = 0. 25e-9 ,
18
- t_delay = 4e-9 ,
19
- sampl_rate = 10e9 ,
16
+ channel_type = 'exponent ' ,
17
+ tau = 25e-12 ,
18
+ t_delay = 31.25e-12 ,
19
+ sampl_rate = 160e9 ,
20
20
resp_depth = 500
21
21
)
22
22
chan = Channel (** kwargs )
23
23
24
- # create a channel model delayed such that the optimal
25
- # cursor position is an integer
26
- # TODO: clean this up
27
- kwargs_d = kwargs .copy ()
28
- kwargs_d ['t_delay' ] += 0.5e-9
29
- chan_d = Channel (** kwargs_d )
30
-
31
- # compute response of channel to codes
32
- iterations = 200000
33
- ideal_codes = np .random .randint (2 , size = iterations ) * 2 - 1
34
- chan_out = chan_d .compute_output (ideal_codes )
35
-
36
- # Adapt to the channel
37
- cursor_pos = 5
38
- adapt = Wiener (
39
- step_size = ffe_config ['adaptation' ]['args' ]['mu' ],
40
- num_taps = ffe_config ['parameters' ]['length' ],
41
- cursor_pos = cursor_pos
42
- )
43
- for i in range (iterations - cursor_pos ):
44
- adapt .find_weights_pulse (ideal_codes [i - cursor_pos ], chan_out [i ])
45
- weights = adapt .weights
46
-
47
- # Uncomment this line for debugging purposes to
48
- # use weights corresponding to a perfect channel
49
- # weights = np.array([1.0, 0, 0])
50
-
51
- # Normalize weights
52
- weights = weights * (100.0 / np .sum (np .abs (weights )))
53
-
54
- # Quantize the weights
55
- # TODO: why isn't "quantized_weights" used?
56
- qw = Quantizer (width = ffe_config ['parameters' ]['weight_precision' ], signed = True )
57
- quantized_weights = qw .quantize_2s_comp (weights )
58
-
59
24
# create constants package
60
25
Packager (
61
26
package_name = 'constant_gpack' ,
@@ -84,29 +49,6 @@ def __init__(self, filename=None, **system_values):
84
49
dir = build_dir
85
50
).create_package ()
86
51
87
- # Write impulse response to package
88
- step_dt = 0.1e-9
89
- _ , v_step = chan .get_step_resp (f_sig = 1 / step_dt , resp_depth = 500 )
90
- Packager (
91
- package_name = 'step_resp_pack' ,
92
- parameters = {
93
- 'step_len' : len (v_step ),
94
- 'step_dt' : step_dt ,
95
- 'v_step' : v_step
96
- },
97
- dir = build_dir
98
- ).create_package ()
99
-
100
- # Write weights to package
101
- # TODO: why is "weights" used here instead of "quantized_weights"?
102
- Packager (
103
- package_name = 'weights_pack' ,
104
- parameters = {
105
- 'read_weights' : [int (elem ) for elem in weights ]
106
- },
107
- dir = build_dir
108
- ).create_package ()
109
-
110
52
# Write the step response data to a YAML file
111
53
chan .to_file (build_dir / 'chan.npy' )
112
54
print (build_dir / 'chan.npy' )
0 commit comments