FPGA模N计数器的实现
module ModuloN_Cntr(Clock, Clear, Q, QBAR); parameter NBITS = 2, UPTO = 3;//计数器位数以及模数 input Clock, Clear; output [NBITS-1:0]Q, QBAR; reg [NBITS-1:0]Counter; always @(posedge Clock) if(Clear) Counter <= 0; else Counter <= (Counter + 1) % UPTO; assign Q = Counter; assign QBAR = ~ Counter; endmodule
//计数器位数:NBITS
//模数:UPTO
模N指的是计数器能表示的最多状态个数。
posted on 2018-08-10 15:20 super_star123 阅读(1326) 评论(0) 编辑 收藏 举报