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

回复
打赏帖 | |
---|---|
分享汽车防盗系统的组成与分类(一)被打赏5分 | |
VOFA+波形显示+JYD-31蓝牙发送和解析不定长数据被打赏10分 | |
宏定义和const关键字定义被打赏5分 | |
换取逻辑分析仪】STM32G4从入门到大师之五:ADC中断方式单路采集电压被打赏16分 | |
【换取逻辑分析仪】STM32G4从入门到大师之四:ADC查询方式单路采集电压被打赏14分 | |
【分享开发笔记,赚取电动螺丝刀】几个单片机I2S外设的BLCK时钟对比被打赏20分 | |
【功率监测与控制系统DIY活动成果贴】DIY功率计与LabVIEW数据采集被打赏100分 | |
【分享开发笔记,赚取电动螺丝刀】使用ESP32S3调试I2S音频模块MAX98357被打赏22分 | |
【Freertos】任务管理被打赏10分 | |
分享博世的两种不同的喷射系统模式被打赏5分 |