当前位置: 首页 > news >正文

长沙简单的网站建设公司wordpress+手机应用

长沙简单的网站建设公司,wordpress+手机应用,企业直播解决方案,高端网站开发注意事项函数 函数的主要用途是编写一段可以随时调用n次的代码#xff0c;只需调用函数名即可#xff0c;不需要任何模拟时间来执行。函数是返回类型#xff0c;仅返回函数声明中提到的单个值#xff0c;如果未声明则返回一个位的值。 语法#xff1a; initial begin functio…函数 函数的主要用途是编写一段可以随时调用n次的代码只需调用函数名即可不需要任何模拟时间来执行。函数是返回类型仅返回函数声明中提到的单个值如果未声明则返回一个位的值。 语法 initial begin function_name(arguments); endfunction return_type(optional) function_name(arguments);statement1;statement2;. . statementN; endfunction 限制 函数内部的代码中不允许有#、、wait等耗时语句只能返回一个值无法从函数中调用任务因为任务允许有耗时的语句 调用函数有很多变体 调用以值作为参数的函数调用以变量作为参数的函数使用表达式中的值调用函数C使用带位置参数的变量调用函数调用自动函数通过变量的引用调用带有变量的函数调用返回类型为 void 的函数通过传递数组来调用函数调用具有默认值的变量的函数从函数调用任务使用 fork 和 join_none 的例外情况 调用以值作为参数的函数 示例 int result; initial begin resultsum(5,6); $display(\treturned from function and); $display(\tstored the value of sum in result); $display(\n\t %0t ns, value of sum is %0d,$time,result); end function int sum(int var1,var2); $display(entered into function); return var1var2; endfunction 在上面的示例中函数名称是 sum其返回类型为 int即它仅返回一个 int 值。 流程图 调用以变量作为参数的函数 示例 int result,a5,b6; initial begin $display(\tcalling the function); resultsum(a,b); $display(\treturned from function and); $display(\tstored the value of sum in result); $display(\n\t %0t ns, value of sum is %0d,$time,result); end function int sum(input int a,b); $display(entered into function); return ab; endfunction 流程图 使用表达式中的值调用函数 示例 initial begin $display(\n\t %0t ns, value of sum is %0d,$time,sum(5,6)); end function int sum(int var1,var2); $display(entered into function); return var1var2; endfunction 使用带位置参数的变量调用函数 示例 initial begin resultsum(.var1(5),.var2(6)); $display(\treturned from function and); $display(\tstored the value of sum in result); $display(\n\t %0t ns, value of sum is %0d,$time,result); end function int sum(int var1,var2); $display(entered into function); return var1var2; endfunction 调用自动函数 语法 function automatic function_name(arguments);示例 module func_automatic();int result1,result2;function int factorial_static(int var1);if(var12)result1factorial_static(var1-1)*var1;elsebeginresult11;endreturn result1;endfunctionfunction automatic int factorial_automatic(int var1);if(var12)result2factorial_automatic(var1-1)*var1;elsebeginresult21;endreturn result2;endfunctioninitialbeginresult1factorial_static(5);result2factorial_automatic(5);$display(factorial_static:%0d,result1);$display(factorial_automatic:%0d,result2);endendmodule: func_automatic 这里我们使用带有 automatic 关键字的函数这意味着每当调用该函数时都会创建新的内存而在 static 中每当调用该函数时都会使用相同的内存。 通过变量的引用调用带有变量的函数 语法 function automatic data_type function_name(ref arguments);流程图 示例 int result,addend,augend; initial begin addend5; augend6; $display(\tBefore calling function - addend %0d , augend %0d,addend,augend); $display(\tcalling the functions); resultsum_without_ref(addend,augend); $display(\tafter calling function without ref - addend %0d, augend %0d,addend,augend); resultsum_with_ref(addend,augend); $display(\tafter calling function with ref - addend %0d, augend %0d,addend,augend); end function automatic int sum_with_ref(ref int var1,var2); int temp; $display(\n\tentered into with ref function); tempvar1; var1var2; var2temp; $display(\tswapped variables by using ref ); return var1var2; endfunction : sum_with_ref function int sum_without_ref(input int var1,var2); int temp; $display(\n\tentered into without ref function); tempvar1; var1var2; var2temp; $display(\tswapped variables by without using ref ); return var1var2; endfunction : sum_without_ref 当通过传递变量引用来调用函数时需要提及关键字 automatic 和 ref如上例所示。 调用返回类型为 void 的函数 语法 //type casting void(function_name(arguments));或者 //declaring the function as void type which doesnt return any value. function void function_name(arguments);示例 initial begin display(\t ----output for function void return type-----); display(\t passing string to function for displaying); end function void display(string str); $display(%s,str); endfunction: display 通过传递数组来调用函数 语法 data_type array_name[size]; function automatic return_type function_name(ref data_type array_name); 示例 int array[5]; void(fun_arr(array)); $display(\treturned from function); $display(\n\t %0t ns, Array elements %0p,$time,array); end function automatic int fun_arr(ref int arr[5]); $display(\tEntered the function); foreach(arr[i])begin arr[i]i1; end $display(\t values assigned to array elements starts from 1); return 0; endfunction 一般来说我们不能从函数返回数组但可以使用引用传递来传递数组并且可以在函数中操作该数组。 调用具有默认值的变量的函数 语法 function_name() function return_type function_name(varable1deafult_value,variable2default_value)示例 initialbegin$display(\t ----output for function passing by values through variables-----);$display(\tcalling the function);resultsum();$display(\treturned from function and);$display(\tstored the value of sum in result);$display(\n\t %0t ns, value of sum is %0d,$time,result);endfunction int sum(input int var12,var23);$display(\n\tentered into function );return var1var2;endfunction: sum在此示例中调用函数但不传递任何值或变量那么在这种情况下函数所需的两个变量将采用分配给它们的默认值即在本例中为 2 3 得出的总和为 5。 如果调用函数时没有值和变量并且函数没有任何默认值则模拟器将抛出错误。 从函数调用任务 一般来说从函数调用任务是非法的编译器会报错但有一种特殊情况可以使用 fork join_none 从函数调用任务如下例所示。 示例 initial begin$display(\t %0t ns, In the initial block,$time); $display(\tcalling function); #1 void(function_call); end function function_call; fork $display( \t %0t ns Im in function,$time); $display(\t %0t ns, calling task from func,$time); task_call; join_none endfunction task task_call; #1 $display( \t %0t ns , Im in task,$time); #1 $display(\t %0t ns,leaving from task,$time); endtask 流程图 任务 任务task与函数类似但任务可以计算多个变量并使用输出或 inout 语句返回它们但不像函数那样必需即任务不是返回类型并且任务能够具有诸如 #、、等待。任务也可以调用另一个任务和函数。 语法 task_name(arguments); task task_name(arguments); statement1; statement2; . . statementN; endtask 限制 任务不可综合 流程图 automatic task 每当声明为 automatic task 时每次调用该任务时模拟器都会分配新的内存。一般来说任务在模块内部是静态的要使其自动执行需要添加 automatic 关键字如下所示。 语法 task automatic task_name()示例 task automatic factorial_automatic(int var1);#1;if(var12)beginfactorial_automatic(var1-1);resultresult*var1;endelsebeginresult1;-a;endendtaskinitialbeginforkfactorial_static(5);factorial_automatic(5);joinforkwait(a.triggered);$display( %0t ns , factorial_automatic:%0d,$time,result);end流程图 从任务中调用函数 示例 initialbegin$display(\t ----output for func from task----);$display(\t %0t ns, In the initial block,$time);$display(\tcalling task);task_sum;$display(\treturned to initial from function);end task task_sum;#1 $display( \t %0t ns , Im in task,$time);$display(\tcalling func inside a task);#1 void(function_sum);$display(\treturned to task from function);endtaskfunction function_sum;$display( \t %0t ns Im in function,$time);endfunction从函数中调用任务是非法的但从任务中调用 func 是正常的因为函数没有任何耗时的语句。 流程图 全局任务 如果一个任务是在模​​块和类之外声明的则该任务被称为全局任务默认的全局任务本质上是静态的。该全局任务可以从任何模块调用通过以下示例可以更好地理解。 示例 task mul(input int var1,var2,output int res);#1 resvar1*var2;endtaskmodule task1();int multiplicand5,multiplicator6,result;initialbegin$display(\t ----output of global task----);mul(multiplicand,multiplicator,result);$display(\t %0t ns , %0d X %0d %0d,$time,multiplicand,multiplicator,result);endendmodulemodule task2();int r;initialbegin#2 mul(7,8,r);$display(\t %0t ns , 7 X 8 %0d,$time,r);endendmodule禁用任务 可以通过在任务名称中使用关键字 disable 来禁用任务这会在调用禁用时停止该特定任务。 示例 module disable_task();initialbegin$display(\t ----output of disable task----);forkdisplay_task();#20 disable display_task.task_A;joinendtask display_task();begin : task_A$display(\t %0t ns , task_A initiated,$time);#30 $display(\t %0t ns , task_A finished,$time);end :task_Abegin : task_B$display(\t %0t ns , task_B initiated,$time);#10 $display(\t %0t ns , task_B finished,$time);end :task_Bendtaskendmodule
http://www.pierceye.com/news/265721/

