Home /Modules/xlt/SLXltSource.sleela

SLXltSource.sleela

lib/xlt/SLXltSource.sleela · 226 line(s) · sleela

<< lib/xlt/SLXltSource.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLXltSource — the canonical source-time representation of
     an XLT (.xlt) CPU-model sheet, the exact counterpart of SSTSource for the
     SST (.sst) layer. Where SST declaratively authors a SYSTEM of library
     symbols, XLT declaratively authors a CPU MODEL: a chosen CPU SKU plus the
     board, memory, cadence, storage, and bus parts that assemble it. The format
     needs no new keyword and no setters — the document's ORTHOGONALITY (each
     part declared once, in order, non-overlapping) is itself what guarantees
     the model's integrity and a clear compilation.
   
     An .xlt sheet reads:
         #xlt 1.0
         model Name {
           < a real CPU SKU class >
           cpu      "SLAMDEPYC9575F";
           < a real SLMotherboard preset (optional) >
           board    "wrx90";
           < a real SLMemoryModule preset + capacity >
           memory   "ddr2_800" 4096;
           < SLCadenceConnector cadence to present >
           cadence  "DDR2";
           < optional >
           storage  "nvmeGen4";
           < optional >
           bus      "pcieGen5x16";
           < optional capability: native GPU >
           gpu;
           < optional capability: DMA engine >
           dma;
           < optional capability: NATIVE_RAM bit >
           nativeram;
           < optional: run this program on the build >
           program  "app.sleela" sleela;
           < optional: memory words + cycle budget >
           grant    65536 1000000;
           target   sleela;
         }
   
     When a `program` is declared, a congruent build is politely RUN: the
     compiler admits an SLWorkload (source + language) under an SLCPUResource
     grant and executes it on build.processor() via SleelaVMCreator — the
     sanctioned path (admission-checked, through the model's fetch-decode-execute
     loop), never reaching around the CPU model.
   
     The compile path parallels SST's:
         .xlt -> SLXltCompiler -> SLExecutorBuild (real parts) -> SLProgram/VM
   
   Family: xlt. Source-time contract; resolved by SLXltCompiler into a real
     SLExecutorBuild. Mirrors lib/sst/SSTSource. >>
