hi, just so people know: obviously for a GPU and a modern CPU, an IEEE754 floating-point unit is essential. however, as you also know, verilog is an old language that would require macro-expansion of some form to modernise it with something approximating OO programming. for the libre riscv CPU/GPU we've chosen nmigen, instead, as it outputs verilog and still allows modern OO programming techniques to be used.
despite the fact that the IEEE754 FP unit is needed *for* the libre riscv CPU/GPU, it is important to note that the work is being done in a completely separate repo, to ensure that it is absolutely clear that this work is for *general* wider use.
we've started from jon dawson's excellent verilog IEEE754 FP code and have begun a process of conversion to nmigen, with a successful initial conversion of the adder, here: https://git.libre-riscv.org/?p=ieee754fpu.git;a=tree;f=src/add
the similarity between the various modules of jon dawson's code - not just 32-bit compared to 64-bit, also how the add is done vs multiply or divide - are striking, meaning that there is *significant* code duplication.
we will be removing *all* of the code-duplication with python OO programming techniques. base classes sharing the common functionality between all modules. class parameterisation so that FP16, FP32 and FP64 all share the exact same code.
in addition we'll be making sure that the code is properly documented (not excessively so), and, crucially, will be converting it to a pipeline architecture. to achieve this pipeline conversion process, a python class that, fascinatingly, originally came from a PyRTL example, has been adapted for use with nmigen.
the current design - jon's original work - is a state machine with variable completion time. it's quite compact in that there are no single-cycle variable-length shifts used: instead, a single 1-bit shift is deployed with a variable-clock-cycle detection on when to end shifting.
obviously that cannot be preserved for a pipeline architecture, however it would be particularly interesting to try to preserve both designs within the same codebase.
if anyone would like to assist with this work you are most welcome: please do join the libre-riscv-dev mailing list http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev otherwise i am happy to answer questions on either of these lists.
l.
if anyone was ever in doubt about using an OO-based programming language for HDL:
* aleksander and i took a couple of days to work on converting jon dawson's excellent 32-bit adder.v to nmigen * i took another day to separate out some base classes * around 90 minutes to then have the divider.v converted (by doing diffs on adder.v and divider.v and using that to identify where to modify a copy of add.py to turn it into divide.py) * it's taken under an hour to modify the python-based Floating-point base class to support 64-bit * with the base class in place it then took *under 10 minutes* to modify the corresponding divider.py to support 64-bit as well
so what was originally 300 lines of verilog (adder.v) was duplicated for double-precision: the use of python classes has therefore cut the amount of code to be maintained in *half*, straight away, and there are further reductions of at least 20 to 30% by separating out common *parameterised* functionality into the base classes.
additional savings could be had if there wasn't so much white space and additional comments, however that would leave the code sterile and completely impossible to maintain.
nmigen rocks!
l.
On Sun, 2019-02-17 at 08:00 +0000, Luke Kenneth Casson Leighton wrote:
if anyone was ever in doubt about using an OO-based programming language for HDL:
- aleksander and i took a couple of days to work on converting jon
dawson's excellent 32-bit adder.v to nmigen
- i took another day to separate out some base classes
- around 90 minutes to then have the divider.v converted (by doing
diffs on adder.v and divider.v and using that to identify where to modify a copy of add.py to turn it into divide.py)
- it's taken under an hour to modify the python-based Floating-point
base class to support 64-bit
- with the base class in place it then took *under 10 minutes* to
modify the corresponding divider.py to support 64-bit as well
so what was originally 300 lines of verilog (adder.v) was duplicated for double-precision: the use of python classes has therefore cut the amount of code to be maintained in *half*, straight away, and there are further reductions of at least 20 to 30% by separating out common *parameterised* functionality into the base classes.
additional savings could be had if there wasn't so much white space and additional comments, however that would leave the code sterile and completely impossible to maintain.
nmigen rocks!
l.
Curious: What is the cycle time of the generated code versus native verilog code ?
rudi =============================================================== Rudolf Usselmann, ASICS World Services, LTD, www.asics.ws Your IP Partner: SAS 12G, SATA-3, USB-3, SD/MMC/SDIO, FEC, etc.
The agony of poor quality remains long after the joy of low cost has been forgotten
This email message may contain confidential and privileged information. Any unauthorized use is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
libresilicon-developers@list.libresilicon.com