简体   繁体   English

如何在Verilog中更改时钟?

[英]How to change clock in Verilog?

module task_A(input [15:0]sw, input clk,output reg [3:0] an= 4'b1111,output reg[7:0] seg);
reg [2:0] num = 3'd0;
wire Z,Z1,Z2;
clk_1_47hz(clk,Z1);
clk_762hz(clk,Z2);
reg count=0;
assign Z= (count<5)?(Z1):(Z2);
always @ (posedge Z)
begin
num <= (sw[15:0]==16'b1111111111111111)?((num==5 | num==0)?(3'd1):(num+1)):(0);
count <=count+1;
case(num)
    3'd0 : begin seg <= 8'b11111111 ; an <= 4'b1111; end
    3'd1 : begin seg <= 8'b10000111 ; an <= 4'b0111; end //t
    3'd2 : begin seg <= 8'b10001000 ; an <= 4'b1011; end //a
    3'd3 : begin seg <= 8'b11001111 ; an <= 4'b1101; end //l
    3'd4 : begin seg <= 8'b11111001 ; an <= 4'b1101; end //l
    3'd5 : begin seg <= 8'b10010001 ; an <= 4'b1110; end //y
    
    endcase
    end
endmodule

I wish to change the clock after the 7 segment display has displayed 'tally' once.我希望在 7 段显示器显示一次“计数”后更改时钟。 So I use count to check.所以我用count来检查。 But the clock does not change at all.但时钟根本没有改变。 May I know how to correct it?我可以知道如何纠正它吗?

count is declared as a 1-bit signal, which is always smaller than 5. count被声明为 1 位信号,它总是小于 5。

reg count=0;

To accomplish your goal, declare it as a 3-bit signal or more.为了实现您的目标,请将其声明为 3 位或更多位信号。
And you may also need to set a limit for count , and stop it, if you want to switch to Z2 clock forever after 'tally' is displayed once.并且您可能还需要为count设置一个限制,并停止它,如果您想在 'tally' 显示一次后永远切换到Z2时钟。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM