標(biāo)題: 簡(jiǎn)單的FPGA計(jì)時(shí)器例程 [打印本頁]

作者: 鬼木士    時(shí)間: 2018-10-21 10:51
標(biāo)題: 簡(jiǎn)單的FPGA計(jì)時(shí)器例程

關(guān)鍵代碼
module Accumulator
(
        CLK,RSTn,Result
        
);

        input                                 CLK;
        input                                 RSTn;
        output reg[7:0]        Result;
                                       
        
        always@(posedge CLK or negedge RSTn)
                begin
                        if(!RSTn)
                                begin
//                                        Result[7:4]<=0;
//                                        Result[3:0]<=0;
                                end
                        else if(Result[3:0]==4'd9)
                                begin
                                        Result[3:0]<=0;
                                        Result[7:4]<=Result[7:4]+1'b1;
                                end
                        else
                                Result[3:0]<=Result[3:0]+1'b1;
                end
               
               
endmodule


全部代碼見附件
Counter.zip (7.49 MB, 下載次數(shù): 23)





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1