VHDL Signals
Quick Syntax
-- signal declaration
signal my_sl : std_logic;
signal my_slv : std_logic_vector(7 downto 0);
signal my_integer : integer;
......
-- and you can initialize signals like this:
signal my_sl : std_logic := '0';
signal my_slv : std_logic_vector(7 downto 0) := "00001000";
signal my_integer : integer range -4 to 4;
......
-- signal assignment
my_sl <= '0';
my_slv <= "11111111"; -- or you can write it in hex: x"00"
my_integer <= 3;
-- signal assignment from other inputs or signals
my_sl <= input_sl;
my_slv <= input_slv;
my_integer <= other_integer;
Purpose
The purpose of signals is for connecting pins of entities, components, etc. You also use signals to write logic. Signals can be many different types, but make sure that when they interact with each other, they are compatible since VHDL is strictly typed.
Prior to VHDL-2008, you could not read pins that were outputs. The common solution was to use a signal internally, and then drive the output pin with that signal so that you can also read that signal as needed.
VHDL-2008 allows you to directly read output pins, so you don't have to use an intermediate signal. However, not all tools are fully compatible with VHDL-2008, even now in 2020.
Personally, I continue to use the prior method of internal signals if they need to be read. That way, my code can work on VHDL all the way back including older designs and tool chains.
Best Practices
1. Signals are a foundational way of connecting things in VHDL.
2. You can initialize signals with a := when you declare it. However, while it usually works in most simulators, you will need to consult with your synthesis tool documentation to see how it's implemented in hardware.