Created
December 29, 2021 15:15
-
-
Save lp6m/53d5578421f185793a9795c285f448b1 to your computer and use it in GitHub Desktop.
Lチカモジュール
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
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