项目作者: qu1x

项目描述 :
Memory Initialization File
高级语言: Rust
项目地址: git://github.com/qu1x/mif.git
创建时间: 2020-08-11T11:00:49Z
项目社区:https://github.com/qu1x/mif

开源协议:

下载


Build Status
Downloads
Rust
Version
Documentation
License

mif

Memory Initialization File

Features

  • Native MIF representation as Vec<(word: T, bulk: usize)>.
  • Detects single-word sequence [first..last]: word but does not
    detect multi-word sequence [first..last]: words.. in binary data.
  • Verifies word fits into MIF’s word width in bits.
  • Joins multiple MIFs of different word widths as long as words fit.
  • Optionally comments join offsets in words with given (file) names.
  • Provides simple mif dump subcommand.
  • Provides reproducible mif join subcommand via TOML instruction file.

Library

MIF creation and serialization is implemented for the Mif structure.

Disable default features like cli and bin to reduce dependencies:

  1. [dependencies]
  2. mif = { version = "0.3", default-features = false }

Default features:

  • cli: Provides command-line interface functionality of mif binary.

    Requires: anyhow, indexmap, serde, toml

  • bin: Enables compilation of mif binary.

    Requires: cli, clap

Command-line Interface

Install via cargo install mif.

Provides two subcommands, dump and join.

  1. mif 0.3.0
  2. Rouven Spreckels <rs@qu1x.dev>
  3. Memory Initialization File
  4. USAGE:
  5. mif <SUBCOMMAND>
  6. OPTIONS:
  7. -h, --help Prints help information
  8. -V, --version Prints version information
  9. SUBCOMMANDS:
  10. dump Dumps binary as MIF
  11. join Joins binaries' memory areas to MIFs
  12. help Prints this message or the help of the given subcommand(s)

Dump Subcommand

  1. mif-dump
  2. Dumps binary as MIF
  3. USAGE:
  4. mif dump [input]
  5. ARGS:
  6. <input> Input file or standard input (-) [default: -]
  7. OPTIONS:
  8. -w, --width <bits> Word width in bits from 1 to 128 [default: 16]
  9. -f, --first <lsb|msb> LSB/MSB first (little/big-endian) [default: lsb]
  10. -h, --help Prints help information
  11. -V, --version Prints version information

Join Subcommand

  1. mif-join
  2. Joins binaries' memory areas to MIFs
  3. USAGE:
  4. mif join [OPTIONS] [toml]
  5. ARGS:
  6. <toml> TOML file or standard input (-) [default: -]
  7. OPTIONS:
  8. -i, --bins <path> Input directory [default: .]
  9. -o, --mifs <path> Output directory [default: .]
  10. -n, --no-comments No comments in MIFs
  11. -h, --help Prints help information
  12. -V, --version Prints version information

Join Example

Assuming two ROM dumps, a.rom and b.rom, whose program and data areas
are concatenated as in:

  • cat a.program.rom a.data.rom > a.rom
  • cat b.program.rom b.data.rom > b.rom

Following TOML file defines how to join both program areas to one MIF and
both data areas to another MIF, assuming 24-bit program words of depth 1267
and 1747 and 16-bit data words of depth 1024 each. Additionally, every area
is dumped to its own separate MIF for verification. Then, between program
and data area is supposed to be an unused area of 0xffffff words, which
should be skipped. Listing them in the skips instruction will verify that
this area only contains these words.

  1. [["a.rom"]]
  2. first = "lsb" # Least-significant byte first. Default, can be omitted.
  3. width = 24
  4. depth = 1267
  5. joins = ["a.prog.mif", "ab.prog.mif"]
  6. [["a.rom"]]
  7. first = "lsb" # Least-significant byte first. Default, can be omitted.
  8. width = 24
  9. depth = 781
  10. skips = [0xffffff] # Empty [] for skipping without verification.
  11. [["a.rom"]]
  12. first = "msb"
  13. width = 16 # Default, can be omitted.
  14. depth = 1024
  15. joins = ["a.data.mif", "ab.data.mif"]
  16. [["b.rom"]]
  17. width = 24
  18. depth = 1747
  19. joins = ["b.prog.mif", "ab.prog.mif"]
  20. [["b.rom"]]
  21. width = 24
  22. depth = 301
  23. skips = [0xffffff]
  24. [["b.rom"]]
  25. depth = 1024
  26. joins = ["b.data.mif", "ab.data.mif"]

License

Dual-licensed under MIT OR Apache-2.0.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the works by you shall be licensed as above, without any
additional terms or conditions.