
修改了一下,加了输入输出端口,以及触发条件
module test(red,amber,green ,able);
input able;
output red,amber,green;
reg clock,red,amber,green;
parameter on=1,off=0,red_tics=350,green_tics=200,amber_tics=30;
//交通灯初始化
initial red=off;
initial amber=off;
initial green=off;
//交通灯控制时序
always
wait(able)
begin
red=on;//开红灯
light(red,red_tics);//调用等待任务
green=on;//开绿灯
light(green,green_tics);//等待
amber=on;//开黄灯
light(amber,amber_tics);//等待
end
//定义交通灯开启时间的任务
task light;
output color;
input [31:0]tics;
begin
repeat(tics)
@(posedge clock);
color=off;
end
endtask
always
begin
#100 clock=0;
#100 clock=1;
end
endmodule
以上就是关于verilog 程序问题,初学者,请见谅,程序代码如下全部的内容,包括:verilog 程序问题,初学者,请见谅,程序代码如下、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)