From 5b697571f9142689648271bb98731ab0e829c046 Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 8 May 2020 07:17:08 -0500 Subject: [PATCH] Fix the NOT gate --- lib/rcircuit/not.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/rcircuit/not.rb b/lib/rcircuit/not.rb index 3eb23c8..c828f49 100644 --- a/lib/rcircuit/not.rb +++ b/lib/rcircuit/not.rb @@ -1,13 +1,6 @@ # Represents a NOT gate class NotGate < Gate - # (see Gate#initialize) - def initialize(*args) - @outmask=0 - super - @outmask=(2**@width)-1 - end - # Add a port to the gate. As this is a NOT gate, there may only be one port. # @param (see Gate#add_input) # @return [void] @@ -22,6 +15,6 @@ class NotGate < Gate # Calculates NOT of input and sets output port to that value. # @param vals [Array] List of values for connected ports. def inputs_changed(vals) - out.setval((~vals[0]) & @outmask) + out.setval((~vals[0]) & ((2**@width)-1)) end end