From b46d70fa070847d237c6c4285abd1a3dfe1d72b1 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 9 Sep 2024 11:27:50 -0700 Subject: [PATCH] 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. --- vram/VRAMCore_Test.bsv | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vram/VRAMCore_Test.bsv b/vram/VRAMCore_Test.bsv index 6f0c1df..6923e5e 100644 --- a/vram/VRAMCore_Test.bsv +++ b/vram/VRAMCore_Test.bsv @@ -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