Skip to content

Instantly share code, notes, and snippets.

@jz5
Created December 3, 2013 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jz5/7763255 to your computer and use it in GitHub Desktop.
Save jz5/7763255 to your computer and use it in GitHub Desktop.
counter 1
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