Skip to content

Commit

Permalink
Address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
romancardenas committed Oct 20, 2024
1 parent b4bf5a9 commit b198aec
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Implement `riscv-pac` traits via experimental `riscv` element in SVD.
You must use the `unstable-riscv` feature to use this.
- Use standard `riscv-peripheral` peripherals via experimental `riscv.yaml` configuration file.
You must compile `svd2rust` with the `unstable-riscv` feature to use this.
- Implement `riscv-pac` traits via experimental `riscv.yaml` configuration file.
You must compile `svd2rust` with the `unstable-riscv` feature to use this.
- Add warning about indexing register arrays
- Skip generating `.add(0)` and `1 *` in accessors
- Bump MSRV of generated code to 1.76
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ default = ["bin", "json", "yaml"]
bin = ["dep:clap", "dep:env_logger", "serde", "dep:irx-config"]
json = ["dep:serde_json"]
yaml = ["dep:serde_yaml"]
unstable-riscv = []
unstable-riscv = ["irx-config/yaml"]

[dependencies]
clap = { version = "4.0", optional = true }
Expand Down
31 changes: 29 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![recursion_limit = "128"]

use log::{debug, error, info, warn};
#[cfg(feature = "unstable-riscv")]
use svd2rust::config::RiscvConfig;
use svd2rust::config::{IdentFormatError, IdentFormats, IdentFormatsTheme};
use svd2rust::util::IdentFormat;

Expand All @@ -18,6 +20,8 @@ use svd2rust::{
};

fn parse_configs(app: Command) -> Result<Config> {
#[cfg(feature = "unstable-riscv")]
use irx_config::parsers::yaml;
use irx_config::parsers::{cmd, toml};
use irx_config::ConfigBuilder;
let ident_formats = app.clone().get_matches();
Expand All @@ -29,10 +33,24 @@ fn parse_configs(app: Command) -> Result<Config> {
.path_option("config")
.ignore_missing_file(true)
.build()?,
)
.load()?;
);
#[cfg(feature = "unstable-riscv")]
let irxconfig = irxconfig.append_parser(
yaml::ParserBuilder::default()
.default_path("riscv.yaml")
.path_option("riscv_cfg")
.ignore_missing_file(true)
.build()?,
);
let irxconfig = irxconfig.load()?;

let mut config: Config = irxconfig.get()?;

#[cfg(feature = "unstable-riscv")]
if let Ok(riscv_config) = irxconfig.get::<RiscvConfig>() {
config.riscv_config = Some(riscv_config);
}

let mut idf = match config.ident_formats_theme {
Some(IdentFormatsTheme::Legacy) => IdentFormats::legacy_theme(),
_ => IdentFormats::default_theme(),
Expand Down Expand Up @@ -290,6 +308,15 @@ Ignore this option if you are not building your own FPGA based soft-cores."),
env!("CARGO_PKG_VERSION"),
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
));
#[cfg(feature = "unstable-riscv")]
let app = app.arg(
Arg::new("riscv_cfg")
.long("riscv_config")
.help("RISC-V Config YAML file")
.short('r')
.action(ArgAction::Set)
.value_name("YAML_FILE"),
);

let mut config = match parse_configs(app) {
Ok(config) => {
Expand Down

0 comments on commit b198aec

Please sign in to comment.