Task的可综合与不可综合:
下面的代码是不可进行综合的:
begin
uart_tx_module(8'h12);
uart_tx_module(8'h78);
end
task uart_tx_module;
input [7:0] data;
begin
uart_tx = 1;
#1000
uart_tx = 0;
#1000
uart_tx = data[0];
#1000
uart_tx = data[1];
#1000
uart_tx = data[2];
#1000
uart_tx = data[3];
#1000
uart_tx = data[4];
#1000
uart_tx = data[5];
#1000
uart_tx = data[6];
#1000
uart_tx = data[7];
#1000
uart_tx = 1;
end
endtask
因为在task中有延时 #1000,这种,命令是无法进行综合分析的
像下面task代码中,没有延时的代码,只有逻辑功能,所以是可以综合的
begin
case(state)
0: CMD(0001);
1: CMD(0010);
2: CMD(0100);
3: CMD(1000);
endcase
end
task CMD;
input [3:0] command;
begin
CS <= command[3];
RAS <= command[2];
CAS <= command[1];
WE <= command[0];
end
endtask
initial语句在有些时候也是可以综合的
initial cnt = 0;
always@(posedge clk)
if(cnt ==10)
cnt<=0;
else
cnt<=cnt+1'b1;
end if;
但是推荐使用reset来进行复位