实现输入一个周期的高电平,会有一个5个周期的高电平信号产生
module kount5(clk,rst,inp,outp,tmp);
input clk,rst,inp;
output outp,tmp;
reg outp;
reg [3:0]cout;
wire tmp;
always @(posedge clk or negedge rst)
begin
if(!rst) cout<=4'h0;
else if(cout==5) cout<=4'h0;
else if(inp==1) cout<=4'h1;
else if(cout!=0) cout<=cout+1;
end
assign tmp=(cout!=0);
always @(posedge clk or negedge rst)
begin
if(!rst)
outp<=1'b0;
else
outp<=tmp;
end
endmodule