Skip to content

Instantly share code, notes, and snippets.

@lp6m
Created December 29, 2021 15:15
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 lp6m/53d5578421f185793a9795c285f448b1 to your computer and use it in GitHub Desktop.
Save lp6m/53d5578421f185793a9795c285f448b1 to your computer and use it in GitHub Desktop.
Lチカモジュール
module counter(
input RESET, CLK,
output [1:0] LED
);
reg [1:0] COUNT;
reg [31:0] inner_count;
always @(posedge CLK or negedge RESET) begin
if (RESET == 1'b0) begin
COUNT <= 1;
inner_count <= 0;
end else begin
if (inner_count >= 32'd200000000) begin
inner_count <= 32'd100000000;
COUNT <= ~COUNT;
end else
inner_count <= inner_count + 1;
end
end
wire reset_sareta = (inner_count < 32'd100000000);
assign LED[1] = reset_sareta ? 1 : COUNT[1];
assign LED[0] = reset_sareta ? 1 : COUNT[0];
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment