Home /Modules/cpu/SLTimingProfile.sleela

SLTimingProfile.sleela

lib/cpu/SLTimingProfile.sleela · 249 line(s) · sleela

<< lib/cpu/SLTimingProfile.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLTimingProfile — the one object that gathers a whole
     machine's adjustable electrical + timing operating point under a single
     expertise tier. It owns the named voltage rails (Vcore, Vsoc, Vddq, Vio),
     the expert CPU/bus/I/O/RAM timings, and the SLTimingClass tier object that
     governs how aggressively any of it may be dialed. The profile is the thing
     a builder tunes and then SEALS into an SLTimingManifest for a compiled
     .sleela file to carry.
   
   Flow:
     1. configure(tier, brand/medium)         pick the expertise Class Object
     2. the tier stamps its guardband/headroom onto every rail and budget
     3. dialCore/dialBus/dialIO/dialRam(...)   adjust variable speeds (tier-capped)
     4. adjustVcore/... (mV)                   adjust ACTUAL voltages (tier-capped)
     5. honored()                              check every budget + rail together
     6. toManifest()                           flatten to the embeddable record
   
   Family: cpu. Composes SLVoltageRail, SLCpuTiming, SLBusTiming, SLIOTiming,
     SLRamTiming, SLTimingClass; produces SLTimingManifest. >>
#sleela 2.5
material;
class SLTimingProfile {
  < ---- 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 = 11087;
  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-13";
  < 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 governing expertise Class Object >
  SLTimingClass tier;

  < Named, adjustable voltage rails — the ACTUAL voltages, in millivolts. >
  < CPU core >
  SLVoltageRail vcore;
  < SoC / uncore / interconnect >
  SLVoltageRail vsoc;
  < DRAM I/O >
  SLVoltageRail vddq;
  < peripheral I/O ring >
  SLVoltageRail vio;

  < Expert timings, each on its rail. >
  SLCpuTiming cpu;
  < the memory interconnect >
  SLBusTiming memBus;
  < the system/front-side interconnect >
  SLBusTiming sysBus;
  SLIOTiming  ioLink;
  SLRamTiming ram;

