Skip to content

Field aliases should inherit attributes #781

Open
@ThinkOpenly

Description

@ThinkOpenly

Is your feature request related to a problem? Please describe.
There are many cases where a CSR field is simply an alias of field in another CSR (search for "alias" in the CSR definitions). Currently, the alias field simply serves as a pointer from one bit to another, and all other attributes associated with the field must be duplicated for the alias. For example, the MBE field in

MBE:
location: 37
base: 64
description: |
*M-mode Big Endian*
Controls the endianness of data M-mode (0 = little, 1 = big).
Instructions are always little endian, regardless of the data setting.
[when,"M_MODE_ENDIANNESS == little"]
Since the CPU does not support big endian, this is hardwired to 0.
[when,"M_MODE_ENDIANNESS == big"]
Since the CPU does not support little endian, this is hardwired to 1.
type(): |
return (M_MODE_ENDIANNESS == "dynamic") ? CsrFieldType::RW : CsrFieldType::RO;
# if endianness is mutable, MBE comes out of reset in little-endian mode
reset_value(): |
return (M_MODE_ENDIANNESS == "big") ? 1 : 0;

and it's alias in

MBE:
location: 5
description: |
see `mstatus.MBE`
type(): 'return (M_MODE_ENDIANNESS == "dynamic") ? CsrFieldType::RW : CsrFieldType::RO;'
reset_value(): 'return (M_MODE_ENDIANNESS == "big") ? 1 : 0;'
alias: mstatus.MBE

Fields which are not location-specific ("type()", "reset_value()") are duplicated, and "description" is only a reference. Since these fields can be non-trivial, as seen above, duplication can be error-prone.

Describe the solution you'd like
Fields which are not location-specific (or perhaps fields which are not overridden by the alias definition) should be inherited from the aliased field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions