make sim global; make nonessential queues optional
This commit is contained in:
20
sim/gate.lua
20
sim/gate.lua
@@ -5,16 +5,18 @@ FFI.cdef[[
|
||||
struct Gate {
|
||||
int objref;
|
||||
int definition_objref;
|
||||
bool in_queue;
|
||||
struct Port ports[1];
|
||||
};
|
||||
]]
|
||||
|
||||
function Gate.new(self, objref, definition, sim)
|
||||
function Gate.new(self, objref, definition)
|
||||
local o = {
|
||||
objref = objref,
|
||||
definition = definition,
|
||||
ports = {},
|
||||
sim = sim,
|
||||
in_queue = false,
|
||||
logic = definition.logic,
|
||||
}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
@@ -27,7 +29,7 @@ function Gate.addport(self, port)
|
||||
end
|
||||
|
||||
function Gate.getportstate(self, index)
|
||||
return Port.getinputstate(self.ports[index])
|
||||
return self.ports[index].group.state
|
||||
end
|
||||
|
||||
function Gate.setportstate(self, index, state)
|
||||
@@ -51,19 +53,15 @@ function Gate.getportisfalling(self, index)
|
||||
end
|
||||
|
||||
function Gate.cb(gate, ...)
|
||||
Simulation.queuecallback(Gate.getsim(gate), gate, ...)
|
||||
Simulation.queuecallback(GSim, gate, ...)
|
||||
end
|
||||
|
||||
function Gate.queue(gate, delay)
|
||||
Simulation.queuegatelater(Gate.getsim(gate), gate, delay)
|
||||
Simulation.queuegatelater(GSim, gate, delay)
|
||||
end
|
||||
|
||||
function Gate.gettick(gate)
|
||||
return Gate.getsim(gate).currenttick
|
||||
end
|
||||
|
||||
function Gate.getsim(gate)
|
||||
return gate.sim
|
||||
return GSim.currenttick
|
||||
end
|
||||
|
||||
function Gate.getdefinition(gate)
|
||||
@@ -77,7 +75,7 @@ function Gate.init(gate)
|
||||
end
|
||||
|
||||
function Gate.logic(gate)
|
||||
Gate.getdefinition(gate).logic(gate)
|
||||
gate.logic(gate)
|
||||
end
|
||||
|
||||
function Gate.input(gate, argv)
|
||||
|
||||
Reference in New Issue
Block a user