【发布时间】:2015-04-02 02:34:20
【问题描述】:
我有一个奇怪的问题,在 vhdl 中听起来不言自明,但即使逻辑看起来没问题,代码也不会输出到示波器。我需要为下面向量中的每个位驱动 0 和 1,并且我需要使用滑块开关的组合来执行此操作。我正在使用 Digilent Nexys 3。
我的问题是,当我运行此代码或每个 if 语句具有 3 个以上输出的任何代码时,如果给出正确的组合,其中一个输出不会输出到逻辑“1”。
我在下面给出了我的代码,这看起来非常简单。有人能告诉我为什么每个 if 语句只能输出 3 件事吗?我需要能够为每个 if 语句输出 20 个或更多信号。
我已经尝试了所有我能想到的方法,从使用 bit_vector 到使用不同的语法。任何关于为什么我最多只能获得 3 个输出的帮助将不胜感激。
Library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.all ;
entity pulse_gen_toVGA is port (
clk_50,sw0,sw1,sw2,sw3 : in std_logic ;
rst : in std_logic;
output : out std_logic_vector(3 downto 0));
end pulse_gen_toVGA;
architecture top of pulse_gen_toVGA is
begin
process(sw0,sw1,sw2,sw3)
begin
if (sw0='0' and sw1='0' and sw2='0' and sw3='0') then
null;
end if;
if(sw0='1') then
output<="0001";
elsif(sw1='1') then
output<="0010";
elsif(sw2='1') then
output<="0100";
elsif(sw3='1') then
output<="1000";
end if;
end process;
end top ;
这是我正在使用的输出的 ucf 文件。
net "clk_50" loc="v10";
net "output<0>" loc="t12";
net "output<1>" loc="n10";
net "output<2>" loc="p11";
net "output<3>" loc="h3";
net "sw0" loc="t10";
net "sw1" loc="t9";
net "sw2" loc="v9";
net "sw3" loc="m8";
【问题讨论】:
标签: if-statement vhdl