@@ -15,10 +15,9 @@ def __init__(self, width):
1515 if width > 32 :
1616 raise ValueError (f"Pin width must be lesser than or equal to 32, not { width } " )
1717 self ._width = width
18- super ().__init__ (
19- # each pin has seperate output enable
20- {f"gpio{ n } " :Out (BidirPinSignature (1 )) for n in range (width )}
21- )
18+ super ().__init__ ({
19+ "gpio" : Out (BidirPinSignature (width , all_have_oe = True ))
20+ })
2221
2322 @property
2423 def width (self ):
@@ -29,8 +28,8 @@ def create(self, *, path=(), src_loc_at=0):
2928
3029 def __init__ (self , width , * , path = (), src_loc_at = 0 ):
3130 super ().__init__ (self .Signature (width ), path = path , src_loc_at = 1 + src_loc_at )
32-
33- @property
31+
32+ @property
3433 def width (self ):
3534 return self .signature .width
3635
@@ -78,8 +77,8 @@ def elaborate(self, platform):
7877
7978 connect (m , flipped (self .bus ), self ._bridge .bus )
8079
81- m .d .comb += [ getattr ( self .pins , f" gpio{ n } " ) .o .eq (self ._do .f .pins .data [ n ]) for n in range ( self . width )]
82- m .d .comb += [ getattr ( self .pins , f" gpio{ n } " ) .oe .eq (self ._oe .f .pins .data [ n ]) for n in range ( self . width )]
83- m .d .comb += [ self ._di .f .pins .r_data [ n ] .eq (getattr ( self .pins , f" gpio{ n } " ) .i ) for n in range ( self . width )]
80+ m .d .comb += self .pins . gpio .o .eq (self ._do .f .pins .data )
81+ m .d .comb += self .pins . gpio .oe .eq (self ._oe .f .pins .data )
82+ m .d .comb += self ._di .f .pins .r_data .eq (self .pins . gpio .i )
8483
8584 return m
0 commit comments