Home /Modules/cpu/ddr5-as-ddr2-cadence.sleela

ddr5-as-ddr2-cadence.sleela

lib/cpu/components/examples/ddr5-as-ddr2-cadence.sleela · 117 line(s) · sleela

<< lib/cpu/components/examples/ddr5-as-ddr2-cadence.sleela
   SLeeLa example: run a real DDR5-6400 module as the system's actual RAM, but
   place a Sleela-level memory interface in the OOD slot that imposes a DDR2
   refresh duty cycle — so the DDR5 "refreshes as though it were DDR2" for a
   special-purpose run. The backing store stays DDR5 (full capacity/data rate);
   only the observed availability (refresh duty) changes. The cadence is modeled
   entirely in the Sleela layer, not in the host OS.
   
   Shows the key property: you compose BOTH the real module AND the interface. >>
#sleela 2.5
material;
class Ddr5AsDdr2CadenceExample {
  < ---- 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 = 11101;
  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 = 7;
  < 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; }

  void main() {
    SLComponentCatalog parts = new SLComponentCatalog();

    SLAMDThreadripper9980X cpu = new SLAMDThreadripper9980X();
    cpu.configure();

    < The REAL RAM in the system: DDR5-6400, 4-channel (TRX50 HEDT). >
    < 4 × 32 GiB >
    SLMemoryModule ddr5 = parts.ddr5_6400_quadChannel(32768);

    < The OOD interface layer: wrap that DDR5 so it refreshes like DDR2. >
    SLMemoryInterface ddr2cad = parts.ddr2CadenceInterface(ddr5);

    SLExecutorBuild build = new SLExecutorBuild();
    build.configure("tr-9980x-ddr5-as-ddr2");
    build.installCpu(cpu);
    build.installBoard(parts.trx50());
    < actual module >
    build.installMemory(ddr5);
    < AND the cadence overlay >
    build.installMemoryInterface(ddr2cad);
    build.installBus(parts.pcieGen5x16());
    < mounts the REAL DDR5 backing store >
    build.assemble();

    print("=== DDR5-6400 operated with DDR2 refresh cadence ===");
    print("native module: " + ddr5.name() + " (" + ddr5.technologyName() +
          "), total " + ddr5.totalCapacityMiB() + " MiB");
    print("backing store mounted as: " + ddr2cad.nativeTechName() +
          " (unchanged; capacity " + ddr2cad.capacityMiB() + " MiB)");
    print("refreshes as: " + ddr2cad.refreshesAsName() +
          "  (tREFI=" + ddr2cad.refreshIntervalNs() + " ns, tRFC=" +
          ddr2cad.refreshTimeNs() + " ns)");
    print("native peak BW: " + ddr2cad.nativeBandwidthMBs() + " MB/s");
    print("available duty: " + ddr2cad.availableDutyPct() + " %  (refresh overhead " +
          ddr2cad.refreshOverheadPct() + " %)");
    print("effective BW under DDR2 cadence: " + ddr2cad.effectiveBandwidthMBs() +
          " MB/s  (= native peak x available duty; the duty follows the chosen");
    print("  cadence's tREFI/tRFC, so the figure reflects DDR2's refresh timing honestly)");
    print("build sees memory BW: " + build.memoryBandwidthMBs() +
          " MB/s, interface active=" + build.hasMemoryInterface());

    < Disengage the overlay to pass the real DDR5 through untouched (A/B check). >
    ddr2cad.disengage();
    print("overlay off -> effective BW back to native: " +
          ddr2cad.effectiveBandwidthMBs() + " MB/s, duty " + ddr2cad.availableDutyPct() + " %");

    < Explicit Dynamite Connector flow: build a cadence connector, drive its >
    < lifecycle, and plug it into the interface's slot via connect() — instead >
    < of relying on setters. Re-cadence the SAME interface to DDR4. >
    < initialized + resolved >
    SLCadenceConnector ddr4 = parts.ddr4Cadence();
    print("connector '" + ddr4.referenceId() + "' state after resolve: " + ddr4.state());
    ddr2cad.engage();
    < load()s then binds timings >
    boolean connected = ddr2cad.connect(ddr4);
    print("connected DDR4 cadence: " + connected + ", slot state=" +
          ddr2cad.cadenceSlot().state() + ", refreshes as " + ddr2cad.refreshesAsName());
    print("effective BW under DDR4 cadence: " + ddr2cad.effectiveBandwidthMBs() +
          " MB/s, duty " + ddr2cad.availableDutyPct() + " %");
  }
}