Skip to content

hidden fields are not handled on write only register #307

@krcb197

Description

@krcb197

PeakRDL Python allows some instance names to be hidden, e.g. RSVD.

The write_fields method of a Write Only Register forces all fields in a register to execute a single write, which is needed as a read-modify-write is not possible and generally write only registers have hardware actions associated with them. The function signature of the write_fields method needs to have all currently accessible fields as arguments

Consider the following system rdl:

addrmap reserved_elements {
        reg  {
        default sw = w;
        default hw = r;
        field { fieldwidth=1; } RSVD;
        field { fieldwidth=1; } field_a;
    } write_only_register;

When this is exported with hidden_inst_name_regex set to None, the following will be generated:

    def write_fields(self,RSVD : int,field_a : int) -> None: # type: ignore[override]
        """
        Do a write to the register, updating all fields
        """
        reg_value = 0

        reg_value &= self.RSVD.inverse_bitmask
        reg_value |= self.RSVD._encode_write_value(RSVD)
        
        reg_value &= self.field_a.inverse_bitmask
        reg_value |= self.field_a._encode_write_value(field_a)
        
        self.write(reg_value)

However, when the hidden_inst_name_regex set to "(?:[\w_\[\]]+\.)+RSVD", the following will be generated:

    def write_fields(self,field_a : int) -> None: # type: ignore[override]
        """
        Do a write to the register, updating all fields
        """
        reg_value = 0       

        reg_value &= self.field_a.inverse_bitmask
        reg_value |= self.field_a._encode_write_value(field_a)
        
        self.write(reg_value)

This is not the case

The problem is that the template was using the children iterator from the underlying the system rdl compiler and not the filtered version.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions