求助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

回复
打赏帖 | |
---|---|
【S32K146】S32DS watchdog 配置使用被打赏20分 | |
【Zephyr】使用 IAR 调试 Zephyr 镜像被打赏20分 | |
【Zephyr】MCXN947 Zephyr 开发入门适配shell被打赏20分 | |
【我要开发板】6.联合MATLAB记录数据被打赏50分 | |
【瑞萨RA2E1开发板】:使用ADC功能实现位移传感器采集方案被打赏20分 | |
【nRF7002DK】基于sht30的温湿度计被打赏20分 | |
【nRF7002DK】日志打印被打赏20分 | |
【换取手持示波器】RGB屏幕移植ARM-2D库被打赏35分 | |
【分享开发笔记,赚取电动螺丝刀】分享一下如何解决瑞萨RA2E1使用printf编译报错问题被打赏27分 | |
rtthread硬件加密-5hash加密分析被打赏10分 |