Source: https://www.uqac.ca/ht2bui/exercices_vhdl.pdf