|
1 | | -from typing import Unpack |
2 | 1 |
|
3 | 2 | from amaranth import Module, unsigned |
4 | 3 | from amaranth.lib import wiring |
5 | 4 | from amaranth.lib.wiring import In, Out, flipped, connect |
6 | 5 |
|
7 | 6 | from amaranth_soc import csr, gpio |
8 | 7 |
|
9 | | -from chipflow_lib.platforms import BidirIOSignature, IOModelOptions |
| 8 | +from chipflow_lib.platforms import GPIOSignature |
10 | 9 |
|
11 | 10 | __all__ = ["GPIOPeripheral"] |
12 | 11 |
|
13 | 12 |
|
14 | 13 | class GPIOPeripheral(wiring.Component): |
15 | 14 |
|
16 | | - class Signature(wiring.Signature): |
17 | | - def __init__(self, pin_count=1, **kwargs: Unpack[IOModelOptions]): |
18 | | - if pin_count > 32: |
19 | | - raise ValueError(f"Pin pin_count must be lesser than or equal to 32, not {pin_count}") |
20 | | - self._pin_count = pin_count |
21 | | - super().__init__({ |
22 | | - "gpio": Out(BidirIOSignature(pin_count, individual_oe=True, **kwargs)) |
23 | | - }) |
24 | | - |
25 | | - @property |
26 | | - def pin_count(self): |
27 | | - return self._pin_count |
28 | | - |
29 | 15 | """Wrapper for amaranth_soc gpio with chipflow_lib.IOSignature support |
30 | 16 |
|
31 | 17 | Parameters |
@@ -65,7 +51,7 @@ def __init__(self, *, pin_count, addr_width=4, data_width=8, input_stages=2): |
65 | 51 |
|
66 | 52 | super().__init__({ |
67 | 53 | "bus": In(csr.Signature(addr_width=addr_width, data_width=data_width)), |
68 | | - "pins": Out(self.Signature(pin_count)), |
| 54 | + "pins": Out(GPIOSignature(pin_count)), |
69 | 55 | "alt_mode": Out(unsigned(pin_count)), |
70 | 56 | }) |
71 | 57 | self.bus.memory_map = self._gpio.bus.memory_map |
|
0 commit comments