实验现象:
三色led轮流闪烁,具体的逻辑分析仪使用教程请参考iCore3逻辑分析仪例程
核心代码:
module signal_ctrl(
input clk_25m,
input rst_n,
output fpga_ledr,
output fpga_ledg,
output fpga_ledb
);
//--------------------cnt_led-------------------------------//
reg led_clk; always @(posedge clk_25m or negedge rst_n)
if (!rst_n)
begin
led_clk <= 'd0;
cnt_led <= 'd0;
end
else if(cnt_led == 'd8000000)
begin
cnt_led <= 'd0;
led_clk <= ~led_clk;
end
else cnt_led <= cnt_led + 'd1; //--------------------led----------------------------------//
reg [:]led;
reg [:]cnt_led; always @(posedge led_clk or negedge rst_n)
if (!rst_n)
begin
led <= 'd1;
end
else
begin
if (led[])
begin
led <= 'd1;
end
else
begin
led <= led << 'd1;
end
end assign {fpga_ledr,fpga_ledg,fpga_ledb} = ~led; //--------------------endmodule--------------------------//
endmodule
源代码下载链接:
链接:http://pan.baidu.com/s/1pLyUgQJ 密码:1qfu
iCore4链接: