[libre-riscv-dev] [Bug 71] replace SetAssocCache PLRU with random selection (LFSR)
bugzilla-daemon at libre-riscv.org
bugzilla-daemon at libre-riscv.org
Mon Apr 22 17:09:36 BST 2019
http://bugs.libre-riscv.org/show_bug.cgi?id=71
--- Comment #5 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Jacob Lifshay from comment #4)
> I finished a comprehensive LFSR implementation:
> https://git.libre-riscv.org/?p=soc.git;a=blob;f=TLB/src/LFSR2.py;
> h=8cdb2cc560ca9a28e88d7e96e81213da2c44bf3d;hb=HEAD
excellent. i like the split of the polynomials, and the unit test's great.
> It appears as though Daniel was a little faster though
yes :) context:
http://lists.libre-riscv.org/pipermail/libre-riscv-dev/2019-April/001180.html
ironically it probably only took you what... 45 minutes to write?
i've been doing review/code-morph for about 2.5 hours so far (!)
https://youtu.be/dljWBXSBGYw
even after that i found some more things (which make the code even shorter,
and more "direct use of python features")
http://lists.libre-riscv.org/pipermail/libre-riscv-dev/2019-April/001181.html
every time i look at it there's another way to reduce the code by another
line or two. LFSR2.__init__ i managed to remove 2 more lines of code just
now:
def __init__(self, exponents=()):
for e in exponents:
assert isinstance(e, int), TypeError("%s must be an int" % repr(e))
assert (e >= 0), ValueError("%d must not be negative" % e)
set.__init__(self, set(exponents).union({0})) # must contain zero
the exponents can be a list, tuple, set, dictionary, generator, iterator
or another LFSRPolynomial (which is derived from a set) and it doesn't
matter, they all get converted to a set, zero is union'd into it, and
because the result of the union is a new set, that new set is returned
to the constructor of set.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the libre-riscv-dev
mailing list