题解 | #占空比50%的奇数分频#
占空比50%的奇数分频
https://www.nowcoder.com/practice/ccfba5e5785f4b3f9d7ac19ab13d6b31
`timescale 1ns/1ns module odo_div_or ( input wire rst , input wire clk_in, output wire clk_out7 ); //*************code***********// reg [2:0] cnt; wire tff1_en; wire tff2_en; reg div1; reg div2; assign tff1_en = (cnt==6)?1'b1:1'b0;//N拉高上升沿触发电路 assign tff2_en = (cnt==3)?1'b1:1'b0;//(N-1)/2拉高下降沿触发器的输入 assign clk_out7 =(!rst)?1'b0:(div1^div2); always@(posedge clk_in or negedge rst)//计数器,用于控制两个T触发器产生相位相差90度的时钟 begin if(!rst) cnt<=0; else if(cnt==6) cnt<=0; else cnt <= cnt + 1; end always @(posedge clk_in or negedge rst)//下降沿T触发器,产生正交时钟1 begin if(!rst) div1<=0; else if(tff1_en) div1<=~div1; end always @(negedge clk_in or negedge rst)//下降沿T触发器,产生正交时钟2 begin if(!rst) div2<=0; else if(tff2_en) div2<=~div2; end //*************code***********// endmodule 要产生奇数分频,占空比是50%,核心点是使用上下沿触发T触发器产生两路相位差90度的信号,进行异或即可#占空比505奇数分频verilog#