Origen-SDK / o2

MIT License
4 stars 0 forks source link

Register model support for SET, CLR and INV registers? #78

Open redxeth opened 4 years ago

redxeth commented 4 years ago

On many SOCs there are these convenience SET, CLR, INV registers that server to help modify individual bits of another 'real' register. Often times these are clearly defined in the XML (or other source) already but the issue was that in Origen(1) the register don't work as intended.

i.e.

reg.value = 0x00000000
reg_clr.set 0xF0000000    # should set bits 28-31 of reg but doesn't 
                          # and these bits should clear as well.

How do we support these in O2?

ginty commented 4 years ago

Not sure about this one, its getting into the realm of modelling the external effects of register changes which is generally beyond the scope of what Origen can do - obviously there's a million and one other ways that writing a given register can cause changes in another register that we don't model.

This could be handled in the application's main write_register method. Where it would be on the lookout for writes to one of these special registers and then update the data value of the 3rd party register as required.

However, we could also make an exception and handle this in Origen if it is viewed as generally useful. My main question then would be how do you think we should express this linkage in Origen?

IP-XACT has no way to express something like this btw.

redxeth commented 4 years ago

I get that. Just had direct experience on another project with this and thought would bring it up for discussion. Would like to know @chrisnappi 's thoughts.

ginty commented 4 years ago

Here's the current reg definition API:

    # This is the reg description
    with Reg("adc_ctrl", 0x0024, size=16):
        # This is the COCO description
        Field("coco", offset=7, access="ro")
        Field("aien", offset=6)
        Field("diff", offset=5)
        Field("adch", offset=0, width=5, reset=0x1F, enums={
            # A simple enum
            "val1": 3,
            # A more complex enum, all fields except for value are optional, it will probably
            # eventually support assigning the description from this comment
            "val2": { "value": 5, "usage": "w", "description": "The value of something"},
        })

How would we expand that to describe this behavioral linkage between registers?