SLRAM.sleela
lib/cpu/SLRAM.sleela · 94 line(s) · sleela
<< lib/cpu/SLRAM.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLRAM — random-access main memory: a word-addressable
store the CPU reads instructions and data from. It models capacity, word
width, and access counting, and crosses the explicit VM/OS bridge to the
native memory subsystem for the actual backing cells (SLeeLa's surface has
no large array storage, so bulk cells live below the bridge).
Addressing is by word index; out-of-range access is rejected.
Family: cpu. Native backing store via bridge. >>
#sleela 2.5
material;
class SLRAM {
< ---- 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 = 10275;
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-06";
< 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; }
< number of addressable words >
int wordCount;
< bits per word >
int width;
< native backing-store handle (0 until allocated) >
int handle;
int reads;
int writes;
void configure(int words, int bits) {
wordCount = words; width = bits; handle = 0; reads = 0; writes = 0;
}
< Allocate the native backing store (zero-initialized). >
int allocate() {
handle = native sleela_mem_alloc_words(wordCount, width);
return handle;
}
boolean inRange(int addr) { return addr >= 0 && addr < wordCount; }
int readWord(int addr) {
if (!inRange(addr)) { return -1; }
reads = reads + 1;
return native sleela_mem_read_word(handle, addr);
}
int writeWord(int addr, int value) {
if (!inRange(addr)) { return -1; }
writes = writes + 1;
return native sleela_mem_write_word(handle, addr, value);
}
void free() { if (handle != 0) { native sleela_mem_free(handle); handle = 0; } }
int capacityWords() { return wordCount; }
int capacityBytes() { return wordCount * (width / 8); }
}