【iCore4 雙核心板_FPGA】例程四:Signal Tapll 實驗——邏輯分析儀

XiaomaGee發表於2017-08-11

實驗現象:

三色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 <= 1'd0;
            cnt_led <= 25'd0;
        end
    else if(cnt_led == 25'd8000000)
        begin
            cnt_led <= 25'd0;
            led_clk <= ~led_clk;
        end
    else cnt_led <= cnt_led + 1'd1;

//--------------------led----------------------------------//            
reg [2:0]led;
reg [24:0]cnt_led;

always @(posedge led_clk or negedge rst_n)
    if (!rst_n)
        begin
            led <= 3'd1;
        end
    else
        begin
            if (led[2])
                begin
                    led <= 3'd1;
                end
            else 
                begin
                    led <= led << 1'd1;
                end
        end

assign {fpga_ledr,fpga_ledg,fpga_ledb} = ~led;

//--------------------endmodule--------------------------//    
endmodule

原始碼下載連結:

連結:http://pan.baidu.com/s/1pLyUgQJ 密碼:1qfu

iCore4連結:

相關文章