Moreover, the gate sr-latch may produce illegal
output when s = r = 1. Our elementary gates respects
DEVS encapsulation principle, so access to state vari-
ables are limited to elementary gate where those vari-
ables are declared. In order to avoid a not allowed
state for the gate sr-latch, we may couple its output
with a monitor component to forbidden undesirable
outputs by checking the assertion out
0
6= out
1
each
time an output is sent out through the port out
0
or out
1
.
However, this solution even if it avoids undesirable
outputs but it leads the sr-latch transitioning to an un-
desirable state. It is better to avoid undesirable inputs
than handle undesirable outputs. By adding a monitor
component handling the inputs s and r, we guaran-
tee that the sr-latch transition to a desirable state and
send out desirable outputs. As conclusion, designing
a valid sr-latch consists of using an additional compo-
nent that checks whether the inputs are desirable and
a gate sr-latch that design its logic function. This is
an issue to handle desirable inputs for any logic gate.
5 PERFORMANCE
COMPARISON
In order to show that DEVS is able to make simula-
tions of logic gate as fast as verilog, we firstly give
the simulation execution times of basic logic gates
and, or, not, nand and nor in both adevs-2.8.1 and
verilog-0.9.7. The input data simulation are identical
for both simulations: same delay for all atomic gates
and same input pulses; the simulation time is 4000
u.t (units of time). These simulations are carried out
on personal computer DELL with CPU Intel
c
Core2
Duo CPU E8400 - 3.00GHz × 2 where is set Ubuntu
14.0.4. The results are shown on Table 2.
Table 2: Execution time means of basic logic gates in mil-
liseconds.
and or not nand nor
adevs 16.0 15.6 9.2 24.8 17.2
verilog 23.6 22.0 18.0 24.0 23.2
By looking to results shown on Table 2, glob-
ally, the M&S of logic gates using adevs provides a
concrete gain on execution time. So, DEVS simula-
tion of logic gates is able to provide quick simula-
tions as such as those provided by well-known tools
in this field like verilog. In fact, the gate not designed
in DEVS is distinguished by a small execution time
comparing to other gates. The gate not has only one
inport, so it avoids the function δ
ext
to use the condi-
tional statement if then to determine on which port
the gate has received an event. This fact explains
what the gates and and or have considerable execu-
tion time for the same simulation data. These gates
hold two inports and they should check on which port
the event was received in order to update the right
state variable and compute correctly the output. The
composite gates nand and nor have the higher execu-
tion times due to fact that they involves each one two
internal gates {and, not} and {or, not} respectively. It
is quite that these composite gates present such exe-
cution times.
Now let us consider both design in adevs and ver-
ilog, the execution time of simulating basic gates and,
or and not with adevs are less than those in verilog.
However, the execution time of gates nand and nor
in adevs and verilog are close. This lost on speed of
adevs simulation is due to the architecture of DEVS
simulation which introduces additional processes (co-
ordinator) to simulate composite logic gates. Some-
one may believe that adevs loses on speed each time,
for the simulation of more complex composite gates.
For that we can use new architectures enhancing sim-
ulation process like those proposed by (Kim et al.,
2000) and (Franceschini and Bisgambiglia, 2014) to
reduce intermediary processes, and so the messages
will cross short paths. What this suggests that adevs
and DEVS simulator in C++ may provide interest-
ing simulation execution times of logic gate close to
Verolig.
Therefore DEVS as a discrete event formalism
and its simulation software could compare with other
software well-known and specialized in the field of
logic gate application.
6 CONCLUSION
In this paper, we proposed a modular and hierarchi-
cal approach to design logic gates in DEVS. We used
a simple language based on DEVS to design both
atomic and composite gates. In this approach, we
introduced logic statements well-known in logics to
compute outputs of logic gates and the time basis
to delay outputs with regard to inputs. In addition,
we were led to re-design the behavior of basic gates
in order to take into account the unknown state of
logic latches that occurs at initialization of simulation.
Note that our approach allows filtering inputs to avoid
the non-allowed state for these latches by composi-
tion, i.e., by a simple DEVS component that sends
out to latches only acceptable inputs. Recall that, the
adevs and verilog simulations carried out for differ-
ent logic gates provide execution times close for each
other.
Moreover, the approach still opens to take into
ModelingandSimulationofLogicGatesusingDEVS
217