VHDL如何检测数据发生变化,类似rising_edge 这种

2025-03-13 15:07:09
推荐回答(3个)
回答1:

用==等号,先将当前的数值保存在寄存器中,然后在比较该寄存器的数值和输入的数值是否相等,来判断数据是否在变化
例如,输入信号为inputA,
将inputA保存为regA,然后判断if(inputA==regA) then c<=1;elsec<=0;endif;

若inputA发生了变化,则判断结果c为0,否则c为1

回答2:

用 clock'event

回答3:

我也遇到了这个问题,我是这么解决的。
在PROCESS结束前,将这个信号(data_out通过输入端口,立即改变)赋值给另一个信号(data_out_dac自定义),然后在process开始的时候进行比较,因为process里面是顺序结构的,所以仿真通过了,希望对大家有帮助。
process(sclk_out_tmp,resetin)
variable cnt:integer range 0 to 32:=0;
begin
if resetin='0' then
sync_out_tmp<='1';
da_data_out<='0';
cnt:=0;
elsif data_out/=data_out_dac then --进行比较
cnt:=1;
sync_out_tmp<='1';
elsif rising_edge(sclk_out_tmp) then
cnt:=cnt+1;
if cnt=1 then
sync_out_tmp<='1';
elsif cnt>=2 and cnt<18 then
sync_out_tmp<='0';
da_data_out<=data_out_dac(17-cnt);
elsif cnt=20 then
sync_out_tmp<='1';
cnt:=0;
end if;
end if;
data_out_dac<= data_out;--赋值
end process;