Constant Bit Signal in VHDL

fpgavhdl

I need to declare a bit with the constant value of 1.

What almost worked was:

signal name: bit := '1';

but the value of "name" is always '0' in this case.

How can I do this properly?

Full code:

ENTITY sleA IS
PORT(
    signal sel: std_logic; 
    A: in bit_vector (3 downto 0);
    S: out bit_vector (3 downto 0)
);
end sleA;
architecture arq_sleA of sleA is
begin
    sel <= '1';
    S(3) <= ((not sel) and A(3)) or (sel and A(2));
    S(2) <= ((not sel) and A(2)) or (sel and A(1));
    S(1) <= ((not sel) and A(1)) or (sel and A(0));
    S(0) <= ((not sel) and A(0)) or (sel and sel);
end arq_sleA;

Best Answer

If sel is an input for the entity then you can set the initial value in the entity's port:

port(
  sel: in std_logic := '1';
  A: in bit_vector (3 downto 0);
  S: out bit_vector (3 downto 0)
);

This will work in simulation, but for synthesis make sure your target technology supports initial "power-on" values (true for FPGAs, not so for ASICs). See Is initialization necessary?

Also note that signal is only used in the architecture body, not entity declaration.

Related Topic