import java.math.BigInteger;
import java.util.Random;
+import java.util.stream.LongStream;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import net.mograsim.logic.core.timeline.Timeline;
import net.mograsim.logic.core.types.Bit;
private Timeline t = new Timeline(10);
- @Test
- public void wordAddressableMemoryLargeTest()
+ @ParameterizedTest(name = "seed = {0}")
+ @MethodSource("seedsForRandom")
+ public void wordAddressableMemoryLargeTest(long seed)
{
CoreWire rW = new CoreWire(t, 1, 2);
CoreWire data = new CoreWire(t, 16, 2);
new WordAddressableMemory(MainMemoryDefinition.create(64, 16, 4096L, Long.MAX_VALUE)), data.createReadWriteEnd(),
rW.createReadOnlyEnd(), address.createReadOnlyEnd());
- Random r = new Random();
+ Random r = new Random(seed);
for (long j = 1; j > 0; j *= 2)
{
- for (int i = 0; i < 50; i++)
+ for (int i = 0; i < 100; i++)
{
- String sAddress = String.format("%64s", BigInteger.valueOf(4096 + i + j).toString(2)).replace(' ', '0');
- BitVector bAddress = BitVector.parse(sAddress);
+ BitVector bAddress = BitVector.from(4096 + i + j, 64);
addressI.feedSignals(bAddress);
t.executeAll();
String random = BigInteger.valueOf(Math.abs(r.nextInt())).toString(5);
dataI.clearSignals();
t.executeAll();
- assertEquals(dataI.getValues(), vector);
+ assertEquals(dataI.getValues(), vector, "seed=" + seed + ", j=" + j + ", i=" + i);
}
}
}
+ public static LongStream seedsForRandom()
+ {
+ return LongStream.range(0, 100);
+ }
}