求助fpga编程问题

楼主试试下面的程序能不能实现你的功能。Pulse_In 是输入的脉冲,Pulse_Out是输出的100ns脉冲,rst全局复位,其余一些计数值根据你的需要修改。
基本思路是:对输入脉冲计数,分频为一个占空比为50%(或其他,只要高电平超过100ns即可)的脉冲,再用标准时钟对这个脉冲整形,是输入高电平保持100ns。
( 这个程序我临时写的,没做过仿真,如果有误,请告知 )
reg [10:0] InCnt;
parameter MAXCNT = 500;
reg InCnt_Out;
always@( posedge Pulse_In or nedgedge rst)
begin
if( ~rst )
begin
InCnt <= 0;
end
else
begin
if( InCnt < MAXCNT-250 )
begin
InCnt <= Cnt + 1;
end
else if( InCnt < MAXCNT )
begin
InCnt <= InCnt + 1;
InCnt_Out <= 0;
end
else
begin
InCnt <= 0;
InCnt_Out <= 1;
end
end
reg Pulse_Out;
reg [3:0] OutCnt;
always@( posedge CLK_100M or nededge rst )
begin
if( rst )
Pulse_Out <= 0;
OutCnt <= 0;
else
begin
if( (InCnt_Out==1) && (OutCnt==0) )
begin
OutCnt <= 1;
Pulse_Out <= 1;
end
else if( OutCnt < 11 )
begin
OutCnt <= OutCnt + 1;
Pulse_Out <= 1;
end if( ~InCnt_Out )
begin
OutCnt <= 0;
Pulse_Out <= 0;
end
else
begin
OutCnt <= 11;
Pulse_Out <= 0;
end
end
end
