WRITE-only Registers #117
Replies: 2 comments 1 reply
-
Comments from SRM 27022025harp json-schema
AlternativesInstead of disabling reads, we could be explicit of what the default value should be for these registers. |
Beta Was this translation helpful? Give feedback.
-
It wasn't my focus, but I found another example of this type of register existing in the Harp Soundcard. Specifically the The written value chooses between those functions, they appear to always read as 0. (Implementation here.) |
Beta Was this translation helpful? Give feedback.
-
I think there's some utility in having WRITE-only registers.
Here's an example for configuring a row of 8 digital outputs via bitmasks:
Here, it's ambiguous as to what it means to perform a Harp
READ
onDO_Set
andDO_Clear
. Do they reflect the raw value of the 8 GPIOs? Do they represent the last value set?Here's where a
WRITE-ONLY
register makes sense forDO_Set
andDO_Clear
. Writing to this register would return aWRITE_REPLY
of what was actually written, but reading this register would result in aREAD_ERROR
reply.Benefits/Implications
I think the main change is being able to more directly attach functions to registers where the corresponding register size/content has nothing to do with the device behavior, like triggering a void function (function that returns nothing) with multiple input parameters.
This change asks us to reconsider what's on the other side of a Harp Register. Currently, although not explicitly, the Register abstraction invites us to think about registers as data, i.e: "Registers" represent some sort of actual memory location on the device. Having write-only registers loosens this abstraction, and enables us to think about registers either as data, or more broadly as endpoints that trigger device behaviors (i.e: function pointers, remote procedure calls, etc.).
Other Changes
We would need to change the DUMP core register to not dump write-only registers.
Beta Was this translation helpful? Give feedback.
All reactions