Verilog分频器通解
y分频器,分频之后 ,m个低电平
2 Size ≥ y \geq y ≥y
module divfreu(clk,rst,out);
input clk,rst;
output out;
reg [Size-1:0]cnt;//
reg out;
always @(posedge clk )
begin
if (!rst)
cnt <= Size'b0;
else if (cnt==Size'b(y-1))
cnt <= Size'b0;
else
cnt <= cnt +1'b1;
end
always@(posedge clk )
begin
if (!rst)out <=1'b0;
else if(cnt < Size'bm)
out <=1'b0;
else
out <=1'b1;
end
endmodule