题解 | #占空比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
);
reg [2:0] cnt_p;
reg [2:0] cnt_n;
always@(posedge clk_in or negedge rst)begin
if(!rst)
cnt_p <= 1'b0;
else if(cnt_p == 3'b110)
cnt_p <= 1'b0;
else
cnt_p <= cnt_p + 1'b1;
end
always@(negedge clk_in or negedge rst)begin
if(!rst)
cnt_n <= 1'b0;
else if(cnt_n == 3'b110)
cnt_n <= 1'b0;
else
cnt_n <= cnt_n + 1'b1;
end
assign clk_out7 = (((cnt_n > 2'b11) || (cnt_n==1'b0))&&(cnt_p >= 2'b11))?1'b1:1'b0;
endmodule
查看9道真题和解析