make simulation non-global
This commit is contained in:
35
sim/gate.lua
35
sim/gate.lua
@@ -1,11 +1,12 @@
|
||||
|
||||
Gate = {}
|
||||
|
||||
function Gate.new(self, objref, definition)
|
||||
function Gate.new(self, objref, definition, sim)
|
||||
local o = {
|
||||
objref = objref,
|
||||
definition = definition,
|
||||
ports = {}
|
||||
ports = {},
|
||||
sim = sim,
|
||||
}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
@@ -41,34 +42,14 @@ function Gate:getportisfalling(index)
|
||||
return Port.isfalling(self.ports[index])
|
||||
end
|
||||
|
||||
-- function Gate:cb(...)
|
||||
-- local args = {...}
|
||||
-- local str = tostring(#args)
|
||||
|
||||
-- for i, v in ipairs(args) do
|
||||
-- v = bool_to_int[v] or tostring(v)
|
||||
-- str = str .. "\t" .. tostring(v)
|
||||
-- end
|
||||
|
||||
-- sim:queuecallback(self, str)
|
||||
-- end
|
||||
|
||||
function Gate.cb(self, ...)
|
||||
Simulation.queuecallback(sim, self, ...)
|
||||
function Gate.cb(gate, ...)
|
||||
Simulation.queuecallback(gate.sim, gate, ...)
|
||||
end
|
||||
|
||||
function Gate.queue(self, delay)
|
||||
Simulation.queuegatelater(sim, self, delay)
|
||||
Simulation.queuegatelater(self.sim, self, delay)
|
||||
end
|
||||
|
||||
function Gate.testlogic(self, n)
|
||||
--local time = os.clock()
|
||||
--for i = 1, n do
|
||||
-- self.definition.logic(self)
|
||||
--end
|
||||
--client:send("TEST\t" .. (os.clock()-time) .. "\n")
|
||||
end
|
||||
|
||||
function Gate.gettick(self)
|
||||
return sim.currenttick
|
||||
function Gate.gettick(gate)
|
||||
return gate.sim.currenttick
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user