一个简单交通灯时序控制
时间:10-02
整理:3721RD
点击:
语法错在哪里!求大神
module traffic_lights;
reg clock,red,yellow,green;
parameter on=1,
off=0,
red_tics=350,
yellow_tics=30,
green_tics=200;
initial red=off;
initial yellow=off;
initial green=off;
always
begin
red=on;
light(red,red_tics);
yellow=on;
light(yellow,yellow_tics);
green=on;
light(green,green_tics);
end
task light(color,tics);
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
ERROR:HDLCompiler:719 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 38: Port declaration not allowed in light with formal port declaration list
ERROR:HDLCompiler:719 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 39: Port declaration not allowed in light with formal port declaration list
ERROR:HDLCompiler:24 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 31: light expects 4 arguments
ERROR:HDLCompiler:24 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 33: light expects 4 arguments
ERROR:HDLCompiler:24 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 35: light expects 4 arguments
ERROR:HDLCompiler:598 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 21: Module ignored due to previous errors.
module traffic_lights;
reg clock,red,yellow,green;
parameter on=1,
off=0,
red_tics=350,
yellow_tics=30,
green_tics=200;
initial red=off;
initial yellow=off;
initial green=off;
always
begin
red=on;
light(red,red_tics);
yellow=on;
light(yellow,yellow_tics);
green=on;
light(green,green_tics);
end
task light(color,tics);
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
ERROR:HDLCompiler:719 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 38: Port declaration not allowed in light with formal port declaration list
ERROR:HDLCompiler:719 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 39: Port declaration not allowed in light with formal port declaration list
ERROR:HDLCompiler:24 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 31: light expects 4 arguments
ERROR:HDLCompiler:24 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 33: light expects 4 arguments
ERROR:HDLCompiler:24 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 35: light expects 4 arguments
ERROR:HDLCompiler:598 - "D:/FPGA_EXP/traffic_lights/traffic_lights.v" Line 21: Module ignored due to previous errors.
在“task”语句中不能列出端口名称,即“task light(color,tics);”改为“task light;”。
