我已将我的代码修改为以下以从 50Mhz 输入时钟生成 0.5 Mhz 时钟我使用了同步计数器时钟启用并检测 din 输入数据上的 00110001 模式并输出同步脉冲,如图所示。但我希望 dout 同时检测到模式中的最后一位。请检查下面的代码,让我知道我哪里出错了。我真的很感谢你的帮助。谢谢你。
pattern_detector_clk_0_5mhz : process(clk_50mhz)
begin
if clk_50mhz'event and clk_50mhz = '1' then
if rst = '0' then
clk_enable_0_5mhz <= '0';
temp1 <= (others => '0');
else
temp1 <= temp1 +"1";
clk_enable_0_5mhz <= '0';
if temp1 >= x"63" then --hexadecimal value for 99
temp1 <= (others => '0');
clk_enable_0_5mhz <= not clk_enable_0_5mhz;
end if;
end if;
end if;
end process;
decoder_shift_reg_proc: process (clk_50mhz)
begin
if clk_50mhz'event and clk_50mhz = '1' then
if rst = '0' then
decoder_shift8 <= (others => '0');
elsif clk_enable_0_5mhz = '1' then
for i in 0 to 6 loop
decoder_shift8(i+1) <= decoder_shift8(i);
end loop;
decoder_shift8(0) <= din;
end if;
end if;
end process;
sync_detector_process: process(decoder_shift8)
begin
if decoder_shift8 = PATTERN_TO_DETECT or decoder_shift8 = not PATTERN_TO_DETECT then
sync_detected <= '1';
else
sync_detected <= '0';
end if;
end process;