Skip to content

Commit 9a29699

Browse files
committed
[earlgrey,dv] Remove bogus dmi device from TopEarlgrey
This was added for Darjeeling and it appears the engineers concerned didn't think about the fact this would convince various bits of tooling that the phantom interface exists for Earlgrey too. The bulk of this commit is tidying up the logic in topgen's lib.py, merge.py and top_uvm_reg.sv.tpl to allow the possibility that an instance of a block doesn't connect up all the interfaces that the block defines. To do this properly, it also fixes some incorrect type annotations in the code (which seem to have been introduced when first adding multiple address maps). The Earlgrey-specific change is tiny: it's just remove the "dmi" line in hw/top_earlgrey/data/top_earlgrey.hjson, together with the comment that shows the author realises it didn't make much sense... Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
1 parent 9e17647 commit 9a29699

File tree

13 files changed

+149
-121
lines changed

13 files changed

+149
-121
lines changed

hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,10 +2424,6 @@
24242424
{
24252425
hart: 0x40140000
24262426
}
2427-
dmi:
2428-
{
2429-
hart: 0x0
2430-
}
24312427
}
24322428
param_decl:
24332429
{

hw/top_earlgrey/data/autogen/top_earlgrey.secrets.testing.gen.hjson

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,10 +2873,6 @@
28732873
{
28742874
hart: 0x40140000
28752875
}
2876-
dmi:
2877-
{
2878-
hart: 0x0
2879-
}
28802876
}
28812877
memory: {}
28822878
param_list:

