|
我先实现流水灯的效果,用任务调用的办法,以下是我编的代码
module LED(clk, Led);
input clk;
output [7:0]Led;
reg [7:0]Led;
reg [31:0] count;
integer a;
initial a = 2'H01;
/*************************************/
task Led_Light;
input [7:0]ss;//用来接收传递过来的参数,不知道可不可以这样写。
output [7:0]ll;//这是LED的8个脚
reg [7:0]ll;
begin
ll <= ss;
end
endtask
/*************************************/
always @(posedge clk)//时钟上升沿
begin
if (count == 32'D5_000_000)//50M的晶振
begin
count = 32'D0;
Led_Light(a, Led);//任务调用,a为赋给LED的值,16进制
a = a << 1; //移位
end
else
begin
count = count + 32'D1;
if (a == 2'H80)
a = 2'H01;
end
end
/*************************************/
endmodule
问题来了,效果居然是这样的:流水-全灭-流水-全灭-流水......
而我想要的效果是: 流水-流水-流水-流水-流水......
中间没连接起来,不知道那段时间为什么被吞了,居然全灭了,代码哪里有问题呢?
不知道在verilog中传递参数是怎么做的,我尝试这样写就出了这个问题。 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|