add c gate sim
This commit is contained in:
10
sim/gate.lua
10
sim/gate.lua
@@ -13,6 +13,9 @@ ffi.cdef [[
|
||||
int** port_net_in_queue;
|
||||
struct Net** port_nets_c;
|
||||
int objref;
|
||||
int logic_function;
|
||||
int data_size;
|
||||
int* data;
|
||||
};
|
||||
]]
|
||||
|
||||
@@ -34,6 +37,10 @@ function Gate.new(objref, definition)
|
||||
}
|
||||
gate.in_queue[0] = 0
|
||||
|
||||
if definition.data_size_c > 0 then
|
||||
gate.data_c = ffi.new("int["..(definition.data_size_c).."]")
|
||||
end
|
||||
|
||||
gate.c = ffi.new("struct Gate")
|
||||
gate.c.in_queue = gate.in_queue
|
||||
gate.c.port_states = gate.port_states
|
||||
@@ -42,6 +49,9 @@ function Gate.new(objref, definition)
|
||||
gate.c.port_net_in_queue = gate.port_net_in_queue
|
||||
gate.c.port_nets_c = gate.port_nets_c
|
||||
gate.c.objref = gate.objref
|
||||
gate.c.logic_function = definition.logic_function_c
|
||||
gate.c.data_size = definition.data_size_c
|
||||
gate.c.data = gate.data_c
|
||||
|
||||
return gate
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user