回覆列表
  • 1 # 使用者7906159811237

    moduleled8_display(clk,rst,comsel,en,play);

    inputclk;

    inputrst;

    inputcomsel;

    output[7:0]en;

    output[7:0]play;

    reg[30:0]count;

    reg[7:0]en;

    reg[7:0]play;

    always@(posedgeclkornegedgerst)

    begin

    if(!rst)

    begin

    if(comsel)//共陽譯碼

    begin

    count<=0;

    en<=1;

    play<=8"b00111111;

    end

    else

    begin

    count<=0;

    en<=0;

    play<=8"b11000000;

    end

    end

    else

    begin

    count<=count+1;

    case(count[30:28])

    3"b000:

    begin

    if(consel)

    begin

    en<=8"b00000001;

    play<=8"b00111111;

    end

    else

    begin

    en<=8"b11111110;

    play<=8"b11000000;

    end

    end

    3"b001:

    begin

    if(comsel)

    begin

    en<=8"b00000010;

    play<=8"b00000110;

    end

    else

    begin

    en<=8"b11111101;

    play<=8"b11111001;

    end

    end

    3"b010:

    begin

    if(consel)

    begin

    en<=8"b00000100;

    play<=8"b01011011;

    end

    else

    begin

    en<=8"b11111011;

    play<=8"b10100100;

    end

    end

    4"b011:

    begin

    if(consel)

    begin

    en<=8"b00001000;

    play<=8"b01001111;

    end

    else

    begin

    en<=8"b11110111;

    play<=8"b10110000;

    end

    end

    endcase

    end

    end

    endmodule

    這個是我剛剛寫的4位7段數碼管流水燈顯示1---4的程式,希望對你有用,按題目要求,你只需把程式碼中時鐘分頻器暫存器變數count刪去、outputreg[7:0]en;改成“outputregen,4位動態case顯示改成單數碼管靜態顯示就行了……

  • 中秋節和大豐收的關聯?
  • “自娛自樂”,用英語怎麼說?