Skip to main content

Crate ternaria_mem

Crate ternaria_mem 

Source
Expand description

Guest memory for the Ternaria emulator (D-14).

§Shape

  • The addressable unit is the 9-trit Tryte (D-02).
  • Addresses are signed, covering +/-3.81*10^12 with zero at the centre.
  • Little-endian: the least significant tryte is at the lowest address. This matches ternaria-arith, which orders trits least-significant-first.
  • Everything aligns to the word (3 trytes), including double words. See Memory::read_double.
  • Sparse. The full address space is about 8.6 TB at BCT density, so pages are allocated on first write and never materialised for reads.
  • Memory that has never been written reads as an error rather than zero.

§Storage format

Trytes are stored as BCT rather than as numeric values. Every i32 is a valid tryte value, so a value representation would leave nowhere to record that a location has never been written. BCT has a spare codepoint for it (D-03).

Modules§

bytes
The bit/trit boundary (D-04).
irq
Interrupt request lines: which trit of the interrupt masks each device owns.

Structs§

Memory
Sparse, BCT-backed guest memory.

Enums§

MemoryError
Something went wrong with a memory access.

Constants§

DOUBLE_TRYTES
Trytes per double word - 54 trits / 9.
PAGE_TRYTES
Trytes per page: 3^6 = 729 (D-14). The smaller of the two candidates considered; smaller pages waste less on a sparse address space at the cost of more host allocations.
WORD_TRYTES
Trytes per word - 27 trits / 9.

Traits§

Addressable
Anything a program can load from and store to.