0

VHDL コードについて質問があります。コードは、地雷を検出できるはずのロボット用です。このコードは、この特定の地雷探知機のコードです。teller_sensor プロセスが機能しません。FPGAチップでプログラムされるため、クロックは1つしか持てません。しかし、プロセスを機能させるために何をすべきかわかりません。皆さんが喜んで私を助けてくれることを願っています:)

ロベルト

コードは次のとおりです。

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;
4

1 に答える 1

1

プロセスの先頭でセンサーではなく clk を指定します。次に、対象のクロック エッジでセンサーの状態をサンプリングします。

このようなアプローチには、理論的な問題 (準安定性、サンプリング理論) がないわけではありませんが、ある程度の機能への道を歩む可能性があります。

clk の立ち上がりエッジがたまたま発生するのと同時にセンサーの変化がプロセスをトリガーした場合にのみ発生する可能性があるため、現時点では何も起こりません。ハードウェアではまれです (エッジ検出器がクロック入力の一部である典型的なブロックでは実装できません) - シミュレーションでは不可能かもしれません (詳細な言語とシミュレータのルールを読む必要があります)。それはあなたが必要とすることをしますか。

于 2013-05-29T13:44:28.427 に答える