zoukankan      html  css  js  c++  java
  • FPGA之verilog静态数码管小程序

    话不多说直接上代码:

    module shumaguan0_9(
    clk,
    rst_n,
    conlig,    //位选信号
    dataout   //数码管控制信号,由低到高依次为dp,a,b,c,d,e,f,g
    );

    input clk;
    input rst_n;
    output[3:0] conlig;
    output[7:0] dataout;

    reg[3:0] conlig;
    reg[7:0] dataout;
    reg[25:0] cnt;

    always@(posedge clk or negedge rst_n)begin
    if(rst_n == 0)begin
    cnt <= 0;
    end
    else if(cnt == 49_999_999)begin
    cnt <= 0;
    end
    else begin
    cnt <= cnt+1;
    end
    end

    always@(posedge clk or negedge rst_n)begin
    if(rst_n == 0)begin
    conlig <= 4'b1110;
    end
    else begin
    conlig <= conlig;
    end
    end

    always@(posedge clk or negedge rst_n)begin
    if(rst_n == 0)begin
    dataout <= 8'b1000_0000;
    end
    else if(cnt == 49_999_999)begin
    if(dataout == 8'b1000_0000)begin
    dataout <= 8'b1111_0011;
    end
    else if(dataout == 8'b1111_0011)begin
    dataout <= 8'b0100_1001;
    end
    else if(dataout == 8'b0100_1001)begin
    dataout <= 8'b0110_0001;
    end
    else if(dataout == 8'b0110_0001)begin
    dataout <= 8'b0011_0011;
    end
    else if(dataout == 8'b0011_0011)begin
    dataout <= 8'b0010_0101;
    end
    else if(dataout == 8'b0010_0101)begin
    dataout <= 8'b0000_0101;
    end
    else if(dataout == 8'b0000_0101)begin
    dataout <= 8'b1111_0001;
    end
    else if(dataout == 8'b1111_0001)begin
    dataout <= 8'b0000_0001;
    end
    else if(dataout == 8'b0000_0001)begin
    dataout <= 8'b0010_0001;
    end
    else if(dataout == 8'b0010_0001)begin
    dataout <= 8'b1000_0000;
    end
    else begin
    dataout <= dataout;
    end
    end
    end
    endmodule

  • 相关阅读:
    Android 8.0 adb shell dumpsys activity activities | findstr mFocusedActivity 获取当前的 activity 显示空的
    spring-in-action_day01
    spring-in-action_day02
    spring-in-action-day04-配置属性 @ConfigurationProperties
    springmvc接收参数
    spring中Utils工具类注入问题
    Eclipse Push出现rejected
    Eclpis-cannot open git-receive-pack
    IO
    LinkedHashmap简要说明
  • 原文地址:https://www.cnblogs.com/curatan/p/7419191.html
Copyright © 2011-2022 走看看