kvasir-io / HardwareDescriptionFileGenerator

Generator for KVASIR hardware description files
2 stars 2 forks source link

Allow for alternateGroup #7

Open jacquelinekay opened 7 years ago

jacquelinekay commented 7 years ago

https://www.keil.com/pack/doc/CMSIS/SVD/html/elem_registers.html

"A register description is defined either for a unique address location or could be a redefinition of an already described address. In the latter case, the register can be either marked alternateRegister and needs to have a unique name, or it can have the same register name but is assigned to a register subgroup through the tag alternateGroup (specified in version 1.0)."

The TI boards exercise this feature, including:

TM4C1233D5PM
TM4C1237E6PM
TM4C123GH6ZRB
jacquelinekay commented 7 years ago

My initial solution for this isn't quite correct.

I decided to simply append the fields of the register redefinition to the original register.

I'm now running into a problem with ATSAMD21E16A where a register redefinition using "alternateGroup" redefines a field with the same name as the original field.

I think the correct solution is to encapsulate register groups in a different namespace. I believe a register group is simply a different naming schema for the same set of registers. So for example, the baud rate register group "A" for a register can be A::baud and B::baud for register group B.

The use case for this is fields with the same name but different bit widths. For example, the board in question offers a fractional mode for the baud rate register: default_mode::baud has a bit width of 16 and frac_mode::baud has a bit width of 13, with an additional field frac_mode::fp with a bit width of 3.