56 lines
982 B
Lua
56 lines
982 B
Lua
|
|
Gate = {}
|
|
|
|
function Gate.new(self, objref, definition, sim)
|
|
local o = {
|
|
objref = objref,
|
|
definition = definition,
|
|
ports = {},
|
|
sim = sim,
|
|
}
|
|
setmetatable(o, self)
|
|
self.__index = self
|
|
return o
|
|
end
|
|
|
|
function Gate.addport(self, port)
|
|
self.ports[#self.ports+1] = port
|
|
Port.setgate(port, self)
|
|
end
|
|
|
|
function Gate.getportstate(self, index)
|
|
return self.ports[index].state
|
|
end
|
|
|
|
function Gate.setportstate(self, index, state)
|
|
Port.setstate(self.ports[index], state)
|
|
end
|
|
|
|
function Gate.initdata(self)
|
|
self.data = {}
|
|
end
|
|
|
|
function Gate.getdata(self)
|
|
return self.data
|
|
end
|
|
|
|
function Gate.getportisrising(self, index)
|
|
return Port.isrising(self.ports[index])
|
|
end
|
|
|
|
function Gate:getportisfalling(index)
|
|
return Port.isfalling(self.ports[index])
|
|
end
|
|
|
|
function Gate.cb(gate, ...)
|
|
Simulation.queuecallback(gate.sim, gate, ...)
|
|
end
|
|
|
|
function Gate.queue(self, delay)
|
|
Simulation.queuegatelater(self.sim, self, delay)
|
|
end
|
|
|
|
function Gate.gettick(gate)
|
|
return gate.sim.currenttick
|
|
end
|