|
`timescale 1ns/1ns
module fenpin(
rst_n,
clkin,
clkout
);
input rst_n;
input clkin;
output clkout;
reg clkout;
reg clk0,clk1,clk2;
reg [7:0] c0,c1,c2;
reg [3:0] c3;
always @(posedge clkin or negedge rst_n)
begin
if (rst_n == 1'b0)
begin
clk0 <= 1'b0;
c0<=0;
end
else if(c0<8'd200)
c0<=c0+1;
else
begin
clk0<=~clk0;
c0<=0;
end
end
always @(posedge clk0 or negedge rst_n)
begin
if (rst_n == 1'b0)
begin
c1<=0;
clk1<= 1'b0;
end
else if(c1<8'd100)
c1<=c1+1;
else
begin
clk1<=~clk1;
c1<=0;
end
end
always @(posedge clk1 or negedge rst_n)
begin
if (rst_n == 1'b0)
begin
c2<=0;
clk2<=1'b0;
end
else if(c2<8'd100)
c2<=c2+1;
else
begin
clk2<=~clk2;
c2<=0;
end
end
always @(posedge clk2 or negedge rst_n)
begin
if (rst_n == 1'b0)
begin
c3<=0;
clkout<=1'b0;
end
else if(c3<4'd10)
c3<=c3+1;
else
begin
clkout<=~clkout;
c3<=0;
end
end
endmodule |
|