VHDL Pins logic

Discussion in 'General Electronics Chat' started by Dritech, May 28, 2015.

  1. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Hi all,

    I was using a VHDL code which consists from switches. I used the following code to detect the switch activity:

    if (SW = '1') then

    When looking at the datasheet of the FPGA board I realized that the pins are connected with pullup resistors and a switch to ground.
    Should the code be: if (SW = '0') then ?

    If so, why is the program working fine with: if (SW = '1') then ?

    Also, what is meant by: (others => '0'); ?

    Thanks in advance and sorry for my poor English.
     
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    ...probably because there isn't much of a difference in a closed switch versus an open switch from an external point of view.

    This means your switch is actually open (no current between connections) when the statements after your if statement are evaluated.

    It means all other bits than those specified are '0'.

    If you had a four-bit std_logic_vector, named data_bus, then
    Code (Text):
    1. data_bus <= (others => '0');
    is equivalent to
    Code (Text):
    1. data_bus <= "0000";
    This is quite useful when using large vectors.
     
    Dritech likes this.
Loading...