Exemplo n.º 1
0
def mem_cache_rwx_write_test():
    mem = MemoryCache(0x100, 0x210)
    # build cache contents
    mem.w8(0x100, 42)
    assert mem.r8(0x100) == 42
    mem.w16(0x200, 0xdead)
    assert mem.r16(0x200) == 0xdead
    mem.w32(0x300, 0xcafebabe)
    assert mem.r32(0x300) == 0xcafebabe
    mem.write(0, 0x101, 43)
    assert mem.read(0, 0x101) == 43
    mem.write(1, 0x202, 0x1234)
    assert mem.read(1, 0x202) == 0x1234
    mem.write(2, 0x304, 0x11223344)
    assert mem.read(2, 0x304) == 0x11223344
    # write to main mem
    main_mem = MockMemory()
    mem.write_cache(main_mem)
    # check main mem
    assert main_mem.r8(0x100) == 42
    assert main_mem.r16(0x200) == 0xdead
    assert main_mem.r32(0x300) == 0xcafebabe
    assert main_mem.read(0, 0x101) == 43
    assert main_mem.read(1, 0x202) == 0x1234
    assert main_mem.read(2, 0x304) == 0x11223344
Exemplo n.º 2
0
def mem_cache_rwx_write_test():
  mem = MemoryCache(0x100, 0x210)
  # build cache contents
  mem.w8(0x100, 42)
  assert mem.r8(0x100) == 42
  mem.w16(0x200, 0xdead)
  assert mem.r16(0x200) == 0xdead
  mem.w32(0x300, 0xcafebabe)
  assert mem.r32(0x300) == 0xcafebabe
  mem.write(0, 0x101, 43)
  assert mem.read(0, 0x101) == 43
  mem.write(1, 0x202, 0x1234)
  assert mem.read(1, 0x202) == 0x1234
  mem.write(2, 0x304, 0x11223344)
  assert mem.read(2, 0x304) == 0x11223344
  # write to main mem
  main_mem = MockMemory()
  mem.write_cache(main_mem)
  # check main mem
  assert main_mem.r8(0x100) == 42
  assert main_mem.r16(0x200) == 0xdead
  assert main_mem.r32(0x300) == 0xcafebabe
  assert main_mem.read(0, 0x101) == 43
  assert main_mem.read(1, 0x202) == 0x1234
  assert main_mem.read(2, 0x304) == 0x11223344
Exemplo n.º 3
0
def mem_cache_rwx_read_test():
    mem = MockMemory()
    # build main mem contents
    mem.w8(0x100, 42)
    assert mem.r8(0x100) == 42
    mem.w16(0x200, 0xDEAD)
    assert mem.r16(0x200) == 0xDEAD
    mem.w32(0x300, 0xCAFEBABE)
    assert mem.r32(0x300) == 0xCAFEBABE
    mem.write(0, 0x101, 43)
    assert mem.read(0, 0x101) == 43
    mem.write(1, 0x202, 0x1234)
    assert mem.read(1, 0x202) == 0x1234
    mem.write(2, 0x304, 0x11223344)
    assert mem.read(2, 0x304) == 0x11223344
    # write to cache
    cmem = MemoryCache(0x100, 0x210)
    cmem.read_cache(mem)
    # check cache mem
    assert cmem.r8(0x100) == 42
    assert cmem.r16(0x200) == 0xDEAD
    assert cmem.r32(0x300) == 0xCAFEBABE
    assert cmem.read(0, 0x101) == 43
    assert cmem.read(1, 0x202) == 0x1234
    assert cmem.read(2, 0x304) == 0x11223344