#sleela 2.5
material;
class SLXltSource {
  < ---- 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 = 11280;
  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; }
  < the .xlt file path >
  String path;
  < the `model Name { ... }` identifier >
  String modelName;
  < `target sleela;` >
  String target;
  < the /lib root parts resolve against >
  String libraryRoot;

  < The declared parts, one per orthogonal slot (each may be set at most once). >
  < CPU SKU class name, e.g. "SLAMDEPYC9575F" >
  String cpuRef;
  < SLMotherboard preset, e.g. "wrx90" (empty = none) >
  String boardRef;
  < SLMemoryModule preset, e.g. "ddr2_800" >
  String memoryRef;
  < capacity argument for the memory preset >
  int    memoryCapMiB;
  < cadence to present, e.g. "DDR2" (empty = native) >
  String cadenceRef;
  < SLStorageDevice preset (empty = none) >
  String storageRef;
  < SLSystemBus preset (empty = none) >
  String busRef;

  < Capability directives: bare orthogonal flags (declared at most once each). >
  < `gpu;`       -> build.enableGPU() >
  int gpuFlag;
  < `dma;`       -> build.enableDMA() >
  int dmaFlag;
  < `nativeram;` -> declare the NATIVE_RAM feature bit >
  int nativeRamFlag;

  < Memory-tier designation: the model may split memory into a "usual" tier >
  < (for usual activities) and an "accurate" tier (for competency/accuracy), >
  < and name which is the default (main) tier. Each memory preset slot below. >
  < memory preset for the usual tier, e.g. "ddr2_800" >
  String usualTierRef;
  < memory preset for the accurate tier, e.g. "ddr5_6400" >
  String accurateTierRef;
  < "usual" or "accurate" — which the main program uses >
  String mainTier;

  < Optional workload: the program this model should politely run on the built >
  < CPU (source path + language), and the resource grant it is admitted under. >
  < e.g. "app.sleela" (empty = build hardware only) >
  String programPath;
  < "sleela" | "c" | "cpp" | "java" >
  String programLang;
  < memory words requested (0 = compiler default) >
  int    grantWords;
  < cycle budget requested (0 = compiler default) >
  int    grantBudget;

  int validated;

  void configure(String sourcePath, String root) {
    path = sourcePath; libraryRoot = root;
    modelName = ""; target = "sleela";
    cpuRef = ""; boardRef = ""; memoryRef = ""; memoryCapMiB = 0;
    cadenceRef = ""; storageRef = ""; busRef = "";
    gpuFlag = 0; dmaFlag = 0; nativeRamFlag = 0;
    usualTierRef = ""; accurateTierRef = ""; mainTier = "";
    programPath = ""; programLang = ""; grantWords = 0; grantBudget = 0;
    validated = 0;
  }

  void setModelName(String name) { modelName = name; }
  void setTarget(String t)       { target = t; }

  < Orthogonal part declarations: each returns false if the slot was already >
  < filled (a duplicate breaks document orthogonality and must be reported). >
  boolean declareCpu(String ref)     { if (cpuRef != "") { return false; } cpuRef = ref; return true; }
  boolean declareBoard(String ref)   { if (boardRef != "") { return false; } boardRef = ref; return true; }
  boolean declareMemory(String ref, int capMiB) {
    if (memoryRef != "") { return false; }
    memoryRef = ref; memoryCapMiB = capMiB; return true;
  }
  boolean declareCadence(String ref) { if (cadenceRef != "") { return false; } cadenceRef = ref; return true; }
  boolean declareStorage(String ref) { if (storageRef != "") { return false; } storageRef = ref; return true; }
  boolean declareBus(String ref)     { if (busRef != "") { return false; } busRef = ref; return true; }

  < Capability directives: each may be declared at most once (orthogonal). >
  boolean declareGpu()       { if (gpuFlag == 1) { return false; } gpuFlag = 1; return true; }
  boolean declareDma()       { if (dmaFlag == 1) { return false; } dmaFlag = 1; return true; }
  boolean declareNativeRam() { if (nativeRamFlag == 1) { return false; } nativeRamFlag = 1; return true; }

  < Memory-tier designation (orthogonal: each tier declared at most once). >
  boolean declareUsualTier(String ref)    { if (usualTierRef != "") { return false; } usualTierRef = ref; return true; }
  boolean declareAccurateTier(String ref) { if (accurateTierRef != "") { return false; } accurateTierRef = ref; return true; }
  boolean declareMainTier(String which)   { if (mainTier != "") { return false; } mainTier = which; return true; }

  < Workload + grant (each declared at most once; orthogonal). >
  boolean declareProgram(String path, String lang) {
    if (programPath != "") { return false; }
    programPath = path; programLang = lang; return true;
  }
  boolean declareGrant(int words, int budget) {
    if (grantWords != 0 || grantBudget != 0) { return false; }
    grantWords = words; grantBudget = budget; return true;
  }

  boolean validate() { validated = 1; return 1 == 1; }

  String sourcePath()  { return path; }
  String name()        { return modelName; }
  String targetName()  { return target; }
  String cpu()         { return cpuRef; }
  String board()       { return boardRef; }
  String memory()      { return memoryRef; }
  int    memoryCapacity() { return memoryCapMiB; }
  String cadence()     { return cadenceRef; }
  String storage()     { return storageRef; }
  String bus()         { return busRef; }
  boolean hasBoard()   { return boardRef != ""; }
  boolean hasCadence() { return cadenceRef != ""; }
  boolean hasStorage() { return storageRef != ""; }
  boolean hasBus()     { return busRef != ""; }
  boolean wantsGpu()       { return gpuFlag == 1; }
  boolean wantsDma()       { return dmaFlag == 1; }
  boolean wantsNativeRam() { return nativeRamFlag == 1; }
  String usualTier()       { return usualTierRef; }
  String accurateTier()    { return accurateTierRef; }
  String main()            { return mainTier; }
  boolean hasTiers()       { return usualTierRef != "" || accurateTierRef != ""; }
  String program()         { return programPath; }
  String programLanguage() { return programLang; }
  boolean hasProgram()     { return programPath != ""; }
  int grantWordsRequested(){ return grantWords; }
  int grantBudgetRequested(){ return grantBudget; }
}