SLNativeMemory.sleela
lib/vm/SLNativeMemory.sleela · 105 line(s) · sleela
<< lib/vm/SLNativeMemory.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLNativeMemory โ a flat block of REAL host RAM for the
Secondary Sleela VM to run on when the native-RAM option is chosen. Unlike
SLRAM (which routes every cell through the simulation/VM bridge and keeps
access accounting), SLNativeMemory is a single contiguous host allocation
accessed directly: it crosses the native bridge once at allocate() to obtain
a real pointer-backed region, then reads/writes land straight in host memory
with no per-access simulation layer.
Purpose: "procedural layment outside of simulation" โ when a build prefers to
lay out procedures and data in actual RAM for maximum throughput and native
residency rather than inside the simulated store. Same word interface as
SLRAM so SLVMMemory can use either backing transparently.
Family: vm. Native host allocation via bridge; alternative backing to SLRAM. >>
#sleela 2.5
material;
class SLNativeMemory {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 10513;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-10-09";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 9;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
int wordCount;
< bits per word >
int width;
< native host-allocation handle (0 until allocated) >
int handle;
< 1 once backed by real host RAM >
int resident;
void configure(int words, int bits) {
wordCount = words; width = bits; handle = 0; resident = 0;
}
< Allocate a contiguous block of REAL host RAM (not the simulated store). >
< Crosses the bridge once; thereafter accesses are direct. >
int allocate() {
handle = native sleela_native_ram_alloc(wordCount, width);
resident = (handle != 0) ? 1 : 0;
return handle;
}
boolean inRange(int addr) { return addr >= 0 && addr < wordCount; }
boolean isResident() { return resident == 1; }
< Direct host-memory access โ no per-access accounting or simulation step. >
int readWord(int addr) {
if (!inRange(addr)) { return -1; }
return native sleela_native_ram_read(handle, addr);
}
int writeWord(int addr, int value) {
if (!inRange(addr)) { return -1; }
return native sleela_native_ram_write(handle, addr, value);
}
< Direct block move within host RAM (used for procedural layout / DMA-style >
< bulk placement without the simulated copy loop). >
void blockMove(int dst, int src, int words) {
native sleela_native_ram_move(handle, dst, src, words);
}
void free() { if (handle != 0) { native sleela_native_ram_free(handle); handle = 0; resident = 0; } }
int capacityWords() { return wordCount; }
int capacityBytes() { return wordCount * (width / 8); }
}