[libre-riscv-dev] div/mod algorithm written in python
Jacob Lifshay
programmerjake at gmail.com
Wed Jul 3 07:14:23 BST 2019
On Tue, Jul 2, 2019 at 10:54 PM Luke Kenneth Casson Leighton
<lkcl at lkcl.net> wrote:
>
> On Wed, Jul 3, 2019 at 5:52 AM Jacob Lifshay <programmerjake at gmail.com> wrote:
>
> > I implemented FixedSqrt and FixedRSqrt and they pass all tests.
>
> great. btw, do try to avoid using functions with the word "test" in
> them unless they're an actual unit test (shorten to tst or something)
> - nosetests3 .../test_xxx.py throws several errors.
Pushed a fix.
I would consider it a bug in nosetests3, since python's built-in
unittest module only uses functions that match the regex "^test.*" (or
so I would assume from it's behavior).
> > I
> > think I'll create a combined class that can compute all of
> > div/rem/fixed-sqrt/fixed-rsqrt before converting to nmigen since
> > python is easier to read/write than nmigen.
>
> sigh indeed. not sure if there's much that can be done about that,
> although i have started doing this at the top of functions:
> comb = m.d.comb
> sync = m.d.sync
>
> it reduces indentation by 4 and allows things to fit onto one line in
> many cases.
For me, I've mostly given up on fitting things on one line, and am
using bigger names that don't need to be unabbreviated extensively
before it's understandable. For the final algorithm, I'm trying to
make it relatively easy to see how it matches up with the
next-less-complex version, even if it's too complex to readily
understand without the next-less-complex version as a reference.
Jacob
More information about the libre-riscv-dev
mailing list