make nets keep list of updated gates instead of ports
This commit is contained in:
@@ -2,36 +2,68 @@
|
||||
local ffi = FFI or require("ffi")
|
||||
Simulation = Simulation or {}
|
||||
|
||||
ffi.cdef[[
|
||||
struct Wire {
|
||||
int objref;
|
||||
int layer;
|
||||
struct Net* group;
|
||||
int bounds[6];
|
||||
};
|
||||
|
||||
struct Port {
|
||||
bool state;
|
||||
char type;
|
||||
struct Gate* gate;
|
||||
struct Net* group;
|
||||
};
|
||||
|
||||
struct Gate {
|
||||
int logic_ref;
|
||||
bool in_queue;
|
||||
struct Port ports[?];
|
||||
};
|
||||
|
||||
struct Net {
|
||||
bool state;
|
||||
bool in_queue;
|
||||
int updatetick;
|
||||
int state_num;
|
||||
int num_gates_update;
|
||||
struct Gate* gates_update[?];
|
||||
};
|
||||
]]
|
||||
|
||||
function Simulation.compile(sim)
|
||||
-- assemble a list of all nets
|
||||
local all_nets = {}
|
||||
for wire_idx, wire in pairs(sim.wires) do
|
||||
local all_nets_t = {}
|
||||
for k, wire in pairs(sim.wires) do
|
||||
local net = Wire.getgroup(wire)
|
||||
all_nets[net] = net
|
||||
all_nets_t[net] = net
|
||||
end
|
||||
local num_nets = 0
|
||||
for net_id, net in pairs(all_nets) do
|
||||
num_nets = num_nets+1
|
||||
for net_id, net in pairs(all_nets_t) do
|
||||
table.insert(all_nets, net)
|
||||
end
|
||||
|
||||
-- assemble a list of all gates
|
||||
local all_gates = {}
|
||||
for k, gate in pairs(sim.gates) do
|
||||
table.insert(all_gates, gate)
|
||||
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")
|
||||
-- construct array of all nets
|
||||
local c_nets = ffi.new("struct Net["..(#all_nets).."]")
|
||||
for net_idx, net in ipairs(all_nets) do
|
||||
local c_net = ffi.new("struct Net", #net.gates_update)
|
||||
|
||||
local ports_update = {}
|
||||
for port_id, port in pairs(group.in_ports) do
|
||||
if port.causeupdate then
|
||||
num_ports_update = num
|
||||
end
|
||||
for gate_idx, gate in ipairs(net.gates_update) do
|
||||
|
||||
end
|
||||
--c_net.ports_update = ffi.new("struct Port["..
|
||||
|
||||
array_nets[group_idx] = c_net
|
||||
group_idx = group_idx + 1
|
||||
c_nets[net_idx] = c_net
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,6 +71,6 @@ function Simulation.decompile(sim)
|
||||
|
||||
end
|
||||
|
||||
function Simulation.tickcompiled(sim)
|
||||
function Simulation.tick_compiled(sim)
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user