From 911fa64ee7ad3eb4f310701c08b109ba0df63905 Mon Sep 17 00:00:00 2001 From: Jeeves Date: Tue, 11 Feb 2025 08:14:55 -0700 Subject: [PATCH] misc --- src/main.zig | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) 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; } };