VHDL对时钟的误解

VHDL对时钟的误解,vhdl,Vhdl,我有一个关于我的VHDL代码的问题。代码是为一个机器人编写的,它应该能够探测到地雷。这段代码是这个特定地雷探测器的代码。出纳员传感器进程不工作。我知道,因为它将在FPGA芯片上编程,所以只能有一个时钟。但是我不知道该怎么做才能让这个过程正常工作。我希望你们愿意帮助我:) 罗伯托 代码如下: LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; use IEEE.numeric_std.all; library ieee; use ieee.numeric_std.

我有一个关于我的VHDL代码的问题。代码是为一个机器人编写的,它应该能够探测到地雷。这段代码是这个特定地雷探测器的代码。出纳员传感器进程不工作。我知道,因为它将在FPGA芯片上编程,所以只能有一个时钟。但是我不知道该怎么做才能让这个过程正常工作。我希望你们愿意帮助我:)

罗伯托

代码如下:

LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
use IEEE.numeric_std.all;
library ieee; use ieee.numeric_std.all;

entity metaal_detector is
port (clk    : in std_logic;
      sensor : in std_logic;
      reset  : in std_logic;
      metaal : out std_logic
);
end entity metaal_detector;

architecture behavioural of metaal_detector is
signal count, count_sensor, stand, clock1, sensor1, stand1 : unsigned (10 downto 0);
signal reset_teller, resets, metaals: std_logic;

begin

teller_clk: process (clk)
begin
if rising_edge(clk) then
  if ((reset ='1') or (resets = '1')) then
    count <= (others => '0');
  else
    count <= count + 1;
  end if;
end if;
end process;


teller_sensor: process (sensor)
begin
if rising_edge(clk) then
  if ((reset ='1') or (resets = '1')) then
    count_sensor <= (others => '0');
  else
    if (sensor'event and sensor='1') then
      count_sensor <= count_sensor + 1;
    end if;
  end if;
end if;
end process;


process(clk)
begin
if (unsigned(clock1) = 71) then
  stand <= clock1;
  reset_teller <= '1';
else
  reset_teller <= '0';
  stand <= stand;
end if;
end process;

process(clk)
begin
if (unsigned(stand1) < 70) then
  metaals <= '1';
else
  metaals <= '0';
end if;
end process;


clock1 <= count;
sensor1 <= count_sensor;
stand1 <= stand;
resets <= reset_teller;
metaal <= metaals;

end architecture behavioural;
IEEE库;
使用IEEE.std_logic_1164.ALL;
使用IEEE.numeric_std.all;
图书馆ieee;使用ieee.numeric_std.all;
实体metaal_检测器是
端口(时钟:在标准逻辑中;
传感器:标准逻辑;
复位:在标准逻辑中;
metaal:输出标准逻辑
);
终端实体metaal_检测器;
metaal_探测器的结构行为是
信号计数,计数传感器,支架,时钟1,传感器1,支架1:无符号(10到0);
信号复位\出纳、复位、元:标准\逻辑;
开始
柜员时钟:进程(时钟)
开始
如果上升沿(clk),则
如果((reset='1')或(reset='1')),则
计数“0”);
其他的

计数在流程顶部指定clk而不是传感器。然后对内部传感器的状态进行采样,也就是说在感兴趣的时钟边缘

这种方法并非没有理论上的问题(亚稳定性、采样理论),但它很可能让您走上某种程度的功能化道路


现在什么都没有发生,因为只有当传感器的变化触发这个过程的同时,恰巧有一个clk的上升沿。在很少使用的硬件中(并且在边缘检测器是时钟输入一部分的典型块中无法实现),在模拟中可能不可能(您必须阅读详细的语言和模拟器规则),但无论如何,它都不能满足您的需要。

谢谢您的回答。我在灵敏度列表中切换了clk传感器。然而,我真的不明白你所说的“然后在感兴趣的时钟边缘采样传感器的状态”是什么意思。你能给我解释一下吗?