Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么我没有得到以下3时钟除vhdl代码的输出?_Vhdl - Fatal编程技术网

为什么我没有得到以下3时钟除vhdl代码的输出?

为什么我没有得到以下3时钟除vhdl代码的输出?,vhdl,Vhdl,下面的代码中没有合成错误,但在模拟时仍然没有得到输出cout始终保持逻辑1。请问有谁能帮我找出问题所在吗 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity divide_by_3 is port ( cout :out std_logic; -- Output clock clk :in std_lo

下面的代码中没有合成错误,但在模拟时仍然没有得到输出
cout
始终保持逻辑1。请问有谁能帮我找出问题所在吗

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

entity divide_by_3 is
port (
  cout   :out std_logic; -- Output clock
  clk    :in  std_logic; -- Input clock
  reset  :in  std_logic  -- Input reset
 );
end divide_by_3;

architecture Behavioral of divide_by_3 is
  signal pos_cnt :std_logic_vector (1 downto 0);
  signal neg_cnt :std_logic_vector (1 downto 0);
begin

  process (clk, reset) 
    begin
      if (reset = '1') then
        pos_cnt <= (others=>'0');
      elsif (rising_edge(clk)) then
        if (pos_cnt = "10") then
          pos_cnt <= pos_cnt + '1';
        end if;
      end if;
    end process;

    process (clk, reset) begin
      if (reset = '1') then
        neg_cnt <= (others=>'0');
      elsif (falling_edge(clk)) then
        if (neg_cnt = "10") then
          neg_cnt <= neg_cnt + '1';
        end if;
      end if;
    end process;

    cout <= '1' when ((pos_cnt /= "10") and (neg_cnt /= "10")) else
    '0';
end Behavioral;
IEEE库;
使用IEEE.STD_LOGIC_1164.ALL;
使用IEEE.STD_LOGIC_ARITH.ALL;
使用IEEE.STD_LOGIC_UNSIGNED.ALL;
实体除以3等于
港口(
输出标准逻辑——输出时钟
时钟:在标准逻辑中;--输入时钟
复位:在标准逻辑中——输入复位
);
结束除以3;
将_除以_3的架构行为是
信号位置:标准逻辑向量(1到0);
信号负:标准逻辑向量(1到0);
开始
过程(时钟、复位)
开始
如果(重置='1'),则
位置“0”);
elsif(上升沿(clk))然后
如果(pos_cnt=“10”),则

pos_cnt您的计数器永远不会计数,因为您:

    if (neg_cnt = "10") then
      neg_cnt <= neg_cnt + '1';
    end if;

您的计数器永远不会计数,因为您:

    if (neg_cnt = "10") then
      neg_cnt <= neg_cnt + '1';
    end if;
    if (pos_cnt = "10") then
      pos_cnt <= (others => '0');
    else
      pos_cnt <= pos_cnt + '1';
    end if;