You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.3 KiB
Coq

7 months ago
//使
//
module divider_six0(
input wire sys_clk,
input wire sys_rst_n,
output reg led
);
parameter MAX = 23'd8_333_333;
reg [1: 0] cnt;
reg clk_out;
reg [22: 0] cnt_out;
always @(posedge sys_clk or negedge sys_rst_n) begin
if(!sys_rst_n)begin
cnt <= 2'd0;
end
else if(cnt == 2'd2)begin
cnt <= 2'd0;
end
else begin
cnt <= cnt + 1'd1;
end
end
//clk_out:6 50%
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
clk_out <= 1'b0;
end
else if(cnt == 2'd2)begin
clk_out <= ~clk_out;
end
else begin
clk_out <= clk_out;
end
end
always @(posedge clk_out or negedge sys_rst_n)begin
if(!sys_rst_n)begin
cnt_out <= 23'd0;
end
else if(cnt_out == MAX - 1'd1)begin
cnt_out <= 23'd0;
end
else begin
cnt_out <= cnt_out + 1'd1;
end
end
//使led120ns10^9/120 = 8,333,333
always @(posedge clk_out or negedge sys_rst_n)begin
if(!sys_rst_n)begin
led <= led;
end
else if(cnt_out == MAX - 1'd1)begin
led <= ~led;
end
else begin
led <= led;
end
end
endmodule