计数器VHDL多路复用器7段

时间:2013-11-29 20:53:34

标签: vhdl spartan seven-segment-display

我是VHDL的新手,我的代码可能看起来很愚蠢,但我仍在苦苦挣扎。 我正在尝试使用Spartan 3套件制作BCD计数器。 我有一个多路复用7段的问题,我知道我应该使用组件 但我走的更简单。 我在综合中遇到这个错误:“103行:过程灵敏度列表中缺少一个或多个信号”。为了能够合成FPGA / CPLD硬件,XST将假设灵敏度列表中存在所有必需的信号。请注意,合成的结果可能与初始设计规格不同。丢失的信号是:     任何帮助赞赏。谢谢。

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

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity lab5 is
  port (clk      : in  std_logic;
        x        : in  std_logic;
        --count : inout  STD_LOGIC_VECTOR (3 downto 0);
        data_out : out std_logic_vector (6 downto 0);
        an       : out std_logic_vector (3 downto 0)
        );

end lab5;

architecture Behavioral of lab5 is
  signal counter    : std_logic_vector (3 downto 0) := (others => '0');
  signal prescaler  : std_logic_vector (25 downto 0);
  signal prescaler2 : std_logic_vector (11 downto 0);
  signal counter2   : std_logic_vector (1 downto 0) := (others => '0');
begin

  CounterProcess : process(CLK, x)
  begin
    --prescaler is used as a clock slower to increment the counter every 50M cycles(1 sec)
    if rising_edge(CLK) then
      if prescaler < "10111110101111000010000000" then
        prescaler <= prescaler+1;

      else
        prescaler <= (others => '0');
        if x = '0' then
          if counter = "1001" then
            counter <= "0000";
          else
            counter <= counter+1;
          end if;
        else
          if counter = "0000" then
            counter <= "1001";
          else
            counter <= counter-1;
          end if;
        end if;
      end if;
    end if;

  end process;

--count<=counter;

  Sevensegclock : process(CLK)
  begin
    if rising_edge(CLK) then
      --scale clock to count(which will be the segment selector) every 1024 cycle
      if prescaler2 < "010000000000" then
        prescaler2 <= prescaler2+1;

      else
        prescaler2 <= (others => '0');
        if counter2 = "11" then
          counter2 <= "00";
        else
          counter2 <= counter2+1;
        end if;
      end if;
    end if;

  end process;

  sevenseg : process(counter2, clk)
  begin
    --counter the segment selector used to activate selector and decode data
    if counter2 = "00" then
      an <= "1110";
      if counter(0) = '0' then
        data_out <= "0000001";
      else
        data_out <= "1001111";
      end if;

    end if;

    if counter2 = "01" then
      an <= "1101";
      if counter(1) = '0' then
        data_out <= "0000001";
      else
        data_out <= "1001111";
      end if;
    end if;

    if counter2 = "10" then
      an <= "1011";

      if counter(2) = '0' then
        data_out <= "0000001";
      else
        data_out <= "1001111";
      end if;
    end if;

    if counter2 = "11" then
      an <= "0111";
      if counter(3) = '0' then
        data_out <= "0000001";
      else
        data_out <= "1001111";
      end if;
    end if;

  end process;

end Behavioral;

1 个答案:

答案 0 :(得分:1)

一个开始的地方,是每个进程确定它是否实现 顺序元件(触发器)或组合元件(门)。

实现顺序元素(触发器)的进程的模板, 没有异步重置,可以是:

process (clk) is
begin
  if rising_edge(clk) then
    -- Code for assign to flip-flop outputs at rising edge
  end if;
end process;

实现组合元素(gate)的进程的模板可以 是:

process (all) is  -- "all" make sensitivity on all used signals
begin
  -- Code for assign to gate outputs
end process;

请注意,(all)仅适用于VHDL-2008语法,不适用于以前的VHDL 版本语法在敏感列表中明确列出所有信号

匹配其中一个模板使综合工具确定如何 实现VHDL代码中描述的设计。但是,如果代码匹配 既不是模板,那么综合工具可能会有困难 确定如何在FPGA中实现VHDL代码,结果可能是a 错误信息,就像你得到的那样。

基于模板,流程Sevensegclock实现了顺序 元素(触发器),这个过程应该没有问题。

但是,流程CounterProcesssevenseg不匹配 顺序或组合元素的模板。

对于流程CounterProcess,您似乎想实现一个 顺序元素(触发器),但灵敏度列表包含x。该 解决方案可能是从敏感性列表中删除x

对于流程sevenseg,您似乎希望实现组合 元素(门),但灵敏度列表不包括所有使用的信号 在此过程中,甚至包括过程中未使用的clk。 如果您使用的是VHDL-2008,那么解决方案就是将灵敏度列表替换为 (all),如果使用以前的VHDL版本,则制作敏感度列表 涵盖流程(counter2, counter)中使用的所有信号。

免责声明:我没有检查过代码的逻辑正确性 处理;所以上面只是给出一些如何写的一般指导 过程是为了在FPGA中制作不同类型的设计元素。