新手上路
- 积分
- 39
- 金钱
- 39
- 注册时间
- 2019-12-20
- 在线时间
- 8 小时
|
部分代码如下(数码管静态显示):
module seg_led_static(
input clk,
input rst_n,
input add_flag,
output reg [5:0]sel_led,
output reg [7:0]seg_led
);
reg [3:0]state_number;
always@(posedge clk or negedge rst_n)begin
if(!rst_n)
sel_led<=6'b111111;
else
sel_led<=6'b000000;
end
always@(posedge clk or negedge rst_n)begin
if(!rst_n)
state_number<=10;
else if(add_flag)begin
if(state_number<16)
state_number<=state_number+1'b1;
else
state_number<=1'b0;
end
end
always@(posedge clk or negedge rst_n)begin
if(!rst_n)
seg_led<=8'b11111111;
else begin
case(state_number)
4'd0:seg_led<=8'b11000000;
4'd1:seg_led<=8'b11111001;
4'd2:seg_led<=8'b10100100;
4'd3:seg_led<=8'b10110000;
4'd4:seg_led<=8'b10011001;
4'd5:seg_led<=8'b10010010;
4'd6:seg_led<=8'b10000010;
4'd7:seg_led<=8'b11111000;
4'd8:seg_led<=8'b10000000;
4'd9:seg_led<=8'b10010000;
4'd10:seg_led<=8'b10001000;
4'd11:seg_led<=8'b10000011;
4'd12:seg_led<=8'b11000110;
4'd13:seg_led<=8'b10100001;
4'd14:seg_led<=8'b10000110;
4'd15:seg_led<=8'b10001110;
default:seg_led<=8'b011111111;
endcase
end
end
endmodule
上电时就从10状态开始显示,即使不按复位键也是从10状态开始显示,难道刚上电时不应该从0状态开始显示吗(reg上电默认为0),请各位高手帮忙解答,非常感谢。
|
|