Say I'm creating a RISC-V core, but want to base it on Posits. What is the *minimal* effort to get an as *useful of a result as possible*?
I'm sure this has been considered and debated already (and I apologize for missing it). I have seen John's RISC-V embedding, but I would consider a different approach:
# Strawman
Ignoring FP64 (double precision) for the moment, make all existing FP instructions use Posits. Some instruction become nops, others have no equivalents and becomes illegal instructions. With this approach, you'd essentially would only need to change the compilers/assemblers to emit posit constants instead of floats. You almost certainly will have to tweak libraries like libm and libc (the latter not much I suspect).
(Variation of the above: introducing dedicated Posit load/store instructions, making the original float load/store (flw/fsw) load/store IEEE-754 numbers and convert to/from Posit (and trap for NaN).)
For FP64 could might either expand it to Posit64 or simply map everything to Posit32.
# The Quine
This is an orthogonal issue and it's a bit of an awkward beast, but here's one option I'm considering that would allow most existing code to use the quine transparently:
- there are one [or more] quines
- at any point in time, a quine is either free or associated with an fp register
- a use of an fp register associated with a quine will convert the quine, update the fp register, and disassociate the quine (freeing it)
- an fma instruction, say fmadd.s rd,rs1,rs2,rs3 will allocate a free quine and associate it with rd.
- a special exception to the above: if rs3 is associated with quine, then ownership is transferred to rd.
Thus, an an example,
flw fs7, ...
fmadd fs7, fs1, fs2, fs7
fmadd fs7, fs3, fs4, fs7
fsw fs7, ....
will perform the two element dot-product using the quine without even having to know about it.
For context switching needs, there will be a way to save and restore the quine(s) via CSRs, TBD.
Admittedly there are rough edges here, but again, the focus was not on a perfect solution, but on a solution that would require minimal changes to compilers and libraries.
Thoughts, flames?
Tommy
Disclaimer: opinions are my own and doesn't in any way reflect anything about my employer