//`timescale 1 ps/ 1 psmodule traffic_lights(clk,red,amber,green);input clk;output red;output amber;output green;reg red;reg amber;reg green;////dedine the parameterparameter on=1,off=0,red_tics=350,amber_tics=30,green_tics=200;//initialinitial red=off;initial arber=off;initial green=off;///the main progressalways beginred=on; //打开light(red,red_tics); //等待green=on;light(green,green_tics);amber=on;light(amber,amber_tics);end //类似C语言的函数调用////define tasktask light(color,tics); //定义交通灯的开启时间taskoutput color; //输出 控制信号input [31:0] tics; //输入 延时时钟beginrepeat (tics) @(posedge clock);color=off;endendtask//// produce the clock// always @ (posedge clk)// beginendmodule
- 2 回答
- 0 关注
- 649 浏览
添加回答
举报
0/150
提交
取消