CCIE 发表于 2010-6-28 00:08:23

verilog 中的函数(tunction)如何用?

哪位大哥知道在verilog中怎么用函数function呀,我今天照着书上写了一个,可是不知道该怎么调用,谁写过完整的程序传上来一个吧

tim 发表于 2010-6-28 01:30:40

module test(con,...);<br>
input&nbsp;&nbsp;con;<br>
...<br>
//定义一个函数a<br>
function &nbsp;&nbsp;a;<br>
input&nbsp; &nbsp;operate; <br>
begin<br>
&nbsp; &nbsp;&nbsp; &nbsp; if (operate)<br>
&nbsp; &nbsp;&nbsp; &nbsp; begin<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;a&nbsp;&nbsp;= (2'b01)*(2'b11);<br>
&nbsp; &nbsp;&nbsp; &nbsp; end&nbsp;&nbsp;<br>
end<br>
endfunction<br>
<br>
reg result;<br>
always @ ( * )<br>
begin<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; result&nbsp;&nbsp;= a(con);&nbsp; &nbsp; //调用已经定义的一个函数a,con值传递给operate<br>
end<br>
<br>
endmodule

ATA 发表于 2010-6-28 03:21:55

好象有点道理啊,谢谢

VVIC 发表于 2010-6-28 04:41:25

看过<br>
谢谢
页: [1]
查看完整版本: verilog 中的函数(tunction)如何用?