微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 菜鸟关于verilog中函数调用的问题

菜鸟关于verilog中函数调用的问题

时间:10-02 整理:3721RD 点击:
源程序如下:在但是仿真波形输出的 y值是  xxxxxxx
module hanshu(x,y
    );
input [3:0]x;
output integer y;

function automatic integer factor;
input [3:0]a;
reg [3:0]i;

begin
factor=1;
for(i=2;i<=a;i=i+1)
begin
factor=factor*i;
$display("the value of fanctor at present is :%e",factor);
end
end
endfunction

always@(x)
begin
y=factor(x);
end
endmodule

X输入问题。



把i,a换成integer试一试。
function automatic integer factor;
    input integer a;
    integer i;
或者,这样试一试:
把testbench中的
#10 x=4'b1111;
换成
#10 x=4'b0111;

a=4'b1111时,
for(i=2;i<=a;i=i+1)
是个无限循环。

太复杂了

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top