Closed
Description
(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
andl
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 ani16
, 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):
- Limit the types that can be put into the map. Start with int and bool, and define a clear interpretation for them.
- 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.