10.06.2016 Views

eldo_user

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Eldo Control Language<br />

Simulation Dynamic Control<br />

...<br />

.define_task t_rc<br />

set v = 10<br />

set r = 20<br />

set c = 0.1<br />

set res = simulation(tb_rc(p_v=v, p_r=r, p_c=c),<br />

/* Pass the testbench arguments to the callback. */<br />

+ callback=f_callback_rc(p_v=v, p_r=r, p_c=c),<br />

+ condition="v(2) > " + (0.632 * v))<br />

if (res.simu_status == 0)<br />

fprint(stdout, "Simulation succeeded.\n")<br />

else<br />

fprint(stdout, "Simulation failed.\n")<br />

endif<br />

.end_define_task<br />

.define_function f_callback_rc (p_v=1, p_c=1, p_r=1)<br />

fprint(stdout, "The simulation of 'tb_rc p_v=%.1f p_c=%.1f p_r=%.1f' has<br />

been stopped " +<br />

+ "at t = %.1f s " +<br />

+ "because the expected condition has been met.\n",<br />

+ _simu_get("time"),<br />

+ p_v, p_r, p_c)<br />

return 1<br />

.end_define_function<br />

.t_rc<br />

It is possible to do the same if the callback needs to have output arguments.<br />

If a periodic callback needs to save some values so that it can retrieve them the next time it is<br />

called, then it has to define one input and one output variable for each of them, to be able to<br />

store and get the result from a local variable defined in the main task.<br />

See “Tasks” on page 814, “Variables” on page 821, “Flow Control Statements” on page 835,<br />

“Defining and Running Simulations” on page 841, and the fprint function for more information<br />

on the concepts used in the example.<br />

Example 2<br />

This example shows how to sample a signal using a periodic callback and store the values in an<br />

array defined in the main task. The current index in the array also needs to be saved.<br />

1022<br />

Eldo® User's Manual, 15.3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!