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 />

Defining and Running Simulations<br />

.define_testbench tb_rc(v_extract=4)<br />

.param param_v = 5<br />

.param param_r = 10k<br />

.param param_c = 1m<br />

v1 1 0 param_v<br />

r1 1 2 param_r<br />

c1 2 0 param_c ic=0<br />

.tran 1 20 uic<br />

* Give a name to the waveform to be able to retrieve it from the task.<br />

.plot tran uc=v(2,0)<br />

* Give a label to the extract to be able to retrieve it from the task.<br />

.extract tran label=x_extract xthres(v(2,0), v_extract)<br />

.end_define_testbench<br />

.define_task t_simu<br />

set pv = 0<br />

set pr = 0<br />

set pc = 0<br />

set ptemp = 0<br />

set extract_res = 0<br />

set xval_res_vect = 0<br />

set xval_res = 0<br />

set uc_wave = 0<br />

/* Run the simulation and get some results (parameter values,<br />

extract value and waveform) inside local variables.*/<br />

if (simulation( \<br />

name="simu_rc/simu_rc.cir", \<br />

tb_rc(), \<br />

pv=@param_v, \<br />

pr=@param_r, \<br />

pc=@param_c, \<br />

ptemp=@temp, /* temp is indeed an implicitly defined parameter. */ \<br />

extract_res=@x_extract, \<br />

uc_wave=@uc \<br />

).simu_status == 0)<br />

/* Call xval on the waveform to see if we get the same result as<br />

the extract result. */<br />

xval_res_vect = xval(uc_wave, 4)<br />

/* xval_res_vect is a vector because there could be many values.<br />

Take the first one here. */<br />

xval_res = xval_res_vect[xval_res_vect.imin]<br />

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

fprint(stdout, "with v=%.4eV, r=%.4eOhm, c=%.4eF, temp=%.4fC\n", pv,<br />

pr, pc, ptemp)<br />

fprint(stdout, "uc reaches 4V at %.4fs (.extract)\n", extract_res)<br />

fprint(stdout, "uc reaches 4V at %.4fs (.plot + xval)\n", xval_res)<br />

else<br />

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

endif<br />

.end_define_task<br />

.t_simu<br />

Eldo® User's Manual, 15.3 847

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

Saved successfully!

Ooh no, something went wrong!