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.

67 lines
1.9 KiB
Coq

7 months ago
module static_led(
input wire sys_clk ,
input wire sys_rst_n ,
output reg [7: 0] seg_led ,//
output reg [5: 0] sel_led //
);
parameter MAX = 28'd50_000_000;//1s
parameter NUM = 4'd10;//10
reg [27: 0] cnt_s;
reg [3: 0] cnt_10;
//cnt_s
always @(posedge sys_clk or negedge sys_rst_n) begin
if(!sys_rst_n)begin
cnt_s <= 28'd0;
end
else if(cnt_s == MAX - 1'd1)begin
cnt_s <= 28'd0;
end
else begin
cnt_s <= cnt_s + 1'd1;
end
end
//cnt_10
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
cnt_10 <= 4'd0;
end
//91s
else if((cnt_10 == NUM - 1'd1) && (cnt_s == MAX - 1'd1))begin
cnt_10 <= 4'd0;
end
//1s1
else if(cnt_s == MAX - 1'd1)begin
cnt_10 <= cnt_10 + 1'd1;
end
//沿
else begin
cnt_10 <= cnt_10;
end
end
//sel_led
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
sel_led <= 6'b111_111;//6
end
else begin
sel_led <= 6'b000_000;//6
end
end
//seg_led
always @(*)begin
case(cnt_10)
4'd0 : seg_led = 8'b1100_0000;
4'd1 : seg_led = 8'b1111_1001;
4'd2 : seg_led = 8'b1010_0100;
4'd3 : seg_led = 8'b1011_0000;
4'd4 : seg_led = 8'b1001_1001;
4'd5 : seg_led = 8'b1001_0010;
4'd6 : seg_led = 8'b1000_0010;
4'd7 : seg_led = 8'b1111_1000;
4'd8 : seg_led = 8'b1000_0000;
4'd9 : seg_led = 8'b1001_0000;
default : seg_led = 8'b1100_0000;
endcase
end
endmodule