1164 Reference Card
1164 Reference Card
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;
entity Adder4 is
port ( in1, in2 : in STD_LOGIC_VECTOR(3 downto 0) ;
mySum : out STD_LOGIC_VECTOR(3 downto 0) ) ;
end Adder4;
entity Adder_1 is
port ( A, B : in UNSIGNED(3 downto 0) ;
C : out UNSIGNED(4 downto 0) ) ; -- C(4) = carry
end Adder_1;
z <= a + b + c + d;
-- 3 adders stacked 3 deep a
+
b +
c + z
d
z <= (a + b) + (c + d);
-- 3 adders stacked 2 deep a
+
b
c + z
+
d
Resource sharing for
mutually-exclusive operations
process (a,b,c,test) begin
if (test=TRUE) then
o <= a + b ; -- either this evaluates
else
o <= a + c ; -- or this evaluates
end if ;
end process ;
-- Leonardo generates two adders & one mux
a
+
b
a o
+
c
test
Equivalent model
process (a,b,c,test) begin
variable tmp : integer range 0 to 255 ;
begin
if (test=TRUE) then -- mux will select b or c
tmp := b ;
else
tmp := c ;
end if ;
o <= a + tmp ; -- mux output added to a
end process ;
test
-- one adder and one mux generated b tmp
c + o
a