SLMemoryTierRouter.sleela
lib/cpu/components/SLMemoryTierRouter.sleela · 118 line(s) · sleela
<< lib/cpu/components/SLMemoryTierRouter.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLMemoryTierRouter โ the piece that makes memory tiers
PHYSICAL. A build can carry two real memory modules: a "usual" tier (for
usual activities, e.g. DDR2) and an "accurate" tier (for competency/
accuracy-critical work, e.g. DDR5). This router holds both, knows the
program's default (main) tier, and โ given a function's declared tier โ
returns the actual SLMemoryModule that function should bind its memory
accesses to. The VM/dispatcher consults it per function so a program marked
`usualmem`/`accuratemem` (or defaulted at the document level) runs against
the matching module, not a single shared store.
Tier ids mirror the Sleela memory-tier modifiers and SLAccessSemantics
shape: 0 = inherit (use the main tier), 1 = usual (DDR2), 2 = accurate
(DDR5). A function that declares neither inherits the main tier.
Family: cpu.components. Composes SLMemoryModule; held by SLExecutorBuild;
consulted by the VM dispatch path. >>
#sleela 2.5
material;
class SLMemoryTierRouter {
< ---- 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 = 11269;
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-16";
< 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; }
< no per-function tier -> use main >
static final int TIER_INHERIT = 0;
< usualmem (DDR2) >
static final int TIER_USUAL = 1;
< accuratemem (DDR5) >
static final int TIER_ACCURATE = 2;
< the usual-activities tier module (may be null) >
SLMemoryModule usual;
< the accuracy/competency tier module (may be null) >
SLMemoryModule accurate;
< TIER_USUAL or TIER_ACCURATE (default accurate) >
int mainTier;
void configure() { usual = null; accurate = null; mainTier = TIER_ACCURATE; }
void installUsual(SLMemoryModule m) { usual = m; }
void installAccurate(SLMemoryModule m) { accurate = m; }
void setMainTier(int tier) {
if (tier == TIER_USUAL || tier == TIER_ACCURATE) { mainTier = tier; }
}
< Resolve a function's declared tier to the concrete tier it runs on: >
< TIER_INHERIT folds to the main tier; otherwise the declared tier stands. >
int resolveTier(int declaredTier) {
if (declaredTier == TIER_USUAL || declaredTier == TIER_ACCURATE) { return declaredTier; }
return mainTier;
}
< The actual memory module a function with `declaredTier` binds to. Falls >
< back to whichever tier IS installed if the resolved one is absent, so a >
< model that declared only one tier still runs (the router never returns >
< null when at least one tier is present). >
SLMemoryModule moduleFor(int declaredTier) {
int t = resolveTier(declaredTier);
if (t == TIER_USUAL) {
if (usual != null) { return usual; }
return accurate;
}
if (accurate != null) { return accurate; }
return usual;
}
< Human-readable tier a function resolves to (for reports/diagnostics). >
String tierName(int declaredTier) {
int t = resolveTier(declaredTier);
if (t == TIER_USUAL) { return "usual"; }
return "accurate";
}
boolean hasUsual() { return usual != null; }
boolean hasAccurate() { return accurate != null; }
int main() { return mainTier; }
boolean twoTier() { return usual != null && accurate != null; }
}