标签:rto 事件 fopen 其它 scanf _id 格式 pointer 变量
task[automatic] task_id; [declarations] procedural_statement endtask
**任务可以没有参变量,也可以有多个参变量,包括input,output,inout。
示例:module esoc; parameter MAX = 8; task reverse_bits; input [MAX-1:0] data_in; output [MAX-1:0] data_out; integer k; begin for(k=0; k<MAX; k=k+1) data_out[MAX-1-k] = data_in[k]; end endtask ... endmodule
**任务可以在其范围内声明任何变量,但仅限于其范围内使用,为局部变量。
**关于automatic:task automatic rotate; integer mac; ...; endtask
module golobal_var; reg[0:7]qram[0:63]; integer index; reg check_bit; task get_parity; input [7:0]address; output parity_bit; parity_bit = ^qram[address]; endtask initial for(index=0; index<=63; index = index+1) begin get_parity(index, check_bit); $display("Parity bit of memory word %d is %b.",index, check_bit); end endmodule
**系统任务
integer file_pointer = $fopen(file_name, mode); $fclose(file_pointer);
mode:
"r","rb":打开文件并从文件的头开始读。如果文件不存在就报的错。$timeformat(units_number, precision, suffix, numeric_filed_width);
(c)仿真任务:
使仿真器退出仿真环境:$finishfunction [automatic][signed] [range_of_type] function_id; //function_id为返回的值 input_declaration other_declarations procedural_statement endfunction //或 function [automatic][signed] [range_of_type] function_id(input_declaration); other_declarations procedural_statement endfunction
**函数的调用:
disable task_id; disable bolck_id;
(4)命名事件
event state1, state2, state3; //复位状态 initial begin ->state1; end always@(state1)begin ->state2; end always@(state2)begin ->state3; end always@(state3)begin if(input_a) ->state2; else ->state1; end
标签:rto 事件 fopen 其它 scanf _id 格式 pointer 变量
原文地址:https://www.cnblogs.com/vilicute/p/11614595.html