from ram_controller import RAMController
import random

RAM_SIZE_BYTES = 1024 * 1024 * 16  # 16 MB of RAM

def demo():
    print(f"Virtual RAM Demo: {RAM_SIZE_BYTES / (1024 * 1024):.2f} MB")
    ram = RAMController(RAM_SIZE_BYTES)

    print("\nWriting sequential data to RAM:")
    for i in range(0, 1024, 16):
        data = [random.randint(0, 255) for _ in range(16)]
        ram.write(i, data)
        if i < 64:
            print(f"Address {i}: Data (first 16 bytes) {data}")

    print("\nReading sequential data from RAM:")
    for i in range(0, 1024, 16):
        read_data = ram.read(i, 16)
        if i < 64:
            print(f"Address {i}: Read Data (first 16 bytes) {list(read_data)}")

    print("\nWriting random data to RAM:")
    for _ in range(10):
        address = random.randint(0, RAM_SIZE_BYTES - 16)
        data = [random.randint(0, 255) for _ in range(16)]
        ram.write(address, data)
        print(f"Address {address}: Data (first 16 bytes) {data}")

    print("\nReading random data from RAM:")
    for _ in range(10):
        address = random.randint(0, RAM_SIZE_BYTES - 16)
        read_data = ram.read(address, 16)
        print(f"Address {address}: Read Data (first 16 bytes) {list(read_data)}")

if __name__ == "__main__":
    demo()


