amaranth-soc icon indicating copy to clipboard operation
amaranth-soc copied to clipboard

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

Open jfng opened this issue 1 year ago • 0 comments

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')

jfng avatar Feb 09 '24 14:02 jfng