//`timescale 1 ps/ 1 ps
module traffic_lights(
clk,
red,
amber,
green
);
input clk;
output red;
output amber;
output green;
reg red;
reg amber;
reg green;
////dedine the parameter
parameter on=1,
off=0,
red_tics=350,
amber_tics=30,
green_tics=200;
//initial
initial red=off;
initial arber=off;
initial green=off;
///the main progress
always begin
red=on; //打开
light(red,red_tics); //等待
green=on;
light(green,green_tics);
amber=on;
light(amber,amber_tics);
end //类似C语言的函数调用
////define task
task light(color,tics); //定义交通灯的开启时间task
output color; //输出 控制信号
input [31:0] tics; //输入 延时时钟
begin
repeat (tics) @(posedge clock);
color=off;
end
endtask
//// produce the clock
// always @ (posedge clk)
// begin
endmodule
繁花如伊
一只名叫tom的猫