vivado 60進製計數器並用數碼管顯示

2021-10-10 10:36:59 字數 3319 閱讀 7939

module second

(input wire clk,

output reg sec)

;reg [27:

0]q1;

always @(posedge clk)

begin

if(q1==

50000000

) begin

q1<=0;

sec<=

~sec;

endelse

q1<=q1+1;

endendmodule

module sixty

(input wire clk,

output reg [3:

0] cnt60_l,

output reg [3:

0] cnt60_h,

output reg carry

); initial begin

cnt60_l=8;

cnt60_h=5;

endalways @(posedge clk)

begin

carry<=0;

cnt60_l<=cnt60_l+1;

if(cnt60_l==9)

begin

cnt60_l<=0;

cnt60_h<=cnt60_h+1;

end

if(cnt60_h==

5&& cnt60_l==9)

begin

cnt60_l<=0;

cnt60_h<=0;

carry<=1;

endend

endmodule

module top

( input wire clk,

output wire [3:

0] second_l,

output wire [3:

0] second_h

); wire jinwei;

second u0(.

clk(clk),.

sec(jinwei));

sixty u1(.

clk(jinwei),.

cnt60_l

(second_l),.

cnt60_h

(second_h));

endmodule

module x7seg_4bit

(input clk,

input rst_n,

//input [7:0] x, //等待顯示的bcd碼

output reg [6:

0] a_to_g,

//段訊號

output reg [1:

0] an //位選訊號);

wire [3:

0]l;

wire [3:

0]h;

top zhuogege(.

clk(clk),.

second_l

(l),

.second_h

(h))

;wire [7:

0]x=

;//x=;

//時鐘分頻 計數器

reg [19:

0] clkdiv;

always @(posedge clk or negedge rst_n)

begin

if(!rst_n)

clkdiv<=

20'd0;

else

clkdiv<=clkdiv+1;

end/*利用計數器自動溢位時間,即就是clkdiv從0~11111111111111111111迴圈計數,

則clk[19]會在0~1之間以5.24ms為時間間隔變化 2^19=524288

(即後19位全0到全1的計數時間)

*///bitcnt: 位掃瞄訊號 0~1迴圈變化 掃瞄週期 5.24ms 控制總掃瞄時間不超過10ms,單個數碼管顯示時間約為5ms

wire bitcnt;

assign bitcnt=clkdiv[19]

;//an:位選訊號產生,高有效

always @(posedge clk or negedge rst_n)

begin if(

!rst_n)

an=2'd0;

else

case

(bitcnt)

1'd0:an=4'b01;

1'd1:an=4'b10;

endcase

end//digit 當前帶顯示的數字

reg [3:

0]digit;

always @(posedge clk or negedge rst_n)

beginif(

!rst_n)

digit=

4'd0;

else

case

(bitcnt)

2'd0:digit=x[3:

0];2'd1:digit=x[7:

4];default

:digit=

4'd0;

endcase

end//a_to_g: 段碼訊號,共陰極數碼管,段碼高有效。 7段解碼表

always @(posedge clk or negedge rst_n)

beginif(

!rst_n)

a_to_g=

7'b1111111;

else

case

(digit)

0:a_to_g=

7'b1111110;

//段碼位序由高到低為a-g

1:a_to_g=

7'b0110000;

2:a_to_g=

7'b1101101;

3:a_to_g=

7'b1111001;

4:a_to_g=

7'b0110011;

5:a_to_g=

7'b1011011;

6:a_to_g=

7'b1011111;

7:a_to_g=

7'b1110000;

8:a_to_g=

7'b1111111;

9:a_to_g=

7'b1111011;

default

:a_to_g=

7'b1111110;

endcase

endendmodule

如果**有用,請盡情的點讚和打賞即可

白嫖雖然爽,但是違背公序良俗,不可取哦,親(づ ̄3 ̄)づ╭❤~

可輸入初始值得60進製計數器

timescale 1ns 1ps company engineer create date 09 04 55 08 13 2015 design name module name count60 project name target devices tool versions descripti...

設計20進製計數器

要求 1。用161計數器晶元,設計乙個m 20的計數器,可以用多片 上電後,對clk訊號,從0順序計數到19,然後迴繞到0 2.當計數值為19的clk週期,溢位訊號ov輸出乙個高電平,其他週期ov訊號輸出0 3.用波形 觀察電路結果 步驟 1.建立工程 20 step counter 並建立bwf空...

24進製計數器的設計

本關任務 利用兩個在第3關設計的十進位制計數器,設計乙個24進製計數器,要求具有同步置數 非同步清零功能。計數是一種最簡單的基本運算。計數器就是實現這種運算的邏輯電路,計數器在數字系統中主要是對脈衝的個數進行計數,以實現測量 計數和控制的功能,同時兼有分頻功能。計數器在數字系統中應用廣泛,如在電子計...