|
verilog编写的程序有四段数码管分别显示1234,然后又显示5678,就这样循环下去?
module s4_7seg(clk,rst,
s0,s1,s2,s3,
d0,d1,d2,d3,d4,d5,d6,d7
);
input clk,rst ;
output s0,s1,s2,s3 ;
output d0,d1,d2,d3,d4,d5,d6,d7 ;
reg [2 :0 ] state ;
reg [2 :0 ] sn ;
reg [7 :0 ] data ;
reg [23:0 ] cnt ;
wire s0,s1,s2,s3 ;
wire d0,d1,d2,d3,d4,d5,d6,d7 ;
assign {s3,s2,s1,s0} = sn ;
assign {d7,d6,d5,d4,d3,d2,d1,d0} = data ;
always @ ( posedge clk )
if( !rst )
cnt<=16'b0;
else
cnt<=cnt+3'b1;
wire clk_slow = cnt[24] ;
always @ ( posedge clk_slow or negedge rst )
if( !rst )
state<=3'b000;
else
state<=state+3'b001;
always @ ( posedge clk_slow or negedge rst )
if( !rst )
begin
sn<=4'b0;
data<=8'b0;
end
else
case(state)
3'b000:
begin
sn<=4'b0001;
data<=8'b0110_0000;
end
3'b001:
begin
sn<=4'b0010;
data<=8'b1101_1010;
end
3'b010:
begin
sn<=4'b0100;
data<=8'b1111_0010;
end
3'b011:
begin
sn<=4'b1000;
data<=8'b0110_0110;
end
3'b100:
begin
sn<=4'b0001;
data<=8'b1011_0110;
end
3'b101:
begin
sn<=4'b0010;
data<=8'b1011_1110;
end
3'b110:
begin
sn<=4'b0100;
data<=8'b1110_0000;
end
3'b111:
begin
sn<=4'b1000;
data<=8'b1111_1110;
end
endcase
endmodule
这是我自己编写的一段程序,但只有前三个数码管显示123,567,第四个数码管不显示,按照程序应该显示1234,5678的,请哪个大神帮帮忙看看是哪出了问题? |
|