using System; namespace CPUSimulation { public class CPU { static Random _random = new Random(); static MC _memoryController; public static void Main(string[] args) { _memoryController = new MC(4, 32768); for (int i = 0; i < 32768; i++) { Word dataToWrite = GenerateRandomWord(_random.Next(1, 5)); _memoryController.Write((Int16)i, dataToWrite); Word dataRead = _memoryController.Read((Int16)i); Console.WriteLine($"Data read from address {new Address((Int16)i).ToString()}: {dataRead.ToString()}"); } } private static Word GenerateRandomWord(int byteCount) { //Console.WriteLine($"Generating random word with {byteCount} bytes."); Byte[] bytes = new Byte[byteCount]; for (int i = 0; i < byteCount; i++) { bytes[i] = GenerateRandomByte(); } return new Word(bytes); } private static Byte GenerateRandomByte() { Bit[] bits = new Bit[8]; for (int i = 0; i < 8; i++) { bits[i] = new Bit(_random.Next(2) == 1); } return new Byte(bits); } } }