|
1 | | -- Start Date: (fill in with date at which the RFC is merged, YYYY-MM-DD) |
2 | | -- RFC PR: [amaranth-lang/rfcs#0070](https://github.com/amaranth-lang/rfcs/pull/70) |
3 | | -- Amaranth SoC Issue: [amaranth-lang/amaranth-soc#0000](https://github.com/amaranth-lang/amaranth-soc/issues/0000) |
| 1 | +- Start Date: 2024-06-28 |
| 2 | +- RFC PR: [amaranth-lang/rfcs#70](https://github.com/amaranth-lang/rfcs/pull/70) |
| 3 | +- Amaranth SoC Issue: [amaranth-lang/amaranth-soc#93](https://github.com/amaranth-lang/amaranth-soc/issues/93) |
4 | 4 |
|
5 | 5 | # Unify the naming of `MemoryMap` resources and windows |
6 | 6 |
|
@@ -34,13 +34,13 @@ Some examples: |
34 | 34 |
|
35 | 35 | ```python3 |
36 | 36 | >>> MemoryMap.Name(("rx", "status")) |
37 | | -('rx', 'status') |
| 37 | +Name('rx', 'status') |
38 | 38 | >>> MemoryMap.Name(("uart", 0)) |
39 | | -('uart', 0) |
40 | | ->>> MemoryMap.Name(MemoryMap.Name("uart", 0)) |
41 | | -('uart', 0) |
| 39 | +Name('uart', 0) |
| 40 | +>>> MemoryMap.Name(MemoryMap.Name(("uart", 0)) |
| 41 | +Name('uart', 0) |
42 | 42 | >>> MemoryMap.Name("foo") |
43 | | -('foo',) |
| 43 | +Name('foo',) |
44 | 44 | ``` |
45 | 45 |
|
46 | 46 | ### Assigning resource names |
@@ -133,12 +133,12 @@ In a `MemoryMap` hierarchy, each resource is identified by a path. The path of a |
133 | 133 | ```python3 |
134 | 134 | >>> for res_info in decoder.csr_bus.memory_map.all_resources(): |
135 | 135 | ... print(res_info.path) |
136 | | -(('uart', 0), ('rx', 'config')) |
137 | | -(('uart', 0), ('rx', 'status')) |
138 | | -(('uart', 0), ('rx', 'data')) |
139 | | -(('uart', 1), ('rx', 'config')) |
140 | | -(('uart', 1), ('rx', 'status')) |
141 | | -(('uart', 1), ('rx', 'data')) |
| 136 | +(Name('uart', 0), Name('rx', 'config')) |
| 137 | +(Name('uart', 0), Name('rx', 'status')) |
| 138 | +(Name('uart', 0), Name('rx', 'data')) |
| 139 | +(Name('uart', 1), Name('rx', 'config')) |
| 140 | +(Name('uart', 1), Name('rx', 'status')) |
| 141 | +(Name('uart', 1), Name('rx', 'data')) |
142 | 142 | ``` |
143 | 143 |
|
144 | 144 | ## Reference-level explanation |
@@ -183,20 +183,21 @@ As a consequence of this proposal, the following changes are made to other modul |
183 | 183 | [rationale-and-alternatives]: #rationale-and-alternatives |
184 | 184 |
|
185 | 185 | - Providing a `MemoryMap.Name` class for resource and window names facilitates their validation and documentation. |
186 | | - * Alternative #1: do not add a class, and use standard tuples instead. Names will have to be validated by other means. |
187 | | - * Alternative #2: use `MemoryMap.Name` for resource names only. Window names remain limited to strings. |
| 186 | + * ~~Alternative #1: do not add a class, and use standard tuples instead. Names will have to be validated by other means.~~ |
| 187 | + * ~~Alternative #2: use `MemoryMap.Name` for resource names only. Window names remain limited to strings.~~ |
188 | 188 |
|
189 | 189 | ## Prior art |
190 | 190 | [prior-art]: #prior-art |
191 | 191 |
|
192 | 192 | - Resource names became tuples of strings as a consequence of [RFC 16](https://amaranth-lang.org/rfcs/0016-soc-csr-regs.html). However, array indices defined with `csr.Builder.Index()` were [cast to strings](https://github.com/amaranth-lang/amaranth-soc/issues/69) when `.as_memory_map()` was called. |
193 | 193 |
|
194 | | -## Unresolved questions |
| 194 | +## Resolved questions |
195 | 195 | [unresolved-questions]: #unresolved-questions |
196 | 196 |
|
197 | 197 | - Should we require the presence of at least one string in `MemoryMap.Name` ? |
| 198 | + * Empty names are forbidden and transparent windows (i.e. without names) must use `None` instead. Further validation is deferred to consumers of the memory map (e.g. a BSP generator). |
198 | 199 | - Should we specify the order between strings and integers ? In `csr.Builder`, array indices precede cluster and register names (e.g. `('bar', 0, 'foo')` could be formatted as `"bar.foo[0]"`). |
199 | | -- Bikeshedding `MemoryMap.Name`. |
| 200 | + * No, this decision is left out to consumers of the memory map. They may interpret a name differently depending on what it is assigned to. |
200 | 201 |
|
201 | 202 | ## Future possibilities |
202 | 203 | [future-possibilities]: #future-possibilities |
|
0 commit comments