本文介绍了VHDL-连接开关和LED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Xilinx Spartan6和下一个VHDL代码:

I have the Xilinx Spartan6 and next VHDL code:

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

entity Switches_Leds is
    Port (switch_0: in STD_LOGIC;
          LED_0 : out STD_LOGIC);
end Switches_Leds;

architecture Behavioral of Switches_Leds is
begin
   LED_0 <= switch_0;
end;

这是我的用户约束文件:

Here is my User constraint file:

NET "switch_0" LOC = C3;

NET "LED_0" LOC = P4;

我的问题是:为什么LED总是打开,但是如果我单击按钮,它就会熄灭?

My question is: Why the led is always is turned on, but it goes off if I click on button ?

我解释:我对我的fpga进行了编程-led已打开,我按下了开关按钮-led已关闭,我未按下按钮-led亮了.

I explain: I program my fpga - the led is turned on, I press the switch button - the led is turned off, I unpress the button - led goes on.

推荐答案

反转可能发生在两个地方:

The inversion can happen in two places:

  • 在按钮中.
  • 在LED中.

这完全取决于它们的连接方式.我画了一个图:

It all depends on how they are connected. I made a diagram:

(由于我们在EE网站上没有示意图编辑器,因此不得不绘制它)

(Had to draw it as we do not have a schematic editor here as on the EE site)

如果您查看该图:可以通过两种方式连接按钮.它们可以在被按下时产生高电平,也可以产生低电平.

If you look at the diagram: buttons can be connected in two ways. They can either generate a high when pushed or a low.

LED也可以通过两种方式连接:当输出为高时它们可以点亮,或者当输出为低时它们可以点亮.

LEDs can also be connected in two ways: they can light up when the output is high or they can light up when the output is low.

这提供了四个组合,其中两个组合在按下按钮时使LED点亮,而另两个组合在按下按钮时使LED熄灭.

That gives you four combinations from which two give an LED lighting up when the button is pushed and two give an LED which goes off when the button is pushed.

这篇关于VHDL-连接开关和LED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 05:11