|
module jishu(clk,rst,out_wei,out_duan);
input clk;
input rst;
output[1:0] out_wei;
output[6:0] out_duan;
reg[1:0] out_wei;
reg[6:0] out_duan;
reg[24:0] cnt;
reg[17:0] count;
reg[2:0] count1;
reg[6:0] num=0;
reg[6:0] num_ge=7'h3f;
reg[6:0] num_shi=7'h3f;
reg clk_out;
reg out;
initial begin
reg[3:0]ge=num%10;
reg[3:0]shi=num/10;
end
always @(posedge clk)
begin
if(cnt==25'd24999999)
begin
clk_out<=~clk_out;
cnt<=25'd0;
num<=num+1'd1;
end
else
cnt<=cnt+1'd1;
end
always @(posedge clk_out or negedge rst)
begin
if(!rst) num<=0;
else
begin
num<=num+1'd1;
if(num==99)
num<=0;
end
end
always @(posedge clk)
begin
if(count==2499)
begin
count<=18'd0;
out<=~out;
end
else
count<=count+1'd1;
end
always @(posedge out)
begin
count1<=count1+1'd1;
case(count1)
1:begin
out_wei=2'b10;
out_duan=num_ge;
end
5:begin
out_wei=2'b01;
out_duan=num_shi;
end
6:count1<=0;
endcase
end
always @(ge)
begin
case(ge)
0:num_ge=7'h3f;
1:num_ge=7'h06;
2:num_ge=7'h5b;
3:num_ge=7'h4f;
4:num_ge=7'h66;
5:num_ge=7'h6d;
6:num_ge=7'h7d;
7:num_ge=7'h07;
8:num_ge=7'h7f;
9:num_ge=7'h6f;
default:num_ge=7'h3f;
endcase
case(shi)
0:num_shi=7'h3f;
1:num_shi=7'h06;
2:num_shi=7'h5b;
3:num_shi=7'h4f;
4:num_shi=7'h66;
5:num_shi=7'h6d;
6:num_shi=7'h7d;
7:num_shi=7'h07;
8:num_shi=7'h7f;
9:num_shi=7'h6f;
default:num_shi=7'h3f;
endcase
end
endmodule
我现在刚开始接触这个,这个数码管显示我纠结了很久,一直都想不通,我要实现两位数码管显示0-99.但是实际效果是,数码管上一直显示的是两个0,一直都不变。希望各位不吝赐教,小弟万分感谢!!! |
|