go-board-code/count_and_toggle.v

23 lines
454 B
Coq
Raw Normal View History

2024-07-06 18:51:29 +00:00
module Count_And_Toggle (
input i_Clk,
input i_Enable,
output reg o_Toggle
);
parameter COUNT_LIMIT = 10;
reg [$clog2(COUNT_LIMIT - 1):0] r_Counter;
always @(posedge i_Clk) begin
if (i_Enable == 1) begin
if (r_Counter == COUNT_LIMIT - 1) begin
o_Toggle <= !o_Toggle;
r_Counter <= 0;
end else begin
r_Counter <= r_Counter + 1;
end
end else begin
o_Toggle <= 0;
end
end
endmodule