Fix the NOT gate
This commit is contained in:
parent
f98142f387
commit
5b697571f9
@ -1,13 +1,6 @@
|
|||||||
# Represents a NOT gate
|
# Represents a NOT gate
|
||||||
class NotGate < 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.
|
# Add a port to the gate. As this is a NOT gate, there may only be one port.
|
||||||
# @param (see Gate#add_input)
|
# @param (see Gate#add_input)
|
||||||
# @return [void]
|
# @return [void]
|
||||||
@ -22,6 +15,6 @@ class NotGate < Gate
|
|||||||
# Calculates NOT of input and sets output port to that value.
|
# Calculates NOT of input and sets output port to that value.
|
||||||
# @param vals [Array<Integer>] List of values for connected ports.
|
# @param vals [Array<Integer>] List of values for connected ports.
|
||||||
def inputs_changed(vals)
|
def inputs_changed(vals)
|
||||||
out.setval((~vals[0]) & @outmask)
|
out.setval((~vals[0]) & ((2**@width)-1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user