Article ID: 000083251 Content Type: Product Information & Documentation Last Reviewed: 09/11/2012

How do I use LeonardoSpectrum's predefined VHDL arithmetic functions? (Leonardo, VHDL)

Environment

BUILT IN - ARTICLE INTRO SECOND COMPONENT
Description

The Exemplar package in LeonardoSpectrum defines several commonly used functions for use in VHDL. They should be treated like typical functions, as shown in the following code that uses the predefined add function:

library ieee;
use ieee.std_logic_1164.all;
library exemplar;
use exemplar.exemplar_1164.all;
entity adder is
port (
a : in std_logic_vector (3 downto 0);
b : in std_logic_vector (3 downto 0);
result : out std_logic_vector (4 downto 0)
);
end adder;
architecture altera of adder is
signal q : std_logic_vector (4 downto 0);
begin
q <= add(a, b);
result <= q;
end altera;

The add function takes two vectors and returns a vector one bit larger than the largest of the input vectors. Therefore, result and q are both one bit larger than the input vectors a and b. The extra bit is used as the carry bit.

Other operators such as the must be used in a slightly different way. Since the operator does not account for the carry bit, result and q can be the same size as the inputs a and b. You must also replace the assignment to q as follows:

q <= a   b;

More information about these functions can be found in the on-line HDL Synthesis manual and the on-line LeonardoSpectrum manual.

Related Products

This article applies to 1 products

Intel® Programmable Devices

1