vram/VRAMCore: cycle using prime numbers in tests

VRAMs are powers of two, so if memory wiring is wrong and we end up
with ram blocks mirrored at several points in the address space, we
want a write pattern that doesn't repeat cleanly on power of two
blocks. That way, a mirrored memory block cannot contain values that
are valid for all its locations.
This commit is contained in:
David Anderson 2024-09-09 11:27:50 -07:00
parent 719339e69f
commit b46d70fa07
1 changed files with 10 additions and 2 deletions

View File

@ -38,8 +38,16 @@ module mkIncrementingValue(ValFn);
function ActionValue#(Bit#(8)) next();
return (actionvalue
val <= val+1;
return val;
// Cycle through 101 values. 101 is prime, so the
// pattern it generates doesn't align to a power of
// two and should detect any memory mapping errors.
if (val == 100)
val <= 0;
else
val <= val+1;
// Add another number to get all nonzero values, to
// detect writes that don't stick.
return 23+val;
endactionvalue);
endfunction