分享

verilog 实现的动态数码管显示

 独孤琅嬛 2014-04-10



module seg71(clk,rst,dataout,en);

input clk,rst;
output[7:0] dataout;
output[7:0] en;//COM使能输出
reg[7:0] dataout;//各段数据输出
reg[7:0] en;

reg[15:0] cnt_scan;//扫描频率计数器
reg[4:0] dataout_buf;

always@(posedge clk or negedge  rst)
begin
    if(!rst) begin
        cnt_scan<=0;
       
     end
    else begin
        cnt_scan<=cnt_scan+1;
        end
end

always @(cnt_scan)
begin
  case(cnt_scan[15:13])
      3'b000 :
          en = 8'b1111_1110;
      3'b001 :
          en = 8'b1111_1101;
      3'b010 :
          en = 8'b1111_1011;
      3'b011 :
          en = 8'b1111_0111;
      3'b100 :
          en = 8'b1110_1111;
      3'b101 :
          en = 8'b1101_1111;
      3'b110 :
          en = 8'b1011_1111;
      3'b111 :
          en = 8'b0111_1111;
      default :
          en = 8'b1111_1110;
    endcase
end

always@(en) //对应COM信号给出各段数据
begin
    case(en)
        8'b1111_1110:
            dataout_buf=0;
        8'b1111_1101:
            dataout_buf=1;
        8'b1111_1011:
            dataout_buf=2;
        8'b1111_0111:
            dataout_buf=3;   
        8'b1110_1111:
            dataout_buf=4;
        8'b1101_1111:
            dataout_buf=5;
        8'b1011_1111:
            dataout_buf=6;
        8'b0111_1111:
            dataout_buf=7;
        default:
            dataout_buf=8;
     endcase
end

always@(dataout_buf)
begin
    case(dataout_buf)
        4'b0000:
            dataout=8'b0000_0011;
        4'b0001:
            dataout=8'b1001_1111;
        4'b0010:
            dataout=8'b0010_0101;
        4'b0011:
            dataout=8'b0000_1101;
        4'b0100:
            dataout=8'b1001_1001;
        4'b0101:
            dataout=8'b0100_1001;
        4'b0110:
            dataout=8'b0100_0001;
        4'b0111:
            dataout=8'b0001_1111;
        4'b1000:
            dataout=8'b0000_0001;
        4'b1001:
            dataout=8'b0001_1001;
        4'b1010:
            dataout=8'b0001_0001;
        4'b1011:
            dataout=8'b1100_0001;
        4'b1100:
            dataout=8'b0110_0011;
        4'b1101:
            dataout=8'b1000_0101;
        4'b1110:
            dataout=8'b0110_0001;
        4'b1111:
            dataout=8'b0111_0001;
     endcase
end

endmodule

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多