add net and wire struct; move net update into its file

This commit is contained in:
Redo0
2021-05-25 15:13:03 -05:00
parent 8561940777
commit d151ab688c
5 changed files with 38 additions and 15 deletions

View File

@@ -1,6 +1,19 @@
Group = {}
FFI.cdef[[
struct Port;
struct Net {
bool state;
bool fxstate;
int updatetick;
int internal_ref;
int state_num;
int num_in_ports_update;
struct Port* in_ports_update[1];
};
]]
function Group.new(self, sim)
local o = {
state = false,
@@ -9,6 +22,8 @@ function Group.new(self, sim)
wires = {},
out_ports = {},
in_ports = {},
state_num = 0,
nwires = 0,
nout_ports = 0,
@@ -154,3 +169,15 @@ end
function Group.getsim(group)
return group.sim
end
function Group.update(group)
local newstate = false
for j, port in pairs(group.out_ports) do
newstate = newstate or Port.getstate(port)
if newstate then
break
end
end
Group.setstate(group, newstate)
end