File tree 1 file changed +16
-7
lines changed
1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -16,13 +16,22 @@ def __init__(self, signal):
16
16
self .comb += signal .eq (self ._out .storage )
17
17
18
18
19
- class GPIOInOut (Module ):
20
- def __init__ (self , in_signal , out_signal ):
21
- self .submodules .gpio_in = GPIOIn (in_signal )
22
- self .submodules .gpio_out = GPIOOut (out_signal )
23
-
24
- def get_csrs (self ):
25
- return self .gpio_in .get_csrs () + self .gpio_out .get_csrs ()
19
+ class GPIOTristate (Module , AutoCSR ):
20
+ def __init__ (self , signals ):
21
+ l = len (signals )
22
+ self ._in = CSRStatus (l )
23
+ self ._out = CSRStorage (l )
24
+ self ._oe = CSRStorage (l )
25
+
26
+ for n , signal in enumerate (signals ):
27
+ ts = TSTriple (1 )
28
+ self .specials += ts .get_tristate (signal )
29
+
30
+ self .specials += MultiReg (ts .i , self ._in .status )
31
+ self .comb += [
32
+ ts .o .eq (self ._out .storage ),
33
+ ts .oe .eq (self ._oe .storage )
34
+ ]
26
35
27
36
28
37
class Blinker (Module ):
You can’t perform that action at this time.
0 commit comments