huangtorres 发表于 2012-9-4 09:58:09

数码管间隔一秒由0—99显示(verilog)

module jishu(clk,rst,out_wei,out_duan);
input clk;
input rst;
output out_wei;
output out_duan;
reg out_wei;
reg out_duan;
reg cnt;
reg count;
reg count1;
reg num=0;
reg num_ge=7'h3f;
reg num_shi=7'h3f;
reg clk_out;
reg out;

initial begin
regge=num%10;
regshi=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,一直都不变。希望各位不吝赐教,小弟万分感谢!!!
页: [1]
查看完整版本: 数码管间隔一秒由0—99显示(verilog)