ADS学习日志
AEL脚本
decl CKT_BATCH_QUEUE_STATE;
decl CKT_NUM = 0;
decl i = 0;
decl j = 0;
decl k = 0;
defun mybatch_simulation()
{
if(ckt_simulaion_is_running())
{
de_info("A circuit simulation is currently running.\nPlease wait until this simulation is done.");
return;
}
// desim_use_queued_simulators() was introduced in ADS 2004A
// This line makes sure the code works in earlier versions
if ( ! is_word( find_word( "desim_use_queued_simulators" ) ) )
execute( "defun desim_use_queued_simulators( ) { return FALSE; }" );
// Save the queue state
CKT_BATCH_QUEUE_STATE = desim_use_queued_simulators(FALSE);
mybatch_simulate_design();
}
defun mybatch_simulate_design()
{
k = CKT_NUM%5;
j = ((CKT_NUM-k)/5)%4;
i = (((CKT_NUM-k)/5-j)/4)%2;
// Open desired schematic
//de_open_design("mybatch_test",FALSE); // Tweak to desired name..
de_set_window_by_sequence(0, 0);
de_open_workspace("E:\ADS\LTE\QYL_LTE_TESTwrk");
//de_bring_view_to_top_or_open_new_window("QYL_LTE_TESTwrk1_lib_1", "LTE", "schematic", 3);
de_get_design_context_from_name("QYL_LTE_TESTwrk1_lib:LTE:schematic");
decl itemInfo0SP=de_edit_item("VAR2");
de_set_item_id(itemInfo0SP, "VAR2");
de_set_item_parameters(itemInfo0SP, list(list(prm_ex("ads_datacmps","VarFormEditcompPowerVar",prm_ex("ads_datacmps","VarNameForm","CType1"),prm_ex("ads_datacmps","VarValueForm",i)),prm_ex("ads_datacmps","VarFormEditcompPowerVar",prm_ex("ads_datacmps","VarNameForm","CType"),prm_ex("ads_datacmps","VarValueForm","if (CType1==0) then 0 elseif (CType1==1) then 2 else 0 endif")))));
de_end_edit_item(itemInfo0SP);
itemInfo0SP=de_free_item(itemInfo0SP);
decl itemInfo1SP=de_edit_item("SNR_Computation1");
de_set_item_id(itemInfo1SP, "SNR_Computation1");
de_set_item_parameters(itemInfo1SP, list(list(prm_ex("ads_datacmps","VarFormEditcompPowerVar",prm_ex("ads_datacmps","VarNameForm","SNR1"),prm_ex("ads_datacmps","VarValueForm",j)),prm_ex("ads_datacmps","VarFormEditcompPowerVar",prm_ex("ads_datacmps","VarNameForm","RS_EPRE"),prm_ex("ads_datacmps","VarValueForm","-25")),prm_ex("ads_datacmps","VarFormEditcompPowerVar",prm_ex("ads_datacmps","VarNameForm","NDensity"),prm_ex("ads_datacmps","VarValueForm","RS_EPRE-10*log10(15e3)-SNR")),prm_ex("ads_datacmps","VarFormEditcompPowerVar",prm_ex("ads_datacmps","VarNameForm","SNR"),prm_ex("ads_datacmps","VarValueForm","if (SNR1==0) then 0 elseif (SNR1==1) then -10 elseif (SNR1==2) then -20 elseif (SNR1==3) then -30 else 0 endif")))));
de_end_edit_item(itemInfo1SP);
itemInfo1SP=de_free_item(itemInfo1SP);
decl itemInfo2SP=de_edit_item("VAR1");
de_set_item_id(itemInfo2SP, "VAR1");
de_set_item_parameters(itemInfo2SP, list(list(prm_ex("ads_datacmps","VarFormEditcompPowerVar",prm_ex("ads_datacmps","VarNameForm","LoFreq"),prm_ex("ads_datacmps","VarValueForm","1895e6+LoFreq2 Hz")),prm_ex("ads_datacmps","VarFormEditcompPowerVar",prm_ex("ads_datacmps","VarNameForm","LoFreq1"),prm_ex("ads_datacmps","VarValueForm",k)),prm_ex("ads_datacmps","VarFormEditcompPowerVar",prm_ex("ads_datacmps","VarNameForm","LoFreq2"),prm_ex("ads_datacmps","VarValueForm","if (LoFreq1==0) then 0 elseif (LoFreq1==1) then 100 elseif (LoFreq1==2) then 1000 elseif (LoFreq1==3) then 10000 elseif (LoFreq1==4) then 100000 else 0 endif")))));
de_end_edit_item(itemInfo2SP);
itemInfo2SP=de_free_item(itemInfo2SP);
// Simulate it
decl wInst=api_get_current_window();
de_analyze();
// Wait for the simulation to finish
// install a timer function
api_set_timer("cktSimTimer", // timer name
1000, // number of milliseconds b/n calls
1, // auto repeat
"ckt_sim_check_timer_cb", // callback
NULL); // cbData of callback
}
defun ckt_sim_check_timer_cb (cbData, callData)
{
if (!ckt_simulaion_is_running())
{
// make sure to remove timer function
api_remove_timer("cktSimTimer");
// Increase Design Number
CKT_NUM++;
// More designs to simulate?
if ( CKT_NUM <= 39 )
mybatch_simulate_design();
else
{
// Reset the queue state
desim_use_queued_simulators(CKT_BATCH_QUEUE_STATE);
de_info("Done!");
}
}
}
defun ckt_simulaion_is_running()
{
//decl dsnDir = de_current_design_name();
//decl workDir = de_mom_get_working_dir(db_get_design(dsnDir));
if (desim_foreground_simulation_running())
{
return TRUE;
}
else
{
return FALSE;
}
}
mybatch_simulation();