Skip to content

Commit ee315e9

Browse files
committed
Fix to do everything modern CSR way
1 parent a5b70c8 commit ee315e9

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

amaranth_orchard/base/gpio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ def __init__(self, width):
5555
5656
All pins default to input at power up.
5757
"""
58-
def __init__(self, *, name, pins):
58+
def __init__(self, *, pins):
5959

6060
self.width = pins.width
6161
self.pins = pins
6262

63-
regs = csr.Builder(addr_width=4, data_width=8, name=name)
63+
regs = csr.Builder(addr_width=4, data_width=8)
6464

6565
self._do = regs.add("do", self.DO(self.width), offset=0x0)
6666
self._oe = regs.add("oe", self.OE(self.width), offset=0x4)

amaranth_orchard/base/soc_id.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ def __init__(self, width):
2121
Two read-only CSRs; the first contains a SoC-defined type ID and the second the git hash of the
2222
repo being used to build the SoC.
2323
"""
24-
def __init__(self, *, name, type_id=0xbadca77e):
24+
def __init__(self, *, type_id=0xbadca77e):
2525
self.type_id = type_id
2626
self.git_hash = int(subprocess.check_output('git rev-parse --verify HEAD'.split(' ')).strip()[0:8], base=16)
2727

28-
regs = csr.Builder(addr_width=4, data_width=8, name=name)
28+
regs = csr.Builder(addr_width=4, data_width=8)
2929

3030
self._soc_type = regs.add("soc_type", self.Register(32), offset=0x0)
3131
self._soc_version = regs.add("soc_version", self.Register(32), offset=0x4)

amaranth_orchard/io/uart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def __init__(self, init_divisor):
5555
5656
TODO: Interrupts support, perhaps mimic something with upstream Linux kernel support...
5757
"""
58-
def __init__(self, *, name, init_divisor, pins):
58+
def __init__(self, *, init_divisor, pins):
5959
self.init_divisor = init_divisor
6060
self.pins = pins
6161

62-
regs = csr.Builder(addr_width=5, data_width=8, name=name)
62+
regs = csr.Builder(addr_width=5, data_width=8)
6363

6464
self._tx_data = regs.add("tx_data", self.TxData(), offset=0x00)
6565
self._rx_data = regs.add("rx_data", self.RxData(), offset=0x04)

amaranth_orchard/memory/spimemio.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,23 @@ def elaborate(self, platform):
5555
- ctrl_bus is the original 32-bit control register
5656
- data_bus is a bus peripheral that directly maps the 16MB of read-only flash memory.
5757
"""
58-
def __init__(self, *, name, flash):
59-
self.flash = flash
58+
def __init__(self, flash):
6059
self.size = 2**24
6160
size_words = (self.size * 8) // 32
6261

6362
super().__init__({
63+
"qspi": Out(QSPIPins.Signature()),
6464
"ctrl_bus": In(csr.Signature(addr_width=exact_log2(4), data_width=8)),
6565
"data_bus": In(wishbone.Signature(addr_width=exact_log2(size_words), data_width=32,
6666
granularity=8)),
6767
})
6868

6969
ctrl_memory_map = MemoryMap(addr_width=exact_log2(4), data_width=8)
70-
ctrl_memory_map.add_resource(name=(name,), size=4, resource=self)
70+
ctrl_memory_map.add_resource(name="spimemio", size=4, resource=self)
7171
self.ctrl_bus.memory_map = ctrl_memory_map
7272

7373
data_memory_map = MemoryMap(addr_width=exact_log2(self.size), data_width=8)
74-
data_memory_map.add_resource(name=(name,), size=self.size, resource=self)
74+
data_memory_map.add_resource(name="spimemio", size=self.size, resource=self)
7575
self.data_bus.memory_map = data_memory_map
7676

7777
def elaborate(self, platform):
@@ -90,17 +90,17 @@ def elaborate(self, platform):
9090
"o_ready": spi_ready,
9191
"i_addr": Cat(Const(0, 2), self.data_bus.adr), # Hack to force a 1MB offset
9292
"o_rdata": self.data_bus.dat_r,
93-
"o_flash_csb": self.flash.csn.o,
94-
"o_flash_clk": self.flash.clk.o,
93+
"o_flash_csb": self.qspi.csn.o,
94+
"o_flash_clk": self.qspi.clk.o,
9595
"i_cfgreg_we": ctrl_bridge.cfgreg_we,
9696
"i_cfgreg_di": ctrl_bridge.cfgreg_di,
9797
"o_cfgreg_do": ctrl_bridge.cfgreg_do,
9898
} | {
99-
f"o_flash_io{n}_oe": getattr(self.flash, f"d{n}").oe for n in range(4)
99+
f"o_flash_io{n}_oe": getattr(self.qspi, f"d{n}").oe for n in range(4)
100100
} | {
101-
f"o_flash_io{n}_o": getattr(self.flash, f"d{n}").o for n in range(4)
101+
f"o_flash_io{n}_o": getattr(self.qspi, f"d{n}").o for n in range(4)
102102
} | {
103-
f"o_flash_io{n}_i": getattr(self.flash, f"d{n}").i for n in range(4)
103+
f"o_flash_io{n}_i": getattr(self.qspi, f"d{n}").i for n in range(4)
104104
}
105105

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

0 commit comments

Comments
 (0)