SLMemoryModule.sleela
lib/cpu/components/SLMemoryModule.sleela · 154 line(s) · sleela
<< lib/cpu/components/SLMemoryModule.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLMemoryModule — a selectable main-memory part a user
plugs into a Sleela executor build. It carries the real-world specification
of a RAM module: technology (DRAM/SDRAM/DDRn/SRAM), capacity, data-bus
width, clock, CAS latency, and the resulting first-word latency and peak
transfer bandwidth. The timings are what make one RAM choice faster than
another; SLComponentCatalog offers presets (DDR3-1600, DDR5-6000, ...).
The module backs an SLRAM at the chosen capacity; the spec fields drive the
performance model (effective bandwidth, access latency) so overclocked CPUs
and faster RAM visibly change an executor's characterization.
Family: cpu.components. Composes SLRAM; selected via SLComponentCatalog. >>
#sleela 2.5
material;
class SLMemoryModule {
< ---- 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 = 10511;
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; }
< Memory technology ids. >
static final int TECH_SRAM = 0;
static final int TECH_DRAM = 1;
static final int TECH_SDRAM = 2;
static final int TECH_DDR = 3;
static final int TECH_DDR2 = 4;
static final int TECH_DDR3 = 5;
static final int TECH_DDR4 = 6;
static final int TECH_DDR5 = 7;
< e.g. "DDR4-3200 16GB" >
String partName;
int technology;
< module capacity in MiB >
int capacityMiB;
< data bus width per channel (e.g. 64 for a DIMM) >
int busWidthBits;
< I/O bus clock (MT/s = clockMHz × ddrFactor) >
int clockMHz;
< CL in clock cycles >
int casLatency;
< 1 for SDR/SRAM, 2 for DDR double-pumping >
int ddrFactor;
< populated memory channels (1 single, 4 HEDT, 8 PRO) >
int channels;
< the actual word store the executor addresses >
SLRAM backing;
void configure(String name, int tech, int capMiB, int busBits,
int ioClockMHz, int cl, int ddr) {
configureChannels(name, tech, capMiB, busBits, ioClockMHz, cl, ddr, 1);
}
< Full form: also state how many memory channels are populated. A platform >
< with N channels multiplies both the addressable capacity (N modules) and >
< the aggregate peak bandwidth by N — this is what distinguishes a 4-channel >
< HEDT board from an 8-channel workstation board running the same DIMMs. >
void configureChannels(String name, int tech, int capMiB, int busBits,
int ioClockMHz, int cl, int ddr, int channelCount) {
partName = name; technology = tech; capacityMiB = capMiB;
busWidthBits = busBits; clockMHz = ioClockMHz; casLatency = cl;
ddrFactor = (ddr < 1) ? 1 : ddr;
channels = (channelCount < 1) ? 1 : channelCount;
}
< Set the populated channel count after configuration (e.g. to retarget the >
< same DIMM spec from a 4-channel to an 8-channel platform). >
void setChannels(int channelCount) { channels = (channelCount < 1) ? 1 : channelCount; }
< Allocate the backing store for this module as `width`-bit words. The arena >
< spans the full populated capacity across every channel. >
SLRAM mount(int wordWidth) {
int words = (totalCapacityMiB() * 1048576 * 8) / wordWidth;
backing = new SLRAM(); backing.configure(words, wordWidth); backing.allocate();
return backing;
}
< Effective data rate in mega-transfers/second per channel (DDR double-pumps). >
int transfersPerSecMT() { return clockMHz * ddrFactor; }
< Per-channel peak bandwidth in MB/s: MT/s × bus bytes. >
int channelBandwidthMBs() { return transfersPerSecMT() * (busWidthBits / 8); }
< Aggregate peak bandwidth in MB/s across every populated channel. For a >
< single-channel module this equals the per-channel figure. >
int peakBandwidthMBs() { return channelBandwidthMBs() * channels; }
< Total installed capacity across all channels (one module per channel). >
int totalCapacityMiB() { return capacityMiB * channels; }
< First-word access latency in nanoseconds: CL / clock. (×1000 for ns.) >
int firstWordLatencyNs() { if (clockMHz <= 0) { return 0; } return (casLatency * 1000) / clockMHz; }
String name() { return partName; }
int tech() { return technology; }
int capacity() { return capacityMiB; }
int channelCount() { return channels; }
int busWidth() { return busWidthBits; }
int clock() { return clockMHz; }
int cl() { return casLatency; }
SLRAM memory() { return backing; }
String technologyName() {
if (technology == TECH_SRAM) { return "SRAM"; }
if (technology == TECH_DRAM) { return "DRAM"; }
if (technology == TECH_SDRAM) { return "SDRAM"; }
if (technology == TECH_DDR) { return "DDR"; }
if (technology == TECH_DDR2) { return "DDR2"; }
if (technology == TECH_DDR3) { return "DDR3"; }
if (technology == TECH_DDR4) { return "DDR4"; }
if (technology == TECH_DDR5) { return "DDR5"; }
return "RAM";
}
}