核心程式碼:
//--------------------Module_Signal_TapII-------------------// module Signal_TapII( input CLK_12M, output FPGA_LEDR, output FPGA_LEDG, output FPGA_LEDB ); //--------------------------rst_n--------------------------// reg [9:0]cnt_rst = 4'd0; reg rst_n = 1'd0; always @(posedge CLK_12M) begin if (cnt_rst == 4'd10) begin rst_n <= 1'd1; cnt_rst <= 4'd10; end else cnt_rst <= cnt_rst + 1'd1; end //--------------------------led_clk--------------------------// reg led_clk; reg [24:0]cnt_led; always @(posedge CLK_12M 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; 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/1mhRklZE 密碼:rbmk