lua-logic/sim/compile.lua
2021-05-25 05:26:06 -05:00

51 lines
989 B
Lua

local ffi = FFI or require("ffi")
Simulation = Simulation or {}
ffi.cdef([[
struct Net {
};
]])
function Simulation.compile(sim)
-- assemble a list of all groups
local groups = {}
for wire_idx, wire in pairs(sim.wires) do
local group = Wire.getgroup(wire)
groups[group] = group
end
local num_groups = 0
for group_id, group in pairs(groups) do
num_groups = num_groups+1
end
-- construct each gate into an array
-- construct each group into an array
local group_idx = 0
local array_nets = ffi.new("struct Net["..num_groups.."]")
for group_id, group in pairs(groups) do
local c_net = ffi.new("struct Net")
local ports_update = {}
for port_id, port in pairs(group.in_ports) do
if port.causeupdate then
num_ports_update = num
end
end
--c_net.ports_update = ffi.new("struct Port["..
array_nets[group_idx] = c_net
group_idx = group_idx + 1
end
end
function Simulation.decompile(sim)
end
function Simulation.tickcompiled(sim)
end