For beginners, it is easier to start by implementing basic logic gates using VHDL. This helps them get familiar with the language and learn how to do define signals, architectures etc. For example, to implement a simple AND gate, we need two inputs and one output. First of all, hardware input/output ports are defined in an entity. Entity is a VHDL keyword and its use is explained below:
entity newbie_code is
port (
in1 : in std_logic;
in2 : in std_logic;
and_output : out std_logic
);
end newbie_code;
Here, newbie_code is the name of the entity that we are defining which contains two inputs: in1 and in2, and one output and_output. The inputs and outputs are of std_logic type. As you know in all programming languages, variables must have a type, here the type is std_logic, which means it can have either a value of 0 or 1 (for now). The keywords in and out define whether the ports are input or output. Now that the entity is defined, we can define the architecture :
architecture rtl of newbie_code is
signal and_gate : std_logic;
begin
and_gate <= in1 and in2;
and_output <= and_gate;
end rtl;
A signal is declared inside the architecture of std_logic type. This signal, and_gate, is assigned the value of the result we get when in1 is anded with in2. '<=' is the assignment operator. Finally, and_gate is assigned to our output. This concludes the code of an AND gate implementation. The only thing left is to remember to include libraries at the top of the code that contains the definitions of functions used in the code. For the above code we must include these lines at the top:
library ieee;
use ieee.std_logic_1164.all;
Some other great examples to look at are implementation of MUX, adder, XOR gate, flip flops etc.