Created
December 3, 2013 03:03
-
-
Save jz5/7763255 to your computer and use it in GitHub Desktop.
counter 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reg [15:0] count; | |
// max_count は 入力値など | |
always @(posedge clk or negedge rst_n) begin | |
if (~rst_n) begin | |
count <= 0; // リセット | |
end | |
else if (count == max_count) begin | |
count <= 0; // カウンタ最大値の場合、0 にリセット | |
end | |
else begin | |
count <= count + 1; | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment