思路:
用clk上升沿分频出“3高4低”的7分频tmp
再用clk下降沿分频出“3高4低”的7分频tmp1
将tmp与tmp1相或即可得到占空比50%的7分频oclk
Verilog代码:
module oddfreq(
input clk,
input rst,
output oclk
);
reg [3:0] count;
reg tmp;
always @(posedge clk or negedge rst) begin
if(rst) begin
count <= 4'b0000;
tmp <= 1'b0;
end
else begin
if(count