0

私は自分のプロジェクトで VHDL を学ぼうとしているアナログ エンジニアです。このプロジェクトは、入力信号の立ち上がりエッジをカウントし、カウントをより小さな数にプリスケールすることです。たとえば、入力に 8 カウントがある場合、1 カウントが出力されます。プリスケール値はユーザーが変更できます。私はプリスケール部分をうまく処理できましたが、現時点では出力が常に高くなります。

私がやろうとしているのは、プリスケール カウントが = ユーザーが選択した値になると、一定のロジック ハイではなく 500 ns パルスが出力されることです。

私は 50 MHz の clk を持っているので、出力は 25 のロック サイクルの間ハイのままにする必要がありますが、これを行う方法がわかりません。

どんな助けでも素晴らしいでしょう:)

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;


entity counter is
port (
    pushbutton: in std_logic;
    SW: in std_logic_vector(7 downto 0); -- user select switches
    RESET: in std_logic;
    OUTPUT: out std_logic;
    LEDS: out std_logic_vector(8 downto 0) -- un used leds

);
end counter;

architecture Behavioral of counter is
signal COUNTER: std_logic;
signal PRESCALER: std_logic_vector(7 downto 0);
signal SWITCH: std_logic_vector(7 downto 0);
begin

CounterProcess: process(RESET, pushbutton)
begin
    if rising_edge(pushbutton) then
        if RESET = '0' then
            PRESCALER <= (others => '0');
            COUNTER <= '0';
        else        
            if PRESCALER < SWITCH - 1 then
            PRESCALER <= PRESCALER + 1;
            else
                PRESCALER <= (others => '0');
                COUNTER <= '1';
                end if;
        end if;
    end if;
end process;

LEDS <= (others => '0'); -- Turn off all unsed LEDs
SWITCH <= SW; -- Asign switch value into a signal 
OUTPUT <= COUNTER; 

end Behavioral;
4

1 に答える 1