集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2939|回复: 3

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

[复制链接]
CCIE 发表于 2010-6-28 00:08:23 | 显示全部楼层 |阅读模式
哪位大哥知道在verilog中怎么用函数function呀,我今天照着书上写了一个,可是不知道该怎么调用,谁写过完整的程序传上来一个吧
tim 发表于 2010-6-28 01:30:40 | 显示全部楼层
module test(con,...);<br>
input&nbsp;&nbsp;con;<br>
...<br>
//定义一个函数a<br>
function [3:0]&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 [3:0] 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 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-15 22:50 , Processed in 0.124013 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表