HDL task/initial可综合/不可综合

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来进行复位

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值