make net states pointers
This commit is contained in:
@@ -4,16 +4,16 @@ local ffi = FFI
|
||||
Group = {}
|
||||
|
||||
function Group.new()
|
||||
local o = {
|
||||
local net = {
|
||||
-- Logic Critical
|
||||
state = 0,
|
||||
state_num = 0,
|
||||
state = ffi.new("int[1]"),
|
||||
state_num = ffi.new("int[1]"),
|
||||
in_queue = ffi.new("int[1]"),
|
||||
update_tick = ffi.new("int[1]"),
|
||||
gates_update = {},
|
||||
num_gates_update = 0,
|
||||
|
||||
fxstate = 0,
|
||||
update_tick = 0,
|
||||
|
||||
wires = {},
|
||||
out_ports = {},
|
||||
@@ -22,7 +22,11 @@ function Group.new()
|
||||
nout_ports = 0,
|
||||
nin_ports = 0,
|
||||
}
|
||||
return o
|
||||
net.state[0] = 0
|
||||
net.state_num[0] = 0
|
||||
net.in_queue[0] = 0
|
||||
net.update_tick[0] = 0
|
||||
return net
|
||||
end
|
||||
|
||||
function Group.getsize(group)
|
||||
@@ -95,7 +99,7 @@ function Group.addport(group, port)
|
||||
|
||||
group.out_ports[port] = port
|
||||
group.nout_ports = group.nout_ports + 1
|
||||
group.state_num = group.state_num + Port.getstate(port)
|
||||
group.state_num[0] = group.state_num[0] + Port.getstate(port)
|
||||
|
||||
Simulation.queuegroup_safe(GSim, group)
|
||||
|
||||
@@ -121,7 +125,7 @@ function Group.removeport(group, port)
|
||||
group.out_ports[port] = nil
|
||||
group.nout_ports = group.nout_ports - 1
|
||||
|
||||
group.state_num = group.state_num - Port.getstate(port)
|
||||
group.state_num[0] = group.state_num[0] - Port.getstate(port)
|
||||
|
||||
Simulation.queuegroup_safe(GSim, group)
|
||||
|
||||
@@ -176,11 +180,11 @@ end
|
||||
|
||||
-- Logic Critical
|
||||
function Group.setstate(group, state)
|
||||
if state ~= group.state then
|
||||
if state ~= group.state[0] then
|
||||
local sim = GSim
|
||||
|
||||
group.state = state
|
||||
group.update_tick = sim.current_tick
|
||||
group.state[0] = state
|
||||
group.update_tick[0] = sim.current_tick
|
||||
|
||||
local len = group.num_gates_update
|
||||
for i = 1, len do
|
||||
@@ -196,7 +200,7 @@ end
|
||||
|
||||
-- Logic Critical
|
||||
function Group.update(group)
|
||||
Group.setstate(group, group.state_num>0 and 1 or 0)
|
||||
Group.setstate(group, group.state_num[0]>0 and 1 or 0)
|
||||
end
|
||||
|
||||
function Group.rebuild_ports(group)
|
||||
|
||||
Reference in New Issue
Block a user