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.

61 lines
1.3 KiB
Coq

7 months ago
//使
module divider_six1(
input wire sys_clk,
input wire sys_rst_n,
output reg led
);
parameter MAX = 23'd8_333_333;
reg [2: 0] cnt;
reg flag;
reg [22: 0] cnt_flag;
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
cnt <= 3'd0;
end
else if(cnt == 3'd5)begin
cnt <= 3'd0;
end
else begin
cnt <= cnt + 1'd1;
end
end
//使flag0~5
always @(posedge sys_clk or negedge sys_rst_n) begin
if(!sys_rst_n)begin
flag <= 1'b0;
end
else if(cnt == 3'd5)begin
flag <= 1'b1;
end
else begin
flag <= 1'b0;
end
end
//1
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
cnt_flag <= 23'd0;
end
else if(cnt_flag == MAX - 1'd1)begin
cnt_flag <= 23'd0;
end
else if(flag)begin
cnt_flag <= cnt_flag + 1'd1;
end
else begin
cnt_flag <= cnt_flag;
end
end
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
led <= 1'b0;
end
else if(cnt_flag == MAX - 1'd1)begin
led <= ~led;
end
else begin
led <= led;
end
end
endmodule