amaranth-lang / amaranth-soc

System on Chip toolkit for Amaranth HDL
BSD 2-Clause "Simplified" License
83 stars 31 forks source link

`MemoryMap.add_resource()` should support integers in resource names #69

Closed jfng closed 4 months ago

jfng commented 9 months ago

Currently, csr.Builder works around this by casting array indices to strings calling MemoryMap.add_resource().

Repro:

from amaranth import *
from amaranth_soc import csr

class FooRegister(csr.Register, access="r"):
    a: csr.Field(csr.action.R, unsigned(8))

regs = csr.Builder(addr_width=1, data_width=8)

for n in range(2):
    with regs.Index(n):
        regs.add("foo", FooRegister())

for reg, reg_name, reg_range in regs.as_memory_map().resources():
    print(reg_name)

Current output:

('0', 'foo')
('1', 'foo')

Expected output:

(0, 'foo')
(1, 'foo')