misc
This commit is contained in:
parent
c8e09d1171
commit
911fa64ee7
1 changed files with 22 additions and 3 deletions
25
src/main.zig
25
src/main.zig
|
@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue