Skip to content

Commit ab140b3

Browse files
committed
Use new all_have_oe flag to BidirPinSignature for GPIO and SPIMemIO
1 parent f597f08 commit ab140b3

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

amaranth_orchard/base/gpio.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

amaranth_orchard/memory/spimemio.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def __init__(self):
1818
super().__init__({
1919
"clk": Out(OutputPinSignature(1)),
2020
"csn": Out(OutputPinSignature(1)),
21-
} |
22-
{f"d{n}": Out(BidirPinSignature(1)) for n in range(4)})
21+
"d": Out(BidirPinSignature(4, all_have_oe=True)),
22+
})
2323

2424
def create(self, *, path=(), src_loc_at=0):
2525
return QSPIPins(path=path, src_loc_at=1 + src_loc_at)
@@ -98,11 +98,11 @@ def elaborate(self, platform):
9898
"i_cfgreg_di": ctrl_bridge.cfgreg_di,
9999
"o_cfgreg_do": ctrl_bridge.cfgreg_do,
100100
} | {
101-
f"o_flash_io{n}_oe": getattr(self.qspi, f"d{n}").oe for n in range(4)
101+
f"o_flash_io{n}_oe": self.qspi.d.oe[n] for n in range(4)
102102
} | {
103-
f"o_flash_io{n}_do": getattr(self.flash, f"d{n}").o for n in range(4)
103+
f"o_flash_io{n}_do": self.qspi.d.o[n] for n in range(4)
104104
} | {
105-
f"i_flash_io{n}_i": getattr(self.flash, f"d{n}").i for n in range(4)
105+
f"i_flash_io{n}_di": self.qspi.d.i[n] for n in range(4)
106106
}
107107

108108
m.submodules.spimemio = Instance("spimemio", **verilog_map)

0 commit comments

Comments
 (0)