make net in port lists arrays
This commit is contained in:
parent
d25893566e
commit
730ca3fd64
@ -28,8 +28,8 @@ function Gate.addport(self, port)
|
|||||||
Port.setgate(port, self)
|
Port.setgate(port, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Gate.getportstate(self, index)
|
function Gate.getportstate(gate, index)
|
||||||
return self.ports[index].group.state
|
return gate.ports[index].group.state
|
||||||
end
|
end
|
||||||
|
|
||||||
function Gate.setportstate(self, index, state)
|
function Gate.setportstate(self, index, state)
|
||||||
|
@ -118,7 +118,7 @@ function Group.addport(self, port)
|
|||||||
self.in_ports[port] = port
|
self.in_ports[port] = port
|
||||||
self.nin_ports = self.nin_ports + 1
|
self.nin_ports = self.nin_ports + 1
|
||||||
if port.causeupdate then
|
if port.causeupdate then
|
||||||
self.in_ports_update[port] = port
|
table.insert(self.in_ports_update, port)
|
||||||
end
|
end
|
||||||
|
|
||||||
Simulation.queuegate(GSim, Port.getgate(port))
|
Simulation.queuegate(GSim, Port.getgate(port))
|
||||||
@ -147,7 +147,7 @@ function Group.removeport(self, port)
|
|||||||
self.in_ports[port] = nil
|
self.in_ports[port] = nil
|
||||||
self.nin_ports = self.nin_ports - 1
|
self.nin_ports = self.nin_ports - 1
|
||||||
if port.causeupdate then
|
if port.causeupdate then
|
||||||
self.in_ports_update[port] = nil
|
array_remove(self.in_ports_update, port)
|
||||||
end
|
end
|
||||||
|
|
||||||
Simulation.queuegate(GSim, Port.getgate(port))
|
Simulation.queuegate(GSim, Port.getgate(port))
|
||||||
@ -198,7 +198,7 @@ function Group.setstate(self, state)
|
|||||||
self.state = state
|
self.state = state
|
||||||
self.updatetick = sim.currenttick
|
self.updatetick = sim.currenttick
|
||||||
|
|
||||||
for k, port in pairs(self.in_ports_update) do
|
for k, port in ipairs(self.in_ports_update) do
|
||||||
Simulation.queuegate(sim, Port.getgate(port))
|
Simulation.queuegate(sim, Port.getgate(port))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ while 1 do
|
|||||||
local group = Wire.getgroup(wire)
|
local group = Wire.getgroup(wire)
|
||||||
local numwires = 0; for k, wire2 in pairs(group.wires ) do numwires = numwires +1 end
|
local numwires = 0; for k, wire2 in pairs(group.wires ) do numwires = numwires +1 end
|
||||||
local numportsi = 0; for k, port in pairs(group.in_ports ) do numportsi = numportsi+1 end
|
local numportsi = 0; for k, port in pairs(group.in_ports ) do numportsi = numportsi+1 end
|
||||||
local numportsu = 0; for k, port in pairs(group.in_ports_update) do numportsu = numportsu+1 end
|
local numportsu = #group.in_ports_update
|
||||||
local numportso = 0; local numportson=0;
|
local numportso = 0; local numportson=0;
|
||||||
for k, port in pairs(group.out_ports) do
|
for k, port in pairs(group.out_ports) do
|
||||||
numportso = numportso+1
|
numportso = numportso+1
|
||||||
|
@ -270,18 +270,6 @@ function Simulation.queuegroup(self, group)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function array_remove(array, value)
|
|
||||||
for i = 1, #array do
|
|
||||||
local v = array[i]
|
|
||||||
if v==value then
|
|
||||||
array[i] = array[#array]
|
|
||||||
array[#array] = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
error("element not in array")
|
|
||||||
end
|
|
||||||
|
|
||||||
function Simulation.dequeuegroup(self, group)
|
function Simulation.dequeuegroup(self, group)
|
||||||
if group.in_queue then
|
if group.in_queue then
|
||||||
array_remove(self.groupqueue, group)
|
array_remove(self.groupqueue, group)
|
||||||
|
@ -66,3 +66,14 @@ function tobitstring(num, len)
|
|||||||
return bitstring
|
return bitstring
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function array_remove(array, value)
|
||||||
|
for i = 1, #array do
|
||||||
|
local v = array[i]
|
||||||
|
if v==value then
|
||||||
|
array[i] = array[#array]
|
||||||
|
array[#array] = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
error("element not in array")
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user