diff --git a/src/main.zig b/src/main.zig index d86786c..f67623a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -50,6 +50,7 @@ pub const Buffer = struct { output: *Wire, pub fn process(self: *Buffer) void { + self.output.digital = self.input.digital; self.output.analogSet(self.input.analog); } }; @@ -58,8 +59,26 @@ pub const Not = struct { input: *Wire, output: *Wire, - // TODO check implementation - pub fn process(self: *Buffer) void { - self.output.analogSet(1.0 - self.input.analog); + pub fn process(self: *Not) void { + self.output.digital = !self.input.digital; + 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; } };