5
5
6
6
7
7
class _AD9xxx (Module ):
8
- def __init__ (self , ftw_base , pads , nchannels , ** kwargs ):
8
+ def __init__ (self , ftw_base , pads , nchannels , onehot = False , ** kwargs ):
9
9
self .submodules ._ll = RenameClockDomains (
10
10
ad9xxx .AD9xxx (pads , ** kwargs ), "rio" )
11
11
self .submodules ._rt2wb = RT2WB (flen (pads .a )+ 1 , self ._ll .bus )
@@ -21,23 +21,29 @@ def __init__(self, ftw_base, pads, nchannels, **kwargs):
21
21
current_address .eq (self .rtlink .o .address ),
22
22
current_data .eq (self .rtlink .o .data ))
23
23
24
- # keep track of the currently selected channel
25
- current_channel = Signal (max = nchannels )
24
+ # keep track of the currently selected channel(s)
25
+ current_sel = Signal (flen ( current_data ) - 1 )
26
26
self .sync .rio += If (current_address == 2 ** flen (pads .a ) + 1 ,
27
- current_channel .eq (current_data ))
27
+ current_sel .eq (current_data [1 :])) # strip reset
28
+
29
+ def selected (c ):
30
+ if onehot :
31
+ return current_sel [c ]
32
+ else :
33
+ return current_sel == c
28
34
29
35
# keep track of frequency tuning words, before they are FUDed
30
36
ftws = [Signal (32 ) for i in range (nchannels )]
31
37
for c , ftw in enumerate (ftws ):
32
38
if flen (pads .d ) == 8 :
33
39
self .sync .rio += \
34
- If (current_channel == c , [
40
+ If (selected ( c ) , [
35
41
If (current_address == ftw_base + i ,
36
42
ftw [i * 8 :(i + 1 )* 8 ].eq (current_data ))
37
43
for i in range (4 )])
38
44
elif flen (pads .d ) == 16 :
39
45
self .sync .rio += \
40
- If (current_channel == c , [
46
+ If (selected ( c ) , [
41
47
If (current_address == ftw_base + 2 * i ,
42
48
ftw [i * 16 :(i + 1 )* 16 ].eq (current_data ))
43
49
for i in range (2 )])
@@ -46,15 +52,15 @@ def __init__(self, ftw_base, pads, nchannels, **kwargs):
46
52
47
53
# FTW to probe on FUD
48
54
self .sync .rio += If (current_address == 2 ** flen (pads .a ), [
49
- If (current_channel == c , probe .eq (ftw ))
55
+ If (selected ( c ) , probe .eq (ftw ))
50
56
for c , (probe , ftw ) in enumerate (zip (self .probes , ftws ))])
51
57
52
58
53
59
class AD9858 (_AD9xxx ):
54
- def __init__ (self , pads , nchannels , ** kwargs ):
55
- _AD9xxx .__init__ (self , 0x0a , pads , nchannels , ** kwargs )
60
+ def __init__ (self , * args , ** kwargs ):
61
+ _AD9xxx .__init__ (self , 0x0a , * args , ** kwargs )
56
62
57
63
58
64
class AD9914 (_AD9xxx ):
59
- def __init__ (self , pads , nchannels , ** kwargs ):
60
- _AD9xxx .__init__ (self , 0x2d , pads , nchannels , ** kwargs )
65
+ def __init__ (self , * args , ** kwargs ):
66
+ _AD9xxx .__init__ (self , 0x2d , * args , ** kwargs )
0 commit comments