Skip to content

Commit f9c181c

Browse files
committed
Sketch how soc might work
1 parent e459b5f commit f9c181c

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

riscv-demo/riscv_demo/ips/qspi/glasgow_qspi.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ def elaborate(self, platform):
149149

150150

151151
class QSPIController(wiring.Component):
152-
def __init__(self, ports, *, chip_count=1, use_ddr_buffers=False):
153-
self.ioshape = IOShape({
152+
def pins(chip_count=1):
153+
return IOShape({
154154
"sck": ("o", 1),
155155
"io0": ("io", 1),
156156
"io1": ("io", 1),
@@ -159,10 +159,10 @@ def __init__(self, ports, *, chip_count=1, use_ddr_buffers=False):
159159
"cs": ("o", chip_count),
160160
})
161161

162-
self._ports = self.ioshape.check_ports(ports)
163-
162+
def __init__(self, *, chip_count=1, use_ddr_buffers=False):
164163
self._ddr = use_ddr_buffers
165164
self._chip_count = chip_count
165+
self._ioshape = self.pins(chip_count)
166166

167167
super().__init__(PortSignature({
168168
"o_octets": In(stream.Signature(data.StructLayout({
@@ -182,15 +182,16 @@ def elaborate(self, platform):
182182

183183
m = Module()
184184

185+
self.ports = platform.get_ports()
185186
m.submodules.enframer = enframer = QSPIEnframer(chip_count = self._chip_count)
186187
connect(m, controller=flipped(self.o_octets), enframer=enframer.octets)
187188

188-
m.submodules.io_clocker = io_clocker = IOClocker(self.ioshape,
189+
m.submodules.io_clocker = io_clocker = IOClocker(self._ioshape,
189190
clock="sck", o_ratio=ratio, meta_layout=QSPIMode)
190191
connect(m, enframer=enframer.frames, io_clocker=io_clocker.i_stream)
191192
m.d.comb += io_clocker.divisor.eq(self.divisor)
192193

193-
m.submodules.io_streamer = io_streamer = IOStreamer(self.ioshape, self._ports, init={
194+
m.submodules.io_streamer = io_streamer = IOStreamer(self._ioshape, self._ports, init={
194195
"sck": {"o": 1, "oe": 1}, # Motorola "Mode 3" with clock idling high
195196
"cs": {"o": 0, "oe": 1}, # deselected
196197
}, ratio=ratio, meta_layout=QSPIMode)

riscv-demo/riscv_demo/soc.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from amaranth_soc.wishbone.sram import WishboneSRAM
88

99
from minerva.core import Minerva
10+
from chipflow_lib.platforms.iostream import IOShape
1011

1112
from .ips.qspi import QSPIController, WishboneQSPIFlashController
1213
from .ips.uart import UARTPhy, UARTPeripheral
@@ -17,12 +18,15 @@
1718

1819

1920
class DemoSoC(wiring.Component):
20-
def __init__(self, ports):
21-
super().__init__({})
22-
23-
self.ports = ports
24-
25-
# Memory regions:
21+
pins = IOShape({
22+
'qspi': QSPIController.pins(),
23+
'uart0': UARTPhy.pins(),
24+
'uart1': UARTPhy.pins(),
25+
})
26+
27+
def __init__(self):
28+
super().__init__(PortSignature({}))
29+
# Memory regions:
2630
self.mem_spiflash_base = 0x00000000
2731
self.mem_sram_base = 0x10000000
2832

@@ -37,6 +41,8 @@ def __init__(self, ports):
3741
def elaborate(self, platform):
3842
m = Module()
3943

44+
self.ports = platform.get_ports()
45+
4046
wb_arbiter = wishbone.Arbiter(addr_width=30, data_width=32, granularity=8)
4147
wb_decoder = wishbone.Decoder(addr_width=30, data_width=32, granularity=8)
4248
csr_decoder = csr.Decoder(addr_width=28, data_width=8)

0 commit comments

Comments
 (0)