jeudi 27 février 2020

low-memory pseudo-random shuffle for fixed arbitrary length array

Context: I'm writing an external SRAM tester for a micro-controller based embedded system. No security, no cryptography involved. For a reproducible access to "as-non-consecutive-as-possible" memory locations, I'm looking for an implementation of

y = shuffle(x), taking and returning an integer between 0 and a fixed N = 2^16 - 1

It may not use lot of RAM itself, as e.g. a naive shuffled array of addresses would. On the upside, it is allowed to be slow. No strict definition of non-consecutive - it's about bumping address lines up and down, hunting for soldering and other faults of the printed circuit board. Suggestions?

I found so far Knuth shuffle a.k.a. Fisher-Yates shuffle.




Aucun commentaire:

Enregistrer un commentaire