[libre-riscv-dev] div/mod algorithm written in python

Luke Kenneth Casson Leighton lkcl at lkcl.net
Sat Jun 29 11:04:33 BST 2019


On Sat, Jun 29, 2019 at 10:46 AM Jacob Lifshay <programmerjake at gmail.com> wrote:
>
> I completed the integer div/mod algorithm for simulation/testing and will
> be adding fixed-point sqrt/rsqrt next.

 exccellent.

>  Those are the operations that handle
> the mantissas for fdiv/fsqrt/frsqrt.

 perfect - just what's needed.  the function "calculate_stage" is what
goes into div1.py


> See:
> https://git.libre-riscv.org/?p=ieee754fpu.git;a=blob;f=src/ieee754/div_rem_sqrt_rsqrt/algorithm.py;h=74b7dec16164390576ab6bd741400e4eaa2a362a;hb=HEAD
>
> after the algorithms work in simulation, I'll convert to nmigen and wire
> into the fp pipeline.
>
> I'm planning on having the whole fpdiv pipe in the div_rem_sqrt_rsqrt
> folder, I just haven't gotten around to it.

 yeh please don't do that - stick to the structure that's already pre-defined:

 ieee754/fpvid/*
 ieee754/fpmul/*
 ieee754/fpadd/*
 ieee754/fpsqrt/*

so "calculate_stage" is what is called in ieee754/fpdiv/div1.py,
taking its data _from_ the self.i object which is in ispec() format -
these become the input parameters to class UnsignedDivRem - , and
outputting its data _to_ self.o which is in ospec() format.

that's difficult to do at the moment because
UnsignedDivRem.calculate_stage overwrites its variables (self.quotient
|= rather than returning the computed quotient_bit).

once that's sorted, calculate_stage will drop into place nicely.

l.



More information about the libre-riscv-dev mailing list