SLCPUModel.sleela
lib/cpu/SLCPUModel.sleela · 119 line(s) · sleela
<< lib/cpu/SLCPUModel.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLCPUModel — the declarative description of a specific
processor: the inventory of units it is built from (architecture metadata,
clock, register file, pipeline, execution units, caches, memory, I/O bus,
DMA, MMU, interrupts, couplers) and a validate() contract that a concrete
model satisfies. It is the specification half; SLCPURuntime is the runnable
half a per-architecture model extends.
Kept as populatable fields (not bare names) so a Sleela-sourced CPU can be
described, validated, and then handed to SLCPURuntime to execute on top of the
secondary VM.
Family: cpu. Describes what SLCPURuntime runs. >>
#sleela 2.5
material;
class SLCPUModel {
< ---- 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 = 10491;
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; }
String architecture;
int clock;
< register count >
int registers;
< data path width in bits >
int width;
< pipeline stage count (0 = non-pipelined) >
int pipeline;
int executionUnits;
< cache level count >
int caches;
< addressable words >
int memory;
< 1 if an I/O bus is present >
int ioBus;
< 1 if a DMA engine is present >
int dma;
< 1 if an MMU is present >
int mmu;
< interrupt line count >
int interrupts;
int couplers;
void configure(String arch, int clockMHz, int regCount, int bits,
int stages, int units, int addressableWords) {
architecture = arch; clock = clockMHz; registers = regCount; width = bits;
pipeline = stages; executionUnits = units; memory = addressableWords;
caches = 0; ioBus = 0; dma = 0; mmu = 0; interrupts = 0; couplers = 0;
}
void withCaches(int levels) { caches = levels; }
void withIoBus() { ioBus = 1; }
void withDma() { dma = 1; }
void withMmu() { mmu = 1; }
void withInterrupts(int n) { interrupts = n; }
void withCouplers(int n) { couplers = n; }
< A model is valid when it names an architecture, has a positive width and >
< register count, and a non-empty address space. >
boolean validate() {
if (architecture == null || architecture == "") { return false; }
if (width <= 0) { return false; }
if (registers <= 0) { return false; }
if (memory <= 0) { return false; }
return true;
}
String architectureName() { return architecture; }
int clockMHz() { return clock; }
int registerCount(){ return registers; }
int dataWidth() { return width; }
int pipelineDepth(){ return pipeline; }
int units() { return executionUnits; }
int cacheLevels() { return caches; }
int addressableWords() { return memory; }
boolean hasMmu() { return mmu == 1; }
boolean hasDma() { return dma == 1; }
boolean hasIoBus(){ return ioBus == 1; }
int interruptLines() { return interrupts; }
}