SLStorageDevice.sleela
lib/cpu/components/SLStorageDevice.sleela · 128 line(s) · sleela
<< lib/cpu/components/SLStorageDevice.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLStorageDevice โ a selectable mass-storage part for a
Sleela executor build: hard disk, solid-state disk, NVMe, floppy, or tape.
It carries the real spec that distinguishes them โ capacity, interface
(ST-506/IDE/SATA/SAS/NVMe), rotational speed (RPM, 0 for solid state),
average seek time, and sequential transfer rate โ plus a simple access-time
model (seek + rotational latency + transfer) so a build with a fast NVMe
behaves differently from one with a 3600-RPM MFM drive.
Family: cpu.components. Selected via SLComponentCatalog. >>
#sleela 2.5
material;
class SLStorageDevice {
< ---- 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 = 10533;
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; }
< Device classes. >
static final int CLASS_FLOPPY = 0;
static final int CLASS_HDD = 1;
static final int CLASS_SSD = 2;
static final int CLASS_NVME = 3;
static final int CLASS_TAPE = 4;
< Interfaces. >
static final int IF_ST506 = 0;
static final int IF_IDE = 1;
static final int IF_SCSI = 2;
static final int IF_SATA = 3;
static final int IF_SAS = 4;
static final int IF_NVME = 5;
String partName;
int deviceClass;
int iface;
< capacity in MiB >
int capacityMiB;
< rotational speed (0 for SSD/NVMe/flash) >
int rpm;
< average seek time, microseconds (0 for solid state) >
int avgSeekUs;
< sustained sequential transfer, MB/s >
int transferMBs;
void configure(String name, int devClass, int interfaceId, int capMiB,
int rotationRpm, int seekMicros, int seqMBs) {
partName = name; deviceClass = devClass; iface = interfaceId;
capacityMiB = capMiB; rpm = rotationRpm; avgSeekUs = seekMicros; transferMBs = seqMBs;
}
< Average rotational latency in microseconds (half a revolution). 0 for >
< non-rotational media. >
int rotationalLatencyUs() { if (rpm <= 0) { return 0; } return 30000000 / rpm; }
< Modelled random-access time for a `bytes`-sized read: seek + rotational >
< latency + transfer time, in microseconds. >
int accessTimeUs(int bytes) {
< ~us at MB/s >
int xfer = (transferMBs <= 0) ? 0 : bytes / transferMBs;
return avgSeekUs + rotationalLatencyUs() + xfer;
}
String name() { return partName; }
int classId() { return deviceClass; }
int capacity() { return capacityMiB; }
int rotationRpm() { return rpm; }
int seekTimeUs() { return avgSeekUs; }
int transferRate() { return transferMBs; }
boolean solidState(){ return deviceClass == CLASS_SSD || deviceClass == CLASS_NVME; }
String className() {
if (deviceClass == CLASS_FLOPPY) { return "Floppy"; }
if (deviceClass == CLASS_HDD) { return "HDD"; }
if (deviceClass == CLASS_SSD) { return "SSD"; }
if (deviceClass == CLASS_NVME) { return "NVMe"; }
if (deviceClass == CLASS_TAPE) { return "Tape"; }
return "Storage";
}
String interfaceName() {
if (iface == IF_ST506) { return "ST-506"; }
if (iface == IF_IDE) { return "IDE/PATA"; }
if (iface == IF_SCSI) { return "SCSI"; }
if (iface == IF_SATA) { return "SATA"; }
if (iface == IF_SAS) { return "SAS"; }
if (iface == IF_NVME) { return "NVMe/PCIe"; }
return "unknown";
}
}