make sim local; start circuit compiler
This commit is contained in:
@@ -1,6 +1,44 @@
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user