add net and wire struct; move net update into its file
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user