分别采用上升沿进行一个占空比为2/3的始终,在次用下降样设计同样的占空比,最后将两者进行相与,得到占空比为50%的三分频电路。

// Code your design here
`timescale 1ns/1ps
module div3_half(
input Sys_clk,
input Sys_reset,
output div3 ,
output clk1,
output clk2
);
reg clk1;//2/3 is high posedge
reg clk2;//2/3 is high negedge
//counter
reg [1:0]count;
always @ (posedge Sys_clk )
if(!Sys_reset)
count <= 2'b0;
else if(count ==2'd2)
count <= 2'b0;
else
count <= count +1'b1;
always @(posedge Sys_clk )
if(!Sys_reset)
begin
clk1 <=1'b1;
end
else if(count == 2'd1 | count == 2'd2)
clk1 <= ~clk1;
always @(negedge Sys_clk )
if(!Sys_reset)
begin
clk2 <=1'b1;
end
else if(count == 2'd2 | count ==2'd1)
clk2 <= ~clk2;
//------------------------------------------------
assign div3 =clk1 & clk2;
endmodule
这篇文章详细描述了一个使用Verilog语言编写的三分频电路设计,通过上升沿和下降沿触发,结合计数器和逻辑门操作,实现了占空比为50%的两个2/3占空比时钟信号的同步相与,最终输出一个稳定的三分频信号。

1893

被折叠的 条评论
为什么被折叠?