  < Configure the whole profile for an expertise tier and a brand/medium, then >
  < populate sensible per-tier defaults for a modern part. The tier's guardband >
  < and headroom are stamped into every budget and rail. >
  void configure(int tierId, String brandOrMedium) {
    tier = new SLTimingClass(); tier.configure(tierId, brandOrMedium);

    < Rails: name / floor / ceiling in mV, with a per-tier nominal lift. A >
    < safer (Novice/Basic) tier runs each rail a little HIGHER than its base >
    < nominal so there is real headroom above the floor to insist on; an Expert >
    < tier runs lean. The floor stays at the physical limit; the lift raises the >
    < settled operating point by exactly the headroom the tier demands. >
    int lift = tier.headroom();
    vcore = new SLVoltageRail(); vcore.configure("Vcore", 1200 + lift, 950, 1450);
    < 0.5 mOhm, 60 A >
    vcore.setLoadLine(500); vcore.setLoad(60000); vcore.lock();
    vsoc  = new SLVoltageRail(); vsoc.configure("Vsoc", 1050 + lift, 900, 1300);
    vsoc.setLoadLine(400); vsoc.setLoad(20000); vsoc.lock();
    vddq  = new SLVoltageRail(); vddq.configure("Vddq", 1100 + lift, 1000, 1300);
    vddq.setLoadLine(300); vddq.setLoad(8000); vddq.lock();
    vio   = new SLVoltageRail(); vio.configure("Vio", 1800 + lift, 1620, 2050);
    vio.setLoadLine(200); vio.setLoad(4000); vio.lock();

    < CPU core timing on Vcore. Ceiling 5 GHz; needs ~0.25 mV/MHz of settled Vcore. >
    cpu = new SLCpuTiming(); cpu.configure("core-pipeline", 800, 5000);
    < 1 mV per MHz of ceiling (modeled) >
    cpu.attachVcore(vcore, 1);
    cpu.setFetch(90, 20, 15); cpu.setDecode(80, 20, 15);
    < ALU carry chain = long pole >
    cpu.setExecute(150, 25, 20);
    cpu.setWriteback(70, 15, 10);
    cpu.setClockJitter(8);

    < Memory interconnect on Vsoc: DDR (2 transfers/clk), 64-bit, 400..2400 MHz. >
    memBus = new SLBusTiming(); memBus.configure("MemBus", 400, 2400, 64, 2);
    memBus.attachRail(vsoc, 1);
    memBus.setAddressPath(140, 30, 20);
    < data-strobe: the careful one >
    memBus.setDataPath(90, 25, 18, 10);
    memBus.setControlPath(120, 25, 20);

    < System interconnect on Vsoc: QDR-ish fabric, 32-bit, 400..4000 MHz. >
    sysBus = new SLBusTiming(); sysBus.configure("SysBus", 400, 4000, 32, 2);
    sysBus.attachRail(vsoc, 1);
    sysBus.setAddressPath(110, 25, 18);
    sysBus.setDataPath(70, 20, 15, 8);
    sysBus.setControlPath(100, 22, 18);

    < I/O link on Vio: 50..1000 MHz, 2-stage CDC synchronizer. >
    ioLink = new SLIOTiming(); ioLink.configure("io-link", 50, 1000, 2);
    ioLink.attachVio(vio, 1);
    ioLink.setHandshake(200, 40, 30);
    ioLink.setTurnaround(260, 50, 40);
    ioLink.setRecovery(180, 30, 25);
    ioLink.setJitter(15);

    < RAM channel on Vddq: DDR4-3200 class, dialing 2133..4000 MT/s. >
    ram = new SLRamTiming(); ram.configure("DIMM ch0", 3200, 2133, 4000);
    < 1 mV per 2 MT/s of ceiling (modeled) >
    ram.attachVddq(vddq, 1, 2);
    ram.setCL(16); ram.setTRCD(18); ram.setTRP(18); ram.setTRAS(39); ram.setTRC(57);
    ram.setCommandRate(1);

    stampTierGuardbands();
    dialToTierDefaults();
  }

  < Push the tier's demanded guardband onto every named budget so a passing >
  < check already means "honored for this expertise tier". >
  void stampTierGuardbands() {
    int g = tier.guardband();
    < The tier most directly governs the carefully-named critical paths: the >
    < CPU execute stage and each interconnect's data strobe / handshake. Set >
    < the guardband in place (without disturbing the measured path numbers). >
    cpu.executeBudget().setGuardband(g);
    memBus.dataBudget().setGuardband(g);
    sysBus.dataBudget().setGuardband(g);
    ioLink.handshakeBudget().setGuardband(g);
  }

  < Dial each variable speed to the tier's willing fraction of its honest >
  < ceiling (Novice backs off; Expert pushes to the edge). >
  void dialToTierDefaults() {
    cpu.setClock(tier.dialableMHz(cpu.criticalMaxMHz()));
    memBus.setClock(tier.dialableMHz(memBus.ceilingMHz()));
    sysBus.setClock(tier.dialableMHz(sysBus.ceilingMHz()));
    < 1000 MHz = the io-link ceiling >
    ioLink.setClock(tier.dialableMHz(1000));
    < RAM: dial MT/s to the tier fraction of the datasheet ceiling. >
    ram.setDataRate(tier.dialableMHz(4000));
  }

  < ---- expert dialing surface (tier governs whether each is permitted) ---- >

  int dialCore(int mhz) { if (!tier.allowsKnob() && mhz > cpu.clock()) { return cpu.clock(); } return cpu.setClock(mhz); }
  int dialMemBus(int mhz) { if (!tier.allowsKnob() && mhz > memBus.clock()) { return memBus.clock(); } return memBus.setClock(mhz); }
  int dialSysBus(int mhz) { if (!tier.allowsKnob() && mhz > sysBus.clock()) { return sysBus.clock(); } return sysBus.setClock(mhz); }
  int dialIO(int mhz) { if (!tier.allowsKnob() && mhz > ioLink.clock()) { return ioLink.clock(); } return ioLink.setClock(mhz); }
  int dialRam(int mts) { if (!tier.allowsKnob() && mts > ram.dataRate()) { return ram.dataRate(); } return ram.setDataRate(mts); }

  < Adjust an ACTUAL voltage (mV). Novice/Basic may only lower (undervolt is >
  < always safe); Advanced/Expert may raise within limits. Expert may unlock. >
  int adjustVcore(int deltaMv) { return adjustRail(vcore, deltaMv); }
  int adjustVsoc(int deltaMv) { return adjustRail(vsoc, deltaMv); }
  int adjustVddq(int deltaMv) { return adjustRail(vddq, deltaMv); }
  int adjustVio(int deltaMv) { return adjustRail(vio, deltaMv); }

  int adjustRail(SLVoltageRail rail, int deltaMv) {
    < no raising below Advanced >
    if (deltaMv > 0 && !tier.allowsKnob()) { return rail.effectiveMv(); }
    if (tier.allowsUnlock()) { /* expert may push to window edges */ }
    rail.adjust(deltaMv);
    return rail.effectiveMv();
  }

  < Everything honored together: every expert timing on every rail, and every >
  < rail inside its limits with the tier's insisted headroom. >
  boolean honored() {
    boolean timings = cpu.honored() && memBus.honored() && sysBus.honored()
                   && ioLink.honored() && ram.honored();
    boolean rails = tier.satisfiesHeadroom(vcore.headroomMv())
                 && tier.satisfiesHeadroom(vsoc.headroomMv())
                 && tier.satisfiesHeadroom(vddq.headroomMv())
                 && tier.satisfiesHeadroom(vio.headroomMv());
    return timings && rails;
  }

  < The tightest setup slack across the carefully-named bus/CPU/IO paths — the >
  < single quality number a consumer reads to know how close to the edge this >
  < profile runs. >
  int worstSlackPs() {
    int w = cpu.executeBudget().setupSlackPs();
    int m = memBus.worstSlackPs();
    int s = sysBus.worstSlackPs();
    int io = ioLink.handshakeBudget().setupSlackPs();
    if (m < w) { w = m; }
    if (s < w) { w = s; }
    if (io < w) { w = io; }
    return w;
  }

  < Flatten the whole operating point into the embeddable manifest a compiled >
  < .sleela file carries — stated numbers, not assumed confidences. >
  SLTimingManifest toManifest() {
    SLTimingManifest man = new SLTimingManifest(); man.configure();
    man.setTier(tier.tierId(), tier.tierName(), tier.brandOrMedium());
    man.setClocks(cpu.clock(), memBus.clock(), ioLink.clock(), ram.dataRate());
    man.setVoltages(vcore.effectiveMv(), vsoc.effectiveMv(), vddq.effectiveMv(), vio.effectiveMv());
    man.setRam(ram.casLatency(), ram.rasToCas(), ram.rowPrecharge(), ram.rowActive());
    man.seal(honored(), worstSlackPs());
    return man;
  }

  SLTimingClass expertise() { return tier; }
  SLVoltageRail coreRail() { return vcore; }
  SLVoltageRail memoryRail() { return vddq; }
  SLVoltageRail ioRail() { return vio; }
  SLCpuTiming cpuTiming() { return cpu; }
  SLBusTiming memoryBus() { return memBus; }
  SLBusTiming systemBus() { return sysBus; }
  SLIOTiming ioTiming() { return ioLink; }
  SLRamTiming ramTiming() { return ram; }
}