集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 1101|回复: 1

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

[复制链接]
huangtorres 发表于 2012-9-4 09:58:09 | 显示全部楼层 |阅读模式
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,一直都不变。希望各位不吝赐教,小弟万分感谢!!!
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-6-26 08:05 , Processed in 0.060132 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表