Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add base-address-shift configuration flag #791

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Add `base-address-shift` config flag

## [v0.31.5] - 2024-01-04

- `move` in `RegisterBlock::reg_iter` implementation (iterator of register/cluster array)
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct Config {
pub reexport_core_peripherals: bool,
pub reexport_interrupt: bool,
pub ident_formats: IdentFormats,
pub base_address_shift: u64,
}

#[allow(clippy::upper_case_acronyms)]
Expand Down
4 changes: 2 additions & 2 deletions src/generate/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
let span = Span::call_site();
let p_ty = ident(&name, &config.ident_formats.peripheral, span);
let name_str = p_ty.to_string();
let address = util::hex(p.base_address);
let address = util::hex(p.base_address + config.base_address_shift);
let description = util::respace(p.description.as_ref().unwrap_or(&p.name));

let mod_ty = name.to_snake_case_ident(span);
Expand Down Expand Up @@ -83,7 +83,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
let description = pi.description.as_deref().unwrap_or(&p.name);
let p_ty = ident(name, &config.ident_formats.peripheral, span);
let name_str = p_ty.to_string();
let address = util::hex(pi.base_address);
let address = util::hex(pi.base_address + config.base_address_shift);
let p_snake = name.to_sanitized_snake_case();
snake_names.push(p_snake.to_string());
let mut feature_attribute_n = feature_attribute.clone();
Expand Down
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@ fn run() -> Result<()> {
.action(ArgAction::SetTrue)
.help("Reexport interrupt macro from cortex-m-rt like crates"),
)
.arg(
Arg::new("base_address_shift")
.short('b')
.long("base-address-shift")
.alias("base_address_shift")
.action(ArgAction::Set)
.help("Add offset to all base addresses on all peripherals in the SVD file.")
.long_help("Add offset to all base addresses on all peripherals in the SVD file.
Useful for soft-cores where the peripheral address range isn't necessarily fixed.
Ignore this option if you are not building your own FPGA based soft-cores."),
)
.arg(
Arg::new("log_level")
.long("log")
Expand Down
Loading