2016-03-19 2 views
0

私はプロセスステートメントを使用してVHDLでプログラムしようとしています。以下は私のVHDLコードですVHDL:プロセスとカウンタが機能しません

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 

値が '1'にな​​っているようです。私はなぜカウンターのための増加がないのか分からない。どんな助けも大歓迎です。テストベンチからの出力は、あなたの非標識プロセスのみcount_mの4つの特定の値についてcount_mをインクリメントさ

Testbench Output

答えて

0

下に示され、そしてcount_m = 1はその一つではありません。

試してみてください。

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; 

そして、何これが行うことは、すべてのclk_muxインクリメントcount_mであり、値があるときに115が全て「0年代に割り当てます。

そして、そのようなものを与える:私はあなたのクロック周期算術右を得た場合

no_mcve_incrementing.png

。 count_m = 1へのcount_m + 1の割り当ては、count_m = 115のif文によって上書きされます。また、MUX_0がフリップフロップで、変更を指定するcount_m値の次のclk_muxの立ち上がりエッジの後に出力が変化することもわかります。

デバッグのヘルプは、Minimal, Complete, and Verifiable exampleを入力することによって、応答リーダーに特定のエラーを再現させる機能を提供する必要があります。この場合

それは、必要な初期値すべてのエンティティとアーキテクチャ対で(任意のリセット動作が欠落)を有する4つの信号宣言clk_muxのための第二の方法の問題であった:

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

こんにちは。お返事をありがとうございます。私はコードを動作させることができます。ソリューションがとてもシンプルだったので、私はこれを早期に見ることができませんでした。また、私は将来的に実用的なコードを投稿することを確認します。 – CanisMajoris

関連する問題