相关文章:

  • 快速开发网站的应用程序网站高中建设工具
  • 备案期间网站可以做竞价吗网站开发四川
  • 盐城网站app建设竣工验收备案查询
  • 河南省建设厅八大员网站相城网页设计
  • 建设电子商务网站要多少钱怎么自己开公司
  • 网站设计分析怎么写5年的室内设计师收入
  • 珠海网站建设服务谷歌关键词排名查询工具
  • 三网站合一系统优化最好的安卓手机
  • 那几个网站可以做h5产品经理培训哪个机构好
  • 吉林市做网站阿里巴巴国际站怎么运营
  • 中国网站排名100网站建设属于销售费用
  • 最新seo网站优化教程温州微网站
  • 网站双线选择昆明网站制作代理
  • 网站推广优化招聘织梦网站图片设置多大
  • 四川德充建设集团有限公司网站台州seo免费诊断
  • 农庄网站模板网站 文件夹 上传
  • 做长图文网站企业网站开发服务合同
  • 长椿街网站建设九江网站推广徽hyhyk1
  • 贴吧做网站wordpress不兼容ie
  • 上海万网网站建设网络工程专业是什么
  • 到国外建网站自己做的视频发什么网站吗
  • 高校网站平台建设快速网站排名
  • seo技术 如何优化网站内部结构用ps做网站方法
  • vi设计公司网站python做网站好处
  • 北京专业网站建设服务商枣庄建设工程管理局网站
  • 百度移动网站提交深圳做网站的好公司
  • 十大在线编程网站旅游营销型网站
  • 微转app是用网站做的吗win10运行wordpress
  • 微网站建设哪里便宜网站做的跟别人的一样可以吗
  • 合肥优化网站福州网站设计