This commit is contained in:
Jeeves 2025-02-11 08:14:55 -07:00
parent c8e09d1171
commit 911fa64ee7

View file

@ -50,6 +50,7 @@ pub const Buffer = struct {
output: *Wire, output: *Wire,
pub fn process(self: *Buffer) void { pub fn process(self: *Buffer) void {
self.output.digital = self.input.digital;
self.output.analogSet(self.input.analog); self.output.analogSet(self.input.analog);
} }
}; };
@ -58,8 +59,26 @@ pub const Not = struct {
input: *Wire, input: *Wire,
output: *Wire, output: *Wire,
// TODO check implementation pub fn process(self: *Not) void {
pub fn process(self: *Buffer) void { self.output.digital = !self.input.digital;
self.output.analogSet(1.0 - self.input.analog); self.output.analogSet(1.0 - self.input.analog); // TODO check implementation
}
};
pub const And = struct {
inputs: []Wire,
output: *Wire,
// TODO check implementation
pub fn process(self: *And) void {
var digital = self.inputs[0].digital;
if (digital) for (1..self.inputs.len - 1) |i| if (!self.inputs[i].digital) {
digital = false;
break;
};
// TODO analog
self.output.digital = digital;
} }
}; };