hw/top_earlgrey/data/top_earlgrey.hjson

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@
453453
reset_connections: {rst_ni: "lc_io_div4", rst_kmac_ni: "lc"},
454454
base_addrs: {
455455
regs: {hart: "0x40140000"},
456-
dmi: {hart: "0x0"}, // DMI is not used in EarlGrey
457456
},
458457
param_decl: {
459458
// NOTE THAT THIS IS A FEATURE FOR TEST CHIPS ONLY TO MITIGATE

hw/top_earlgrey/doc/memory_map.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ The main address space, shared between the CPU and DM
2828
| otp_ctrl | core | `0x40130000` | `0x1000` | `0x400` | core device on otp_ctrl |
2929
| otp_macro | prim | `0x40138000` | `0x20` | `0x8` | prim device on otp_macro |
3030
| lc_ctrl | regs | `0x40140000` | `0x100` | `0x40` | regs device on lc_ctrl |
31-
| lc_ctrl | dmi | `0x0` | `0x1000` | `0x400` | dmi device on lc_ctrl |
3231
| alert_handler | default | `0x40150000` | `0x800` | `0x200` | alert_handler |
3332
| spi_host0 | default | `0x40300000` | `0x40` | `0x10` | spi_host0 |
3433
| spi_host1 | default | `0x40310000` | `0x40` | `0x10` | spi_host1 |

hw/top_earlgrey/rtl/autogen/top_earlgrey_pkg.sv

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,6 @@ package top_earlgrey_pkg;
149149
*/
150150
parameter int unsigned TOP_EARLGREY_LC_CTRL_REGS_SIZE_BYTES = 32'h100;
151151

152-
/**
153-
* Peripheral base address for dmi device on lc_ctrl in top earlgrey.
154-
*/
155-
parameter int unsigned TOP_EARLGREY_LC_CTRL_DMI_BASE_ADDR = 32'h0;
156-
157-
/**
158-
* Peripheral size in bytes for dmi device on lc_ctrl in top earlgrey.
159-
*/
160-
parameter int unsigned TOP_EARLGREY_LC_CTRL_DMI_SIZE_BYTES = 32'h1000;
161-
162152
/**
163153
* Peripheral base address for alert_handler in top earlgrey.
164154
*/

hw/top_earlgrey/sw/autogen/chip/top_earlgrey.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,6 @@ pub const LC_CTRL_REGS_BASE_ADDR: usize = 0x40140000;
217217
/// `LC_CTRL_REGS_BASE_ADDR + LC_CTRL_REGS_SIZE_BYTES`.
218218
pub const LC_CTRL_REGS_SIZE_BYTES: usize = 0x100;
219219

220-
/// Peripheral base address for dmi device on lc_ctrl in top earlgrey.
221-
///
222-
/// This should be used with #mmio_region_from_addr to access the memory-mapped
223-
/// registers associated with the peripheral (usually via a DIF).
224-
pub const LC_CTRL_DMI_BASE_ADDR: usize = 0x0;
225-
226-
/// Peripheral size for dmi device on lc_ctrl in top earlgrey.
227-
///
228-
/// This is the size (in bytes) of the peripheral's reserved memory area. All
229-
/// memory-mapped registers associated with this peripheral should have an
230-
/// address between #LC_CTRL_DMI_BASE_ADDR and
231-
/// `LC_CTRL_DMI_BASE_ADDR + LC_CTRL_DMI_SIZE_BYTES`.
232-
pub const LC_CTRL_DMI_SIZE_BYTES: usize = 0x1000;
233-
234220
/// Peripheral base address for alert_handler in top earlgrey.
235221
///
236222
/// This should be used with #mmio_region_from_addr to access the memory-mapped

hw/top_earlgrey/sw/autogen/top_earlgrey.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -282,24 +282,6 @@ extern "C" {
282282
*/
283283
#define TOP_EARLGREY_LC_CTRL_REGS_SIZE_BYTES 0x100u
284284

285-
/**
286-
* Peripheral base address for dmi device on lc_ctrl in top earlgrey.
287-
*
288-
* This should be used with #mmio_region_from_addr to access the memory-mapped
289-
* registers associated with the peripheral (usually via a DIF).
290-
*/
291-
#define TOP_EARLGREY_LC_CTRL_DMI_BASE_ADDR 0x0u
292-
293-
/**
294-
* Peripheral size for dmi device on lc_ctrl in top earlgrey.
295-
*
296-
* This is the size (in bytes) of the peripheral's reserved memory area. All
297-
* memory-mapped registers associated with this peripheral should have an
298-
* address between #TOP_EARLGREY_LC_CTRL_DMI_BASE_ADDR and
299-
* `TOP_EARLGREY_LC_CTRL_DMI_BASE_ADDR + TOP_EARLGREY_LC_CTRL_DMI_SIZE_BYTES`.
300-
*/
301-
#define TOP_EARLGREY_LC_CTRL_DMI_SIZE_BYTES 0x1000u
302-
303285
/**
304286
* Peripheral base address for alert_handler in top earlgrey.
305287
*

hw/top_earlgrey/sw/autogen/top_earlgrey_memory.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -304,23 +304,6 @@
304304
* `TOP_EARLGREY_LC_CTRL_REGS_BASE_ADDR + TOP_EARLGREY_LC_CTRL_REGS_SIZE_BYTES`.
305305
*/
306306
#define TOP_EARLGREY_LC_CTRL_REGS_SIZE_BYTES 0x100
307-
/**
308-
* Peripheral base address for dmi device on lc_ctrl in top earlgrey.
309-
*
310-
* This should be used with #mmio_region_from_addr to access the memory-mapped
311-
* registers associated with the peripheral (usually via a DIF).
312-
*/
313-
#define TOP_EARLGREY_LC_CTRL_DMI_BASE_ADDR 0x0
314-
315-
/**
316-
* Peripheral size for dmi device on lc_ctrl in top earlgrey.
317-
*
318-
* This is the size (in bytes) of the peripheral's reserved memory area. All
319-
* memory-mapped registers associated with this peripheral should have an
320-
* address between #TOP_EARLGREY_LC_CTRL_DMI_BASE_ADDR and
321-
* `TOP_EARLGREY_LC_CTRL_DMI_BASE_ADDR + TOP_EARLGREY_LC_CTRL_DMI_SIZE_BYTES`.
322-
*/
323-
#define TOP_EARLGREY_LC_CTRL_DMI_SIZE_BYTES 0x1000
324307
/**
325308
* Peripheral base address for alert_handler in top earlgrey.
326309
*

util/dtgen/helper.py

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,25 +1066,55 @@ def _create_instance(self, m):
10661066
rb = self.UNNAMED_REG_BLOCK_NAME
10671067
rb_key = "null" # Due to json serializing, None appears as null.
10681068
rb = Name.from_snake_case(rb)
1069-
# It is possible that this module is not accessible in this
1070-
# address space. In this case, return a dummy value.
1071-
# FIXME Maybe find a better way of doing this.
1072-
assert rb_key in m["base_addrs"]
1073-
reg_block_map[rb] = m["base_addrs"][rb_key].get(self._addr_space, "0xffffffff")
1069+
1070+
# The register block may not actually be accessible in this
1071+
# address space. Indeed, the top-level might not connect up the
1072+
# register block at all, because it also passes a parameter
1073+
# value that turns off the interface that this address space
1074+
# would be using.
1075+
#
1076+
# If so, use the same behaviour here: don't add the block to
1077+
# reg_block_map.
1078+
asid_to_base_addr = m["base_addrs"].get(rb_key)
1079+
if asid_to_base_addr is not None:
1080+
reg_block_map[rb] = asid_to_base_addr.get(self._addr_space,
1081+
"0xffffffff")
1082+
10741083
inst_desc[self.REG_BLOCK_ADDR_FIELD_NAME] = reg_block_map
1084+
10751085
# Memories.
10761086
if self.has_memories():
10771087
mem_addr_map = OrderedDict()
10781088
mem_size_map = OrderedDict()
10791089
for mem in self.ip.memories.keys():
10801090
mem_name = Name.from_snake_case(mem)
1081-
# It is possible that this module is not accessible in this
1082-
# address space. In this case, return a dummy value.
1083-
# FIXME Maybe find a better way of doing this.
1084-
assert mem in m["base_addrs"]
1085-
mem_addr_map[mem_name] = m["base_addrs"][mem].get(self._addr_space, "0xffffffff")
1086-
assert mem in m["memory"] and "size" in m["memory"][mem]
1087-
mem_size_map[mem_name] = m["memory"][mem]["size"]
1091+
1092+
# As with register blocks, the memory might not be accessible
1093+
# in this address space. As before, don't add the memory to
1094+
# mem_addr_map and mem_size_map.
1095+
#
1096+
# Note that we *do* expect m["memory"][mem] to exist if the
1097+
# memory is accessible. If it doesn't, the configuration
1098+
# requested a connection for a memory without describing what
1099+
# was connected.
1100+
asid_to_base_addr = m["base_addrs"].get(mem)
1101+
if asid_to_base_addr is not None:
1102+
mem_addr_map[mem_name] = asid_to_base_addr.get(self._addr_space, "0xffffffff")
1103+
1104+
memory_mem = m["memory"].get(mem)
1105+
if memory_mem is None:
1106+
raise RuntimeError(f"Connection described for memory "
1107+
f"{mem_name}, but the memory has "
1108+
f"no description.")
1109+
1110+
memory_mem_size = memory_mem.get("size")
1111+
if memory_mem_size is None:
1112+
raise RuntimeError(f"The memory {mem_name} has a "
1113+
f"connection described, but the "
1114+
f"size is not defined.")
1115+
1116+
mem_size_map[mem_name] = memory_mem_size
1117+
10881118
inst_desc[self.MEM_ADDR_FIELD_NAME] = mem_addr_map
10891119
inst_desc[self.MEM_SIZE_FIELD_NAME] = mem_size_map
10901120
# Clock map.

util/topgen.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -856,10 +856,12 @@ def generate_top_ral(topname: str, top: ConfigT, name_to_block: IpBlocksT,
856856

857857
inst_to_block[inst_name] = block_name
858858
for if_name in block.reg_blocks.keys():
859-
if_addr = {
860-
asid: int(addr, 0)
861-
for (asid, addr) in module["base_addrs"][if_name].items()
862-
}
859+
base_addrs = module["base_addrs"].get(if_name)
860+
if base_addrs is None:
861+
continue
862+
863+
if_addr = {asid: int(addr, 0)
864+
for (asid, addr) in base_addrs.items()}
863865
if_addrs[(inst_name, if_name)] = if_addr
864866

865867
# Top-level may override the mem setting. Store the new type to

0 commit comments

Comments
 (0)