public void RAMWorks() { RAM r = new RAM(8,8); TestRam(r, 0); //reset CompareBitArray(new bool[] { false, false, false, false, false, false, false, false }, new bool[] { false, false, false, false, false, false, false, false }, r, true, 0); TestRam(r, 0); TestRam(r, 1); CompareBitArray(new bool[] { false, false, false, false, false, false, false, false }, new bool[] { false, false, false, false, false, false, false, false }, r, true, 1); TestRam(r, 1); TestRam(r, 2); TestRam(r, 3); TestRam(r, 4); TestRam(r, 5); TestRam(r, 6); TestRam(r, 7); }
void TestRam(RAM r, int address) { CompareBitArray(new bool[] { true, true, true, true, true, true, true, true }, new bool[] { false, false, false, false, false, false, false, false }, r, false, address); CompareBitArray(new bool[] { true, true, true, true, true, true, true, true }, new bool[] { true, true, true, true, true, true, true, true }, r, true, address); CompareBitArray(new bool[] { true, true, true, true, true, true, true, true }, new bool[] { true, true, true, true, true, true, true, true }, r, false, address); CompareBitArray(new bool[] { true, false, true, false, true, false, true, false }, new bool[] { true, true, true, true, true, true, true, true }, r, false, address); CompareBitArray(new bool[] { true, false, true, false, true, false, true, false }, new bool[] { true, false, true, false, true, false, true, false }, r, true, address); CompareBitArray(new bool[] { true, true, true, true, true, true, true, true }, new bool[] { true, false, true, false, true, false, true, false }, r, false, address); }
void CompareBitArray(bool[] source, bool[] compareTo, RAM r, bool load, int address) { var output = r.Cycle(source, load,address); for (int i = 0; i < output.Length; i++) { Assert.AreEqual(output[i], compareTo[i]); } }