stop clearing queue arrays

This commit is contained in:
Redo0 2021-06-05 19:02:28 -05:00
parent 19d2e36fd6
commit d3d03ce9a7
2 changed files with 11 additions and 15 deletions

View File

@ -267,16 +267,14 @@ end
-- Logic Critical -- Logic Critical
function Simulation.queuegroup(sim, group) function Simulation.queuegroup(sim, group)
--if group.in_queue==0 then sim.groupqueue[sim.num_groupqueue+1] = group
sim.groupqueue[sim.num_groupqueue+1] = group sim.num_groupqueue = sim.num_groupqueue + 1
sim.num_groupqueue = sim.num_groupqueue + 1 group.in_queue = 1
group.in_queue = 1
--end
end end
function Simulation.dequeuegroup(sim, group) function Simulation.dequeuegroup(sim, group)
if group.in_queue~=0 then if group.in_queue~=0 then
array_remove(sim.groupqueue, group) array_remove(sim.groupqueue, group, true)
sim.num_groupqueue = sim.num_groupqueue - 1 sim.num_groupqueue = sim.num_groupqueue - 1
group.in_queue = 0 group.in_queue = 0
end end
@ -285,7 +283,7 @@ end
function Simulation.dequeuegate(sim, gate) function Simulation.dequeuegate(sim, gate)
if gate.in_queue~=0 then if gate.in_queue~=0 then
array_remove(sim.gatequeue, gate) array_remove(sim.gatequeue, gate, true)
sim.num_gatequeue = sim.num_gatequeue - 1 sim.num_gatequeue = sim.num_gatequeue - 1
gate.in_queue = 0 gate.in_queue = 0
end end
@ -307,13 +305,12 @@ end
-- Logic Critical -- Logic Critical
function Simulation.ticklogic(sim) function Simulation.ticklogic(sim)
local len = sim.num_groupqueue for i = 1, sim.num_groupqueue do
for i = 1, len do
local group = sim.groupqueue[i] local group = sim.groupqueue[i]
Group.update(group) Group.update(group)
group.in_queue = 0 group.in_queue = 0
end end
sim.groupqueue = {} --sim.groupqueue = {}
sim.num_groupqueue = 0 sim.num_groupqueue = 0
if sim.tickqueue[sim.current_tick] ~= nil then if sim.tickqueue[sim.current_tick] ~= nil then
@ -323,13 +320,12 @@ function Simulation.ticklogic(sim)
sim.tickqueue[sim.current_tick] = nil sim.tickqueue[sim.current_tick] = nil
end end
local len = sim.num_gatequeue for i = 1, sim.num_gatequeue do
for i = 1, len do
local gate = sim.gatequeue[i] local gate = sim.gatequeue[i]
gate.logic(gate) gate.logic(gate)
gate.in_queue = 0 gate.in_queue = 0
end end
sim.gatequeue = {} --sim.gatequeue = {}
sim.num_gatequeue = 0 sim.num_gatequeue = 0
sim.current_tick = sim.current_tick + 1 sim.current_tick = sim.current_tick + 1

View File

@ -68,7 +68,7 @@ function tobitstring(num, len)
return bitstring return bitstring
end end
function array_remove(array, value) function array_remove(array, value, pass)
for i = 1, #array do for i = 1, #array do
local v = array[i] local v = array[i]
if v==value then if v==value then
@ -77,7 +77,7 @@ function array_remove(array, value)
return return
end end
end end
error("element not in array") if not pass then error("element not in array") end
end end
function array_add(array, value) function array_add(array, value)