88from amaranth_soc import csr , wishbone
99from amaranth_soc .csr .wishbone import WishboneCSRBridge
1010
11- from amaranth_orchard .base . gpio import GPIOPeripheral , GPIOPins
12- from amaranth_orchard .memory . spimemio import SPIMemIO , QSPIPins
13- from amaranth_orchard .io . uart import UARTPeripheral , UARTPins
14- from amaranth_orchard .memory . sram import SRAMPeripheral
15- from amaranth_orchard .base . soc_id import SoCID
11+ from amaranth_orchard .base import SoCID
12+ from amaranth_orchard .memory import SPIMemIO
13+ from amaranth_orchard .memory import SRAMPeripheral
14+ from amaranth_orchard .io import GPIOPeripheral
15+ from amaranth_orchard .io import UARTPeripheral
1616
1717from amaranth_cv32e40p .cv32e40p import CV32E40P , DebugModule
1818from chipflow_lib .platforms import InputPinSignature , OutputPinSignature
3131 "tdo" : Out (OutputPinSignature (1 )),
3232})
3333
34- # ---------
3534
3635class MySoC (wiring .Component ):
3736 def __init__ (self ):
3837 # Top level interfaces
3938
4039 interfaces = {
41- "flash" : Out (QSPIPins .Signature ()),
40+ "flash" : Out (SPIMemIO .Signature ()),
4241 "cpu_jtag" : Out (JTAGSignature )
4342 }
4443
@@ -64,10 +63,10 @@ def __init__(self):
6463# interfaces[f"pdm_ao_{i}"] = Out(PDMPins.Signature())
6564
6665 for i in range (self .uart_count ):
67- interfaces [f"uart_{ i } " ] = Out (UARTPins .Signature ())
66+ interfaces [f"uart_{ i } " ] = Out (UARTPeripheral .Signature ())
6867
6968 for i in range (self .gpio_banks ):
70- interfaces [f"gpio_{ i } " ] = Out (GPIOPins .Signature (width = self .gpio_width ))
69+ interfaces [f"gpio_{ i } " ] = Out (GPIOPeripheral .Signature (pin_count = self .gpio_width ))
7170
7271 super ().__init__ (interfaces )
7372
@@ -144,12 +143,13 @@ def elaborate(self, platform):
144143 m .submodules .debug = debug
145144 # SPI flash
146145
147- spiflash = SPIMemIO (flash = self . flash )
146+ spiflash = SPIMemIO ()
148147 wb_decoder .add (spiflash .data_bus , addr = self .mem_spiflash_base )
149148 csr_decoder .add (spiflash .ctrl_bus , name = "spiflash" , addr = self .csr_spiflash_base - self .csr_base )
150-
151149 m .submodules .spiflash = spiflash
152150
151+ connect (m , flipped (self .flash ), spiflash .pins )
152+
153153 sw .add_periph ("spiflash" , "SPIFLASH" , self .csr_spiflash_base )
154154
155155 # SRAM
@@ -168,27 +168,31 @@ def elaborate(self, platform):
168168 sw .add_periph ("spi" , f"USER_SPI_{ i } " , base_addr )
169169
170170 # FIXME: These assignments will disappear once we have a relevant peripheral available
171- spi_pins = getattr (self , f"user_spi_{ i } " )
172- connect (m , flipped (spi_pins ), user_spi .spi_pins )
171+ pins = getattr (self , f"user_spi_{ i } " )
172+ connect (m , flipped (pins ), user_spi .spi_pins )
173173
174174 setattr (m .submodules , f"user_spi_{ i } " , user_spi )
175175
176176 # GPIOs
177177 for i in range (self .gpio_banks ):
178- gpio = GPIOPeripheral (pins = getattr ( self , f"gpio_ { i } " ) )
178+ gpio = GPIOPeripheral (pin_count = self . gpio_width )
179179 base_addr = self .csr_gpio_base + i * self .periph_offset
180180 csr_decoder .add (gpio .bus , name = f"gpio_{ i } " , addr = base_addr - self .csr_base )
181181 sw .add_periph ("gpio" , f"GPIO_{ i } " , base_addr )
182182
183+ pins = getattr (self , f"gpio_{ i } " )
184+ connect (m , flipped (pins ), gpio .pins )
183185 setattr (m .submodules , f"gpio_{ i } " , gpio )
184186
185187 # UART
186188 for i in range (self .uart_count ):
187- uart = UARTPeripheral (init_divisor = int (25e6 // 115200 ), pins = getattr ( self , f"uart_ { i } " ) )
189+ uart = UARTPeripheral (init_divisor = int (25e6 // 115200 ))
188190 base_addr = self .csr_uart_base + i * self .periph_offset
189191 csr_decoder .add (uart .bus , name = f"uart_{ i } " , addr = base_addr - self .csr_base )
190-
191192 sw .add_periph ("uart" , f"UART_{ i } " , base_addr )
193+
194+ pins = getattr (self , f"uart_{ i } " )
195+ connect (m , flipped (pins ), uart .pins )
192196 setattr (m .submodules , f"uart_{ i } " , uart )
193197
194198 # I2Cs
0 commit comments