Skip to content

Commit

Permalink
[topgen] Improve support for multiple address spaces
Browse files Browse the repository at this point in the history
Individually generate C and Rust collateral for all address spaces

Signed-off-by: Robert Schilling <[email protected]>
  • Loading branch information
Razer6 authored and a-will committed May 15, 2024
1 parent d3914e5 commit 32ad6ff
Show file tree
Hide file tree
Showing 27 changed files with 1,376 additions and 115 deletions.
1 change: 1 addition & 0 deletions hw/top_darjeeling/data/autogen/top_darjeeling.gen.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@
{
name: hart
desc: The main address space, shared between the CPU and DM
default: true
}
{
name: soc_mbx
Expand Down
2 changes: 1 addition & 1 deletion hw/top_darjeeling/data/top_darjeeling.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
// all peripherals, though not every peripheral will be accessible to every
// host in that address space--Access privileges are separate from addresses.
addr_spaces: [
{ name: "hart", desc: "The main address space, shared between the CPU and DM"},
{ name: "hart", desc: "The main address space, shared between the CPU and DM", default: true},
{ name: "soc_mbx", desc: "SoC address space for mailbox access"},
{ name: "soc_dbg", desc: "SoC address space for debug module interfaces"},
]
Expand Down
46 changes: 46 additions & 0 deletions hw/top_darjeeling/rtl/autogen/top_darjeeling_soc_dbg_pkg.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// ------------------- W A R N I N G: A U T O - G E N E R A T E D C O D E !! -------------------//
// PLEASE DO NOT HAND-EDIT THIS FILE. IT HAS BEEN AUTO-GENERATED WITH THE FOLLOWING COMMAND:
//
// util/topgen.py -t hw/top_darjeeling/data/top_darjeeling.hjson \
// -o hw/top_darjeeling/ \
// --rnd_cnst_seed \
// 1017106219537032642877583828875051302543807092889754935647094601236425074047

package top_darjeeling_soc_dbg_pkg;
/**
* Peripheral base address for dmi device on lc_ctrl in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_LC_CTRL_DMI_BASE_ADDR = 32'h20000;

/**
* Peripheral size in bytes for dmi device on lc_ctrl in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_LC_CTRL_DMI_SIZE_BYTES = 32'h1000;

/**
* Peripheral base address for dbg device on rv_dm in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_RV_DM_DBG_BASE_ADDR = 32'h0;

/**
* Peripheral size in bytes for dbg device on rv_dm in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_RV_DM_DBG_SIZE_BYTES = 32'h200;

/**
* Peripheral base address for soc device on mbx_jtag in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX_JTAG_SOC_BASE_ADDR = 32'h1000;

/**
* Peripheral size in bytes for soc device on mbx_jtag in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX_JTAG_SOC_SIZE_BYTES = 32'h20;



endpackage
106 changes: 106 additions & 0 deletions hw/top_darjeeling/rtl/autogen/top_darjeeling_soc_mbx_pkg.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// ------------------- W A R N I N G: A U T O - G E N E R A T E D C O D E !! -------------------//
// PLEASE DO NOT HAND-EDIT THIS FILE. IT HAS BEEN AUTO-GENERATED WITH THE FOLLOWING COMMAND:
//
// util/topgen.py -t hw/top_darjeeling/data/top_darjeeling.hjson \
// -o hw/top_darjeeling/ \
// --rnd_cnst_seed \
// 1017106219537032642877583828875051302543807092889754935647094601236425074047

package top_darjeeling_soc_mbx_pkg;
/**
* Peripheral base address for soc device on mbx0 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX0_SOC_BASE_ADDR = 32'h1465000;

/**
* Peripheral size in bytes for soc device on mbx0 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX0_SOC_SIZE_BYTES = 32'h20;

/**
* Peripheral base address for soc device on mbx1 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX1_SOC_BASE_ADDR = 32'h1465100;

/**
* Peripheral size in bytes for soc device on mbx1 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX1_SOC_SIZE_BYTES = 32'h20;

/**
* Peripheral base address for soc device on mbx2 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX2_SOC_BASE_ADDR = 32'h1465200;

/**
* Peripheral size in bytes for soc device on mbx2 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX2_SOC_SIZE_BYTES = 32'h20;

/**
* Peripheral base address for soc device on mbx3 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX3_SOC_BASE_ADDR = 32'h1465300;

/**
* Peripheral size in bytes for soc device on mbx3 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX3_SOC_SIZE_BYTES = 32'h20;

/**
* Peripheral base address for soc device on mbx4 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX4_SOC_BASE_ADDR = 32'h1465400;

/**
* Peripheral size in bytes for soc device on mbx4 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX4_SOC_SIZE_BYTES = 32'h20;

/**
* Peripheral base address for soc device on mbx5 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX5_SOC_BASE_ADDR = 32'h1465500;

/**
* Peripheral size in bytes for soc device on mbx5 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX5_SOC_SIZE_BYTES = 32'h20;

/**
* Peripheral base address for soc device on mbx6 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX6_SOC_BASE_ADDR = 32'h1465600;

/**
* Peripheral size in bytes for soc device on mbx6 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX6_SOC_SIZE_BYTES = 32'h20;

/**
* Peripheral base address for soc device on mbx_pcie0 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX_PCIE0_SOC_BASE_ADDR = 32'h1460100;

/**
* Peripheral size in bytes for soc device on mbx_pcie0 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX_PCIE0_SOC_SIZE_BYTES = 32'h20;

/**
* Peripheral base address for soc device on mbx_pcie1 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX_PCIE1_SOC_BASE_ADDR = 32'h1460200;

/**
* Peripheral size in bytes for soc device on mbx_pcie1 in top darjeeling.
*/
parameter int unsigned TOP_DARJEELING_MBX_PCIE1_SOC_SIZE_BYTES = 32'h20;



endpackage
4 changes: 4 additions & 0 deletions hw/top_darjeeling/sw/autogen/chip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@

pub mod top_darjeeling;
pub mod top_darjeeling_memory;
pub mod top_darjeeling_soc_dbg;
pub mod top_darjeeling_soc_dbg_memory;
pub mod top_darjeeling_soc_mbx;
pub mod top_darjeeling_soc_mbx_memory;
70 changes: 70 additions & 0 deletions hw/top_darjeeling/sw/autogen/chip/top_darjeeling_soc_dbg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

// This file was generated automatically.
// Please do not modify content of this file directly.
// File generated by using template: "toplevel.rs.tpl"
// To regenerate this file follow OpenTitan topgen documentations.

#![allow(dead_code)]

//! This file contains enums and consts for use within the Rust codebase.
//!
//! These definitions are for information that depends on the top-specific chip
//! configuration, which includes:
//! - Device Memory Information (for Peripherals and Memory)
//! - PLIC Interrupt ID Names and Source Mappings
//! - Alert ID Names and Source Mappings
//! - Pinmux Pin/Select Names
//! - Power Manager Wakeups
use core::convert::TryFrom;

/// Peripheral base address for dmi device on lc_ctrl in top darjeeling.
///
/// This should be used with #mmio_region_from_addr to access the memory-mapped
/// registers associated with the peripheral (usually via a DIF).
pub const TOP_DARJEELING_LC_CTRL_DMI_BASE_ADDR: usize = 0x20000;

/// Peripheral size for dmi device on lc_ctrl in top darjeeling.
///
/// This is the size (in bytes) of the peripheral's reserved memory area. All
/// memory-mapped registers associated with this peripheral should have an
/// address between #TOP_DARJEELING_LC_CTRL_DMI_BASE_ADDR and
/// `TOP_DARJEELING_LC_CTRL_DMI_BASE_ADDR + TOP_DARJEELING_LC_CTRL_DMI_SIZE_BYTES`.
pub const TOP_DARJEELING_LC_CTRL_DMI_SIZE_BYTES: usize = 0x1000;
/// Peripheral base address for dbg device on rv_dm in top darjeeling.
///
/// This should be used with #mmio_region_from_addr to access the memory-mapped
/// registers associated with the peripheral (usually via a DIF).
pub const TOP_DARJEELING_RV_DM_DBG_BASE_ADDR: usize = 0x0;

/// Peripheral size for dbg device on rv_dm in top darjeeling.
///
/// This is the size (in bytes) of the peripheral's reserved memory area. All
/// memory-mapped registers associated with this peripheral should have an
/// address between #TOP_DARJEELING_RV_DM_DBG_BASE_ADDR and
/// `TOP_DARJEELING_RV_DM_DBG_BASE_ADDR + TOP_DARJEELING_RV_DM_DBG_SIZE_BYTES`.
pub const TOP_DARJEELING_RV_DM_DBG_SIZE_BYTES: usize = 0x200;
/// Peripheral base address for soc device on mbx_jtag in top darjeeling.
///
/// This should be used with #mmio_region_from_addr to access the memory-mapped
/// registers associated with the peripheral (usually via a DIF).
pub const TOP_DARJEELING_MBX_JTAG_SOC_BASE_ADDR: usize = 0x1000;

/// Peripheral size for soc device on mbx_jtag in top darjeeling.
///
/// This is the size (in bytes) of the peripheral's reserved memory area. All
/// memory-mapped registers associated with this peripheral should have an
/// address between #TOP_DARJEELING_MBX_JTAG_SOC_BASE_ADDR and
/// `TOP_DARJEELING_MBX_JTAG_SOC_BASE_ADDR + TOP_DARJEELING_MBX_JTAG_SOC_SIZE_BYTES`.
pub const TOP_DARJEELING_MBX_JTAG_SOC_SIZE_BYTES: usize = 0x20;

/// MMIO Region
///
/// MMIO region excludes any memory that is separate from the module
/// configuration space, i.e. ROM, main SRAM, and flash are excluded but
/// retention SRAM, spi_device memory, or usbdev memory are included.
pub const TOP_DARJEELING_MMIO_BASE_ADDR: usize = 0x1000;
pub const TOP_DARJEELING_MMIO_SIZE_BYTES: usize = 0x20000;
62 changes: 62 additions & 0 deletions hw/top_darjeeling/sw/autogen/chip/top_darjeeling_soc_dbg_memory.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

// This file was generated automatically.
// Please do not modify content of this file directly.
// File generated by using template: "toplevel_memory.rs.tpl"
// To regenerate this file follow OpenTitan topgen documentations.

#![allow(dead_code)]

//! Rust Top-Specific Definitions.
//!
//! This file contains const definitions for use within Rust code.
/// Peripheral base address for dmi device on lc_ctrl in top darjeeling.
///
/// This should be used with #mmio_region_from_addr to access the memory-mapped
/// registers associated with the peripheral (usually via a DIF).
pub const TOP_DARJEELING_LC_CTRL_DMI_BASE_ADDR: usize = 0x20000;

/// Peripheral size for dmi device on lc_ctrl in top darjeeling.
///
/// This is the size (in bytes) of the peripheral's reserved memory area. All
/// memory-mapped registers associated with this peripheral should have an
/// address between #TOP_DARJEELING_LC_CTRL_DMI_BASE_ADDR and
/// `TOP_DARJEELING_LC_CTRL_DMI_BASE_ADDR + TOP_DARJEELING_LC_CTRL_DMI_SIZE_BYTES`.
pub const TOP_DARJEELING_LC_CTRL_DMI_SIZE_BYTES: usize = 0x1000;
/// Peripheral base address for dbg device on rv_dm in top darjeeling.
///
/// This should be used with #mmio_region_from_addr to access the memory-mapped
/// registers associated with the peripheral (usually via a DIF).
pub const TOP_DARJEELING_RV_DM_DBG_BASE_ADDR: usize = 0x0;

/// Peripheral size for dbg device on rv_dm in top darjeeling.
///
/// This is the size (in bytes) of the peripheral's reserved memory area. All
/// memory-mapped registers associated with this peripheral should have an
/// address between #TOP_DARJEELING_RV_DM_DBG_BASE_ADDR and
/// `TOP_DARJEELING_RV_DM_DBG_BASE_ADDR + TOP_DARJEELING_RV_DM_DBG_SIZE_BYTES`.
pub const TOP_DARJEELING_RV_DM_DBG_SIZE_BYTES: usize = 0x200;
/// Peripheral base address for soc device on mbx_jtag in top darjeeling.
///
/// This should be used with #mmio_region_from_addr to access the memory-mapped
/// registers associated with the peripheral (usually via a DIF).
pub const TOP_DARJEELING_MBX_JTAG_SOC_BASE_ADDR: usize = 0x1000;

/// Peripheral size for soc device on mbx_jtag in top darjeeling.
///
/// This is the size (in bytes) of the peripheral's reserved memory area. All
/// memory-mapped registers associated with this peripheral should have an
/// address between #TOP_DARJEELING_MBX_JTAG_SOC_BASE_ADDR and
/// `TOP_DARJEELING_MBX_JTAG_SOC_BASE_ADDR + TOP_DARJEELING_MBX_JTAG_SOC_SIZE_BYTES`.
pub const TOP_DARJEELING_MBX_JTAG_SOC_SIZE_BYTES: usize = 0x20;

/// MMIO Region
///
/// MMIO region excludes any memory that is separate from the module
/// configuration space, i.e. ROM, main SRAM, and flash are excluded but
/// retention SRAM, spi_device memory, or usbdev memory are included.
pub const TOP_DARJEELING_MMIO_BASE_ADDR: usize = 0x1000;
pub const TOP_DARJEELING_MMIO_SIZE_BYTES: usize = 0x20000;
Loading

0 comments on commit 32ad6ff

Please sign in to comment.