淘宝官方店 推荐课程 在线工具 联系方式 关于我们 | |
微波射频仿真设计 Ansoft Designer 中文培训教程 | HFSS视频培训教程套装 |
|
首页 >> Ansoft Designer >> Ansoft Designer在线帮助文档 |
Nexxim Simulator > Digital Clock ModelHere is a model for a digital clock source. This SOURCE type model has no inputs and one output. Here is a listing of the model file, dclock.m, with explanations. The initial comment line (identified by %NEXSYS) is the model definition line. Nexsys reads the model definition into a structure that contains various information the simulator needs. % NEXSYS FUNCTIONAL_MODEL ("dclock", "0","", "", "1","r", "1","NO_DATA_REQ", "NOT_APPLICABLE", "PERIOD,DELAY=0,DUTY=0,NSAMP,SAMPLE_RATE") Here are explanations for the entries in the dclock model definition
Here is the Matlab function declaration for the digital clock. The function name, dclock in this example, is the same as model name. function [ y, SV ] = dclock (p, SV, status_in) The input and output variables for the function are:
The first step is to read the values from the parameters passed to the function. % Get parameters from function argument p period = p(1) During the initialization call, the dclock model sets up its state variables structure SV. During later calls, the model retrieves the data. total_num_out = 0; % (status_in == 0) => Analysis initialization stage if status_in == 0 delay_mode = 0; if (delay > 0) delay_mode = 1; end time_pos = 0.0; total_out_num = 0; SV = [delay_mode time_pos total_num_out] else delay_mode = SV(1); time_pos = SV(2); total_num_out = SV(3); end Here is how dclock calculates the output (digital clock) values: out_value = 0.0; if delay_mode == 1 time_elapsed = (total_num_out + 1) / sample_rate; if (delay > time_elapsed) out_value = 0.0; else delay_mode = 0; end else if ((time_pos>=0) && (time_pos < (duty * period))) out_value = 1.0; else out_value = 0.0; end %re-calculate the time position time_pos = time_pos + 1.0 / sample_rate; if (time_pos >= period) time_pos = time_pos - period; elseif (time_pos == period) time_pos = 0.0; end end y(1) = out_value; total_num_out = total_num_out + 1; Finally, dclock saves its state variables SV and returns. SV = [delay_mode time_pos total_num_out]; return HFSS视频教程 ADS视频教程 CST视频教程 Ansoft Designer 中文教程 |
Copyright © 2006 - 2013 微波EDA网, All Rights Reserved 业务联系:mweda@163.com |