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

Communicating constants from the peripheral to the BSP generator #24

Closed
jfng opened this issue Aug 10, 2020 · 0 comments · Fixed by #25
Closed

Communicating constants from the peripheral to the BSP generator #24

jfng opened this issue Aug 10, 2020 · 0 comments · Fixed by #25
Labels

Comments

@jfng
Copy link

@jfng jfng commented Aug 10, 2020

(discussed during the 06/07 IRC meeting - log).

Examples of constants:

  • clock frequency (if there is only a single one for the core)
  • divisors
  • FIFO sizes
  • functional unit counts, for peripherals/cores with configurable sizes

Constants could be associated both to individual CSRs (e.g. counter time limit) or to an entire peripheral (e.g clock frequency).

Different languages represent constants in different ways:

  • in C, large integers must be appended a combination of u and l suffixes. You can often get away with #define'ing a constant.
  • in Rust, you need to know both size and signedness in order to decide whether to use an u8, or an i16, etc.
  • floating point numbers need special treatment in languages without first class support for them
  • strings may have different encodings e.g. UTF-8, UTF-16, etc.

Name bikeshedding: ConstantDict or ConstantMap

  • not ConfigDict since its scope should be limited to constants only
  • ConstantMap seems preferred

Nesting:

  • provide a way for complex peripherals (e.g. a DRAM controller) to organize constants in a hierarchy
  • hierarchies should preferably be implemented by an external class, instead of being the responsibility of the ConstantMap class itself.

Approach for the next iteration (first attempt was in #19):

  1. Limit the types that can be put into the map. Start with int and bool, and define a clear interpretation for them.
  2. No ConstantMap nesting for now. Once we have a working BSP generator, we should have a better idea of how nesting would work/be used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

1 participant