make nets keep list of updated gates instead of ports
This commit is contained in:
24
sim/port.lua
24
sim/port.lua
@@ -15,20 +15,6 @@ PortDirections = {
|
||||
|
||||
Port = {}
|
||||
|
||||
FFI.cdef[[
|
||||
struct Gate;
|
||||
struct Net;
|
||||
struct Port {
|
||||
bool state;
|
||||
char type;
|
||||
char direction;
|
||||
bool causeupdate;
|
||||
int position[3];
|
||||
struct Gate* gate;
|
||||
struct Net* group;
|
||||
};
|
||||
]]
|
||||
|
||||
function Port.new(type, direction, position, causeupdate)
|
||||
local o = {
|
||||
type = type,
|
||||
@@ -44,13 +30,13 @@ end
|
||||
|
||||
function Port.setstate(port, state) -- output state
|
||||
if state ~= port.state then
|
||||
local group = port.group
|
||||
group.state_num = group.state_num - (port.state and 1 or 0) + (state and 1 or 0)
|
||||
port.state = state
|
||||
if state then
|
||||
Port.getgroup(port).state_num = Port.getgroup(port).state_num + 1
|
||||
else
|
||||
Port.getgroup(port).state_num = Port.getgroup(port).state_num - 1
|
||||
|
||||
if (group.state_num>0) ~= group.state then
|
||||
Simulation.queuegroup(GSim, group)
|
||||
end
|
||||
Simulation.queuegroup(GSim, Port.getgroup(port))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user