51 lines
977 B
Lua
51 lines
977 B
Lua
|
|
local ffi = FFI or require("ffi")
|
|
Simulation = Simulation or {}
|
|
|
|
ffi.cdef([[
|
|
struct Net {
|
|
|
|
};
|
|
]])
|
|
|
|
function Simulation.compile(sim)
|
|
-- assemble a list of all nets
|
|
local all_nets = {}
|
|
for wire_idx, wire in pairs(sim.wires) do
|
|
local net = Wire.getgroup(wire)
|
|
all_nets[net] = net
|
|
end
|
|
local num_nets = 0
|
|
for net_id, net in pairs(all_nets) do
|
|
num_nets = num_nets+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
|