MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / snapshot

Method snapshot

crates/virtual-machine/src/memory/cache.rs:469–496  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

467 block_size: 64,
468 associativity: 2,
469 write_back: true,
470 read_only: false,
471 };
472 Cache::new(params, ram)
473 }
474
475 // The aligned fast path must produce the same bytes as a byte-by-byte access.
476 #[test]
477 fn aligned_fast_path_roundtrip() {
478 let mut c = make_cache();
479 let base = 0x8000_0040; // line-aligned
480
481 c.write_doubleword(base, 0x0102_0304_0506_0708).unwrap();
482 c.write_word(base + 8, 0xAABB_CCDD).unwrap();
483 c.write_halfword(base + 12, 0xBEEF).unwrap();
484
485 assert_eq!(c.read_doubleword(base).unwrap(), 0x0102_0304_0506_0708);
486 assert_eq!(c.read_word(base + 8).unwrap(), 0xAABB_CCDD);
487 assert_eq!(c.read_halfword(base + 12).unwrap(), 0xBEEF);
488
489 // Byte view must agree with the wide stores (little-endian).
490 assert_eq!(c.read_byte(base).unwrap(), 0x08);
491 assert_eq!(c.read_byte(base + 7).unwrap(), 0x01);
492 }
493
494 // A doubleword straddling two lines uses the slow path; verify it still works.
495 #[test]
496 fn line_crossing_unaligned_access() {
497 let mut c = make_cache();
498 let addr = 0x8000_003E; // 2 bytes before a 64-byte line boundary
499

Callers

nothing calls this directly

Calls 2

collectMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected