|
5 | 5 |
|
6 | 6 | from amaranth_soc import csr, gpio |
7 | 7 |
|
8 | | -from chipflow_lib.platforms import GPIOSignature |
| 8 | +from chipflow_lib.platforms import GPIOSignature, SoftwareDriverSignature |
| 9 | + |
9 | 10 |
|
10 | 11 | __all__ = ["GPIOPeripheral"] |
11 | 12 |
|
@@ -49,18 +50,24 @@ def __init__(self, *, pin_count, addr_width=4, data_width=8, input_stages=2): |
49 | 50 |
|
50 | 51 | if pin_count > 32 or pin_count <= 0: |
51 | 52 | # TODO: why? |
52 | | - raise ValueError(f"Pin pin_count must be a postive integrer less than 32, not {pin_count}") |
| 53 | + raise ValueError(f"Pin pin_count must be a postive integer 32 or less, not {pin_count}") |
53 | 54 |
|
54 | 55 | self._gpio = gpio.Peripheral(pin_count=pin_count, |
55 | 56 | addr_width=addr_width, |
56 | 57 | data_width=data_width, |
57 | 58 | input_stages=input_stages) |
| 59 | + super().__init__( |
| 60 | + SoftwareDriverSignature( |
| 61 | + members={ |
| 62 | + "bus": In(csr.Signature(addr_width=addr_width, data_width=data_width)), |
| 63 | + "pins": Out(GPIOSignature(pin_count)), |
| 64 | + "alt_mode": Out(unsigned(pin_count)), |
| 65 | + }, |
| 66 | + component=self, |
| 67 | + regs_struct='gpio_regs_t', |
| 68 | + h_files=['drivers/gpio.h']) |
| 69 | + ) |
58 | 70 |
|
59 | | - super().__init__({ |
60 | | - "bus": In(csr.Signature(addr_width=addr_width, data_width=data_width)), |
61 | | - "pins": Out(GPIOSignature(pin_count)), |
62 | | - "alt_mode": Out(unsigned(pin_count)), |
63 | | - }) |
64 | 71 | self.bus.memory_map = self._gpio.bus.memory_map |
65 | 72 |
|
66 | 73 | def elaborate(self, platform): |
|
0 commit comments