2016-03-19 19 views
0

Proses deyimini kullanarak vhdl programlamayı deniyorum. Aşağıda benim vhdl koduVHDL: işlem ve sayaç çalışmıyor

begin 

dcm_clk PORT MAP(
    CLKIN1_IN => clk, 
    RST_IN => reset, 
    CLKOUT0_OUT => clk0_fast, 
    CLKOUT1_OUT => clk0_dac, 
    CLKOUT2_OUT => clk90_fast, --13.33MHz ; div =60 
    CLKOUT3_OUT => clk_mux  --26.67MHz ; div =30 
); 


process(clk_mux, reset) 
begin 
if (reset = '0') then 
    if rising_edge(clk_mux) then 
     if count_m = 0 then -- 0 
      MUX_0 <= '1'; 
      count_m <= count_m + 1; 
     elsif count_m = 29 then 
      MUX_0 <= '0'; 
      count_m <= count_m + 1; 
     elsif count_m = 57 then 
      MUX_0 <= '1'; 
      count_m <= count_m + 1; 
     elsif count_m = 86 then 
      MUX_0 <= '0'; 
      count_m <= count_m + 1; 
     elsif count_m = 115 then 
      count_m <= (others => '0');   
    end if; -- end count_m 
    end if; -- end clock 

end if; -- end reset 

count_m değeri değerinde sıkışmış gibi görünüyor olduğunu '1'. Sayaç için neden bir artış olmadığını anlamıyorum. Herhangi bir yardım çok takdir edilir. testbenç çıkış Kişisel etiketsiz süreci sadece count_m dört belirli değerleri için count_m artan bir

Testbench Output

cevap

0

aşağıda gösterilmiştir ve count_m = 1 bunlardan biri değildir.

Dene:

UNLABELLED_PROCESS: 
    process (clk_mux, reset) 
    begin 
     if (reset = '0') then 
      if rising_edge(clk_mux) then 
       count_m <= count_m + 1; 
       if count_m = 0 then -- 0 
        MUX_0 <= '1'; 
        -- count_m <= count_m + 1; 
       elsif count_m = 29 then 
        MUX_0 <= '0'; 
        count_m <= count_m + 1; 
       elsif count_m = 57 then 
        MUX_0 <= '1'; 
        -- count_m <= count_m + 1; 
       elsif count_m = 86 then 
        MUX_0 <= '0'; 
        -- count_m <= count_m + 1; 
       elsif count_m = 115 then 
        count_m <= (others => '0');   
      end if; -- end count_m 
      end if; -- end clock 

     end if; -- end reset 
    end process; 

Ya yapar artım count_m her clk_mux ve değer olduğunda 115 hepsi '0 en atar.

Ve böyle bir şey verir: Ben senin saat dönemini aritmetik sağ sahipsek

no_mcve_incrementing.png

. Count_m + 1 'in count_m için atanmasının count_m = 115 için if ifadesiyle geçersiz kılındığını unutmayın. Ayrıca MUX_0'ın bir flip flop olduğunu ve bir değişiklik belirterek count_m değeri için bir sonraki clk_mux yükselen kenarından sonra çıkışın değiştiğini de görebilirsiniz.

Hata ayıklamaya yardımcı olması, yanıtlayan okuyucuya, bir Minimal, Complete, and Verifiable example sağlayarak belirli bir hatayı yeniden oluşturma olanağı sağlamalıdır. Bu durumda

o clk_mux için ikinci sürecin meselesiydi, her bir varlık ve mimarlık çiftinde (herhangi bir sıfırlama eylemi eksik) gerekli başlangıç ​​değerleri ile dört sinyal bildirimleri:

library ieee; 
use ieee.std_logic_1164.all; 
use ieee.numeric_std.all; 

entity no_mcve is 
end entity; 

-- dcm_clk PORT MAP(
--  CLKIN1_IN => clk, 
--  RST_IN => reset, 
--  CLKOUT0_OUT => clk0_fast, 
--  CLKOUT1_OUT => clk0_dac, 
--  CLKOUT2_OUT => clk90_fast, --13.33MHz ; div =60 
--  CLKOUT3_OUT => clk_mux  --26.67MHz ; div =30 
--); 

architecture foo of no_mcve is 
    signal count_m: unsigned (9 downto 0) := (others => '0'); 
    signal clk_mux: std_logic := '0'; -- clock 
    signal mux_0: std_logic := '0'; 
    signal reset: std_logic := '0'; 
begin 

UNLABELLED_PROCESS: 
    process (clk_mux, reset) 
    begin 
     if (reset = '0') then 
      if rising_edge(clk_mux) then 
       count_m <= count_m + 1; 
       if count_m = 0 then -- 0 
        MUX_0 <= '1'; 
        -- count_m <= count_m + 1; 
       elsif count_m = 29 then 
        MUX_0 <= '0'; 
        count_m <= count_m + 1; 
       elsif count_m = 57 then 
        MUX_0 <= '1'; 
        -- count_m <= count_m + 1; 
       elsif count_m = 86 then 
        MUX_0 <= '0'; 
        -- count_m <= count_m + 1; 
       elsif count_m = 115 then 
        count_m <= (others => '0');   
      end if; -- end count_m 
      end if; -- end clock 

     end if; -- end reset 
    end process; 
CLOCK: 
    process 
    begin 
     wait for 19.25 ns; 
     clk_mux <= not clk_mux; 
     if now > 7.3 us then 
      wait; 
     end if; 
    end process; 
end architecture; 
+0

Merhaba. Cevabınız için teşekkürler. Kodu çalıştırabilirim. Bunu daha önce göremedim, çözüm çok basitti.Ayrıca gelecekte bir çalışma kodu yayınladığımdan emin olacağım. – CanisMajoris