Я новичок в кодировании в VHDL и не понимаю, почему мой код не будет отображать вывод при моделировании файла VWF - PullRequest
0 голосов
/ 06 июня 2019

Мой код не будет имитировать вывод при запуске файла VWF.

Я пытался изменить код несколько раз, и я действительно не понимаю, что я делаю неправильно.

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

            entity Counter_JM is
            Port (    
                up_down : in std_logic;
                    LED : out std_logic;
                Q   : Buffer integer Range 0 to 7);

            end Counter_JM;

            architecture archi of Counter_JM is

            Begin

                -- up/down counter
                process (up_down)
                begin
                    if (Q=7) then
                        Q<=0;   
                    end if;

                    if (up_down = '1') then
                        Q <= Q + 1; 
                    else   
                        Q<=0;           
                    end if;

                    if (Q=0 or Q=1) then
                        LED <= '0';
                    else 
                        LED <= '1';
                    end if;

                end process;    
            end archi;

Выходной сигнал светодиода должен показывать высокий для 4 циклов и низкий для 2 в файле VWF

1 Ответ

0 голосов
/ 07 июня 2019

Я не знаю, почему вы используете up_down. Но, как сказал Олдфарт, у тебя нет часов. Я упростил и изменил ваш код (он работает для меня (в modelsim):

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

entity Counter_JM is
     Port (   
            clk: in std_logic;
            up_down : in std_logic;
            LED : out std_logic
                );
end Counter_JM;

architecture archi of Counter_JM is


Begin

process (clk)


    variable Q: integer range 0 to 7;

begin

    if rising_edge(clk) then
        -- up/down counter     

        Q := Q + 1;

    if Q=1 or Q=2 then
        LED <= '0';
    else
        LED <= '1';
    end if;

    if Q = 7 then
        Q := 0;
    end if;

    end if;

end process;    

 end archi;

, а также создал / сгенерировал простой тестовый стенд здесь :

`-- Testbench automatically generated online
-- at http://vhdl.lapinoo.net
-- Generation date : 7.6.2019 11:22:53 GMT

library ieee;
use ieee.std_logic_1164.all;

entity tb_Counter_JM is
end tb_Counter_JM;

architecture tb of tb_Counter_JM is

    component Counter_JM
        port (clk     : in std_logic;
              up_down : in std_logic;
              LED     : out std_logic);
    end component;

    signal clk     : std_logic;
    signal up_down : std_logic;
    signal LED     : std_logic;

    constant TbPeriod : time := 1000 ns; -- EDIT Put right period here
    signal TbClock : std_logic := '0';
    signal TbSimEnded : std_logic := '0';

begin

    dut : Counter_JM
    port map (clk     => clk,
              up_down => up_down,
              LED     => LED);

    -- Clock generation
    TbClock <= not TbClock after TbPeriod/2 when TbSimEnded /= '1' else '0';

    -- EDIT: Check that clk is really your main clock signal
    clk <= TbClock;

    stimuli : process
    begin
        -- EDIT Adapt initialization as needed
        up_down <= '0';

        -- EDIT Add stimuli here
        wait for 100 * TbPeriod;

        -- Stop the clock and hence terminate the simulation
        TbSimEnded <= '1';
        wait;
    end process;

end tb;

-- Configuration block below is required by some simulators. Usually no need to edit.

configuration cfg_tb_Counter_JM of tb_Counter_JM is
    for tb
    end for;
end cfg_tb_Counter_JM;`
...