Counter
// 8-bit counter with clear and count enable controls
module count8 (CLK, clr, cntEn, Dout);
input CLK;
input clr; // clear counter
input cntEn; // enable count
output [7:0] Dout; // counter value
reg [7:0] Dout;
always @(posedge CLK)
if (clr) Dout <= 0;
else if (cntEn) Dout <= Dout + 1;
endmodule
Previous slide
Back to first slide
View graphic version