start adding c structs for gates and ports
This commit is contained in:
26
sim/gate.lua
26
sim/gate.lua
@@ -1,6 +1,14 @@
|
||||
|
||||
Gate = {}
|
||||
|
||||
FFI.cdef[[
|
||||
struct Gate {
|
||||
int objref;
|
||||
int definition_objref;
|
||||
struct Port ports[1];
|
||||
};
|
||||
]]
|
||||
|
||||
function Gate.new(self, objref, definition, sim)
|
||||
local o = {
|
||||
objref = objref,
|
||||
@@ -57,3 +65,21 @@ end
|
||||
function Gate.getsim(gate)
|
||||
return gate.sim
|
||||
end
|
||||
|
||||
function Gate.getdefinition(gate)
|
||||
return gate.definition
|
||||
end
|
||||
|
||||
-- Logic functions
|
||||
|
||||
function Gate.init(gate)
|
||||
Gate.getdefinition(gate).init(gate)
|
||||
end
|
||||
|
||||
function Gate.logic(gate)
|
||||
Gate.getdefinition(gate).logic(gate)
|
||||
end
|
||||
|
||||
function Gate.input(gate, argv)
|
||||
Gate.getdefinition(gate).input(gate, argv